287{
289
290
291 if (filename[0]) {
293 if (!file){
294 parseStr += "Error! - File '";
295 parseStr += filename;
296 parseStr +="' not found.\n";
297 delete file;
298 return false;
299 }
300
302
303
304 if (!strcmp(format, "text")) {
306 char *buf = (char *) new char[num];
307
308 if (!buf) {
309 perror("Memory Error");
310 parseStr += "'";
311 parseStr += filename;
312 parseStr += "' may not be a valid text file.\n";
313 delete buf;
314 delete file;
315 return false;
316 }
317
318 if (file->
Read8(buf, num) !=num) {
319 perror("Read-File Error");
320 parseStr += "'";
321 parseStr += filename;
322 parseStr += "' may not be a valid text file.\n";
323 delete buf;
324 delete file;
325 return false;
326 }
327
329
330
332 parseStr += "File '";
333 parseStr += filename;
334 parseStr += "' is not a valid text file.\n";
336 delete buf;
337 delete file;
338 return false;
339 }
340
341 else {
345
347 for (i=0; i<data.
GetSize(); i++) {
348 *dst = *src;
349 dst++;
350 src++;
351 }
352 }
353
354 delete buf;
355 delete file;
356 return true;
357
358 }
359
360 else if (!strcmp(format, "binary")) {
362 bool little_endian = !strcmp(order, "little");
363
366 if (attr) {
368 }
369
373
377 for (i=0; i<num; i++) {
378 if (!file->
Read8(&value)) {
379 perror("Read-File Error");
380 parseStr += "'";
381 parseStr += filename;
382 parseStr += "' may not be a valid binary file.\n";
383 delete file;
384 return false;
385 }
387 }
388 delete file;
389 return true;
390 }
395
399 for (i=0; i<num; i++) {
400 if (!file->
Read16(&value)) {
401 perror("Read-File Error");
402 parseStr += "'";
403 parseStr += filename;
404 parseStr += "' may not be a valid binary file.\n";
405 delete file;
406 return false;
407 }
408#ifdef ICC_BYTE_ORDER_LITTLE_ENDIAN
409 if (little_endian) {
410#else
411 if (!little_endian) {
412#endif
414 m_ptr[0] = m_ptr[1];
415 m_ptr[1] = t;
416 }
418 }
419 delete file;
420 return true;
421 }
426
430 for (i=0; i<num; i++) {
431 if (!file->
Read16(&value)) {
432 perror("Read-File Error");
433 parseStr += "'";
434 parseStr += filename;
435 parseStr += "' may not be a valid binary file.\n";
436 delete file;
437 return false;
438 }
439#ifdef ICC_BYTE_ORDER_LITTLE_ENDIAN
440 if (little_endian) {
441#else
442 if (!little_endian) {
443#endif
445 m_ptr[0] = m_ptr[1];
446 m_ptr[1] = t;
447 }
449 }
450 delete file;
451 return true;
452 }
457
460
462 for (i=0; i<num; i++) {
464 perror("Read-File Error");
465 parseStr += "'";
466 parseStr += filename;
467 parseStr += "' may not be a valid binary file.\n";
468 delete file;
469 return false;
470 }
471#ifdef ICC_BYTE_ORDER_LITTLE_ENDIAN
472 if (little_endian) {
473#else
474 if (!little_endian) {
475#endif
477 tmp = m_ptr[0]; m_ptr[0] = m_ptr[3]; m_ptr[3] = tmp;
478 tmp = m_ptr[1]; m_ptr[1] = m_ptr[2]; m_ptr[2] = tmp;
479 }
480 *dst++ = value;
481 }
482 delete file;
483 return true;
484 }
485 else {
486 delete file;
487 return false;
488 }
489 }
490 }
491 else {
493
495 return false;
496 }
497
499 return false;
500 }
501
503 }
504
505 return true;
506}
float icFloatNumber
All floating point operations/variables in IccProfLib use the icFloatNumber data type.
CIccIO * IccOpenFileIO(const icChar *szFilename, const char *szAttr)
icFloatNumber icF16toF(icFloat16Number num)
xmlAttr * icXmlFindAttr(xmlNode *pNode, const char *szAttrName)
const char * icXmlAttrValue(xmlAttr *attr, const char *szDefault)
unsigned int icUInt32Number
icInt32Number ReadFloat32Float(void *pBufFloat, icInt32Number nNum=1)
virtual icInt32Number GetLength()
virtual icInt32Number Read8(void *pBuf8, icInt32Number nNum=1)
icInt32Number Read16(void *pBuf16, icInt32Number nNum=1)
icFloatNumber * m_pSamples
virtual bool SetSize(icUInt32Number nSize, bool bZeroAlloc=true)
Name: CIccSampledCurveSegment::SetSize.
static bool ParseArray(T *buf, icUInt32Number nBufSize, xmlNode *pNode)
bool ParseTextArrayNum(const char *szText, icUInt32Number num, std::string &parseStr)