Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
IccTagXml.cpp File Reference

File: IccTagXML.cpp. More...

#include "IccTagXml.h"
#include "IccMpeXml.h"
#include "IccUtil.h"
#include "IccUtilXml.h"
#include "IccIoXml.h"
#include "IccSparseMatrix.h"
#include "IccProfileXml.h"
#include "IccStructFactory.h"
#include "IccArrayFactory.h"
#include <cstring>
#include <set>
#include <map>
#include <sstream>
#include <iomanip>
+ Include dependency graph for IccTagXml.cpp:

Go to the source code of this file.

Typedefs

typedef std::map< icUInt32Number, icTagSignatureIccOffsetTagSigMap
 

Functions

CIccCLUTicCLutFromXml (xmlNode *pNode, int nIn, int nOut, icConvertType nType, std::string &parseStr)
 
bool icCurvesFromXml (LPIccCurve *pCurve, icUInt32Number nChannels, xmlNode *pNode, icConvertType nType, std::string &parseStr)
 
bool icCurvesToXml (std::string &xml, const char *szName, CIccCurve **pCurves, int numCurve, icConvertType nType, std::string blanks)
 
bool icMatrixFromXml (CIccMatrix *pMatrix, xmlNode *pNode)
 
bool icMatrixToXml (std::string &xml, CIccMatrix *pMatrix, std::string blanks)
 
bool icMBBFromXml (CIccMBB *pMBB, xmlNode *pNode, icConvertType nType, std::string &parseStr)
 
bool icMBBToXml (std::string &xml, CIccMBB *pMBB, icConvertType nType, std::string blanks="", bool bSaveGridPoints=false)
 
bool icProfDescToXml (std::string &xml, CIccProfileDescStruct &p, std::string blanks="")
 
static bool icXmlDumpTextData (std::string &xml, std::string blanks, const char *szText, bool bConvert=true)
 
bool icXmlParseProfDesc (xmlNode *pNode, CIccProfileDescStruct &p, std::string &parseStr)
 
static std::string icXmlParseTextString (xmlNode *pNode, std::string &parseStr, bool bConvert=true)
 

Detailed Description

File: IccTagXML.cpp.

Contains: Implementation ICC tag XML format conversions

Version: V1

Copyright: (c) see ICC Software License

Definition in file IccTagXml.cpp.

Typedef Documentation

◆ IccOffsetTagSigMap

Definition at line 79 of file IccTagXml.cpp.

Function Documentation

◆ icCLutFromXml()

CIccCLUT * icCLutFromXml ( xmlNode * pNode,
int nIn,
int nOut,
icConvertType nType,
std::string & parseStr )

Definition at line 3315 of file IccTagXml.cpp.

3316{
3317 CIccCLUT *pCLUT = NULL;
3318
3319 int nPrecision = 2;
3320 if (nType == icConvert8Bit)
3321 nPrecision = 1;
3322
3323 icUInt8Number nInput = (icUInt8Number)nIn;
3324 icUInt16Number nOutput = (icUInt16Number)nOut;
3325
3326 pCLUT = new CIccCLUT(nInput, nOutput, nPrecision);
3327
3328 if (!pCLUT){
3329 parseStr += "Error in creating CLUT Table. Check values of Precision, InputChannel, or OutputChannels.\n";
3330 return NULL;
3331 }
3332
3333 xmlNode *grid = icXmlFindNode(pNode->children, "GridPoints");
3334 if (grid) {
3335 CIccUInt8Array points;
3336
3337 if (points.ParseArray(grid->children)) {
3338 if (!pCLUT->Init(points.GetBuf())) {
3339 parseStr += "Error in setting the size of GridPoints. Check values of GridPoints, InputChannel, or OutputChannels.\n";
3340 delete pCLUT;
3341 return NULL;
3342 }
3343 }
3344 else {
3345 parseStr += "Error parsing GridPoints.\n";
3346 delete pCLUT;
3347 return NULL;
3348 }
3349 }
3350 else {
3351 icUInt8Number nGridGranularity;
3352
3353 xmlAttr *gridGranularity = icXmlFindAttr(pNode, "GridGranularity");
3354
3355 if (gridGranularity) {
3356 nGridGranularity = (icUInt8Number)atoi(icXmlAttrValue(gridGranularity));
3357 }
3358 else {
3359 delete pCLUT;
3360 return NULL;
3361 }
3362 if (!pCLUT->Init(nGridGranularity)) {
3363 parseStr += "Error in setting the size of GridGranularity. Check values of GridGranularity, InputChannel, or OutputChannels.\n";
3364 delete pCLUT;
3365 return NULL;
3366 }
3367 }
3368
3369 xmlNode *table = icXmlFindNode(pNode->children, "TableData");
3370
3371 if (table) {
3372 if (nType == icConvertVariable) {
3373 const char *precision = icXmlAttrValue(table, "Precision");
3374 if (precision && atoi(precision) == 1) {
3375 nType = icConvert8Bit;
3376 pCLUT->SetPrecision(1);
3377 }
3378 else {
3379 nType = icConvert16Bit;
3380 pCLUT->SetPrecision(2);
3381 }
3382 }
3383
3384 const char *filename = icXmlAttrValue(table, "Filename");
3385 if (!filename || !filename[0]) {
3386 filename = icXmlAttrValue(table, "File");
3387 }
3388
3389 if (filename[0]) {
3390 CIccIO *file = IccOpenFileIO(filename, "rb");
3391
3392 if (!file) {
3393 // added error message
3394 parseStr += "Error! - File '";
3395 parseStr += filename;
3396 parseStr +="' not found.\n";
3397 delete pCLUT;
3398 return NULL;
3399 }
3400
3401 const char *format = icXmlAttrValue(table, "Format");
3402
3403 if (!strcmp(format, "text")) {
3404 icUInt32Number num = file->GetLength();
3405 char *buf = (char *)malloc(num);
3406
3407 if (!buf) {
3408 perror("Memory Error");
3409 parseStr += "'";
3410 parseStr += filename;
3411 parseStr += "' may not be a valid text file.\n";
3412 delete file;
3413 delete pCLUT;
3414 return NULL;
3415 }
3416
3417 //Allow for different encoding in text file than implied by the table type
3418 const char *encoding = icXmlAttrValue(table, "FileEncoding");
3419
3420 if (!strcmp(encoding, "int8"))
3421 nType = icConvert8Bit;
3422 else if (!strcmp(encoding, "int16"))
3423 nType = icConvert16Bit;
3424 else if (!strcmp(encoding, "float"))
3425 nType = icConvertFloat;
3426 else if (encoding[0]) {
3427 parseStr+= "Unknown encoding \"";
3428 parseStr+= encoding;
3429 parseStr+= "\" - using default encoding\n";
3430 }
3431
3432 if (file->Read8(buf, num)!=num) {
3433 perror("Read-File Error");
3434 parseStr += "'";
3435 parseStr += filename;
3436 parseStr += "' may not be a valid text file.\n";
3437 free(buf);
3438 delete file;
3439 delete pCLUT;
3440 return NULL;
3441 }
3442
3443 if (nType == icConvert8Bit) {
3444 CIccUInt8Array data;
3445
3446 if (!data.ParseTextArrayNum(buf, num, parseStr)) {
3447 parseStr += "File '";
3448 parseStr += filename;
3449 parseStr += "' is not a valid text file.\n";
3450 free(buf);
3451 delete file;
3452 delete pCLUT;
3453 return NULL;
3454 }
3455
3456 if (data.GetSize()!=pCLUT->NumPoints()*pCLUT->GetOutputChannels()) {
3457 parseStr += "Error! - Number of entries in file '";
3458 parseStr += filename;
3459 parseStr += "'is not equal to the size of the CLUT Table.\n";
3460 parseStr += " a. Check values of GridGranularity/GridPoints, InputChannel, or OutputChannels.\n";
3461 parseStr += " b. File may not be a valid text file.\n";
3462 free(buf);
3463 delete file;
3464 delete pCLUT;
3465 return NULL;
3466 }
3467 icUInt8Number *src = data.GetBuf();
3468 icFloatNumber *dst = pCLUT->GetData(0);
3469
3471 for (i=0; i<data.GetSize(); i++) {
3472 *dst++ = (icFloatNumber)(*src++) / 255.0f;
3473 }
3474 }
3475 else if (nType == icConvert16Bit) {
3476 CIccUInt16Array data;
3477
3478 if (!data.ParseTextArrayNum(buf, num, parseStr)) {
3479 parseStr += "File '";
3480 parseStr += filename;
3481 parseStr += "' is not a valid text file.\n";
3482 free(buf);
3483 delete file;
3484 delete pCLUT;
3485 return NULL;
3486 }
3487
3488 if (data.GetSize()!=pCLUT->NumPoints()*pCLUT->GetOutputChannels()) {
3489 parseStr += "Error! - Number of entries in file '";
3490 parseStr += filename;
3491 parseStr += "'is not equal to the size of the CLUT Table.\n";
3492 parseStr += " a. Check values of GridGranularity/GridPoints, InputChannel, or OutputChannels.\n";
3493 parseStr += " b. File may not be a valid text file.\n";
3494 free(buf);
3495 delete file;
3496 delete pCLUT;
3497 return NULL;
3498 }
3499 icUInt16Number *src = data.GetBuf();
3500 icFloatNumber *dst = pCLUT->GetData(0);
3501
3503 for (i=0; i<data.GetSize(); i++) {
3504 *dst++ = (icFloatNumber)(*src++) / 65535.0f;
3505 }
3506 }
3507 else if (nType == icConvertFloat) {
3508 CIccFloatArray data;
3509
3510 if (!data.ParseTextArrayNum(buf, num, parseStr)) {
3511 parseStr += "File '";
3512 parseStr += filename;
3513 parseStr += "' is not a valid text file.\n";
3514 free(buf);
3515 delete file;
3516 delete pCLUT;
3517 return NULL;
3518 }
3519
3520 if (data.GetSize()!=pCLUT->NumPoints()*pCLUT->GetOutputChannels()) {
3521 parseStr += "Error! - Number of entries in file '";
3522 parseStr += filename;
3523 parseStr += "'is not equal to the size of the CLUT Table.\n";
3524 parseStr += " a. Check values of GridGranularity/GridPoints, InputChannel, or OutputChannels.\n";
3525 parseStr += " b. File may not be a valid text file.\n";
3526 free(buf);
3527 delete file;
3528 delete pCLUT;
3529 return NULL;
3530 }
3531 icFloatNumber *src = data.GetBuf();
3532 icFloatNumber *dst = pCLUT->GetData(0);
3533
3535 for (i=0; i<data.GetSize(); i++) {
3536 *dst++ = *src++;
3537 }
3538 }
3539 else {
3540 parseStr += "Error! Unknown text data type.\n";
3541 free(buf);
3542 delete file;
3543 delete pCLUT;
3544 return NULL;
3545 }
3546 free(buf);
3547 }
3548 else if (!strcmp(format, "binary")) {
3549 const char *order = icXmlAttrValue(table, "Endian");
3550 bool little_endian = !strcmp(order, "little");
3551
3552 if (nType==icConvertVariable) {
3553 //Allow encoding to be defined
3554 const char *encoding = icXmlAttrValue(table, "FileEncoding");
3555
3556 if (!strcmp(encoding, "int8"))
3557 nType = icConvert8Bit;
3558 else if (!strcmp(encoding, "int16"))
3559 nType = icConvert16Bit;
3560 else if (!strcmp(encoding, "float"))
3561 nType = icConvertFloat;
3562 else if (encoding[0]) {
3563 parseStr+= "Unknown encoding \"";
3564 parseStr+= encoding;
3565 parseStr+= "\" - using int16.\n";
3566 nType = icConvert16Bit;
3567 }
3568 else {
3569 parseStr+= "CLUT TableData Encoding type not specified.\n";
3570 }
3571 }
3572
3573 if (nType == icConvert8Bit){
3574 icUInt32Number num = file->GetLength();
3575 icUInt8Number value;
3576 // if number of entries in file is not equal to size of CLUT table, flag as error
3577 if (num!=pCLUT->NumPoints()*pCLUT->GetOutputChannels()) {
3578 parseStr += "Error! - Number of entries in file '";
3579 parseStr += filename;
3580 parseStr += "'is not equal to the size of the CLUT Table.\n";
3581 parseStr += " a. Check values of GridGranularity/GridPoints, InputChannel, or OutputChannels.\n";
3582 parseStr += " b. File may not be a valid binary file.\n";
3583 delete file;
3584 delete pCLUT;
3585 return NULL;
3586 }
3587 icFloatNumber *dst = pCLUT->GetData(0);
3589 for (i=0; i<num; i++) {
3590 if (!file->Read8(&value)) {
3591 perror("Read-File Error");
3592 parseStr += "'";
3593 parseStr += filename;
3594 parseStr += "' may not be a valid binary file.\n";
3595 delete file;
3596 delete pCLUT;
3597 return NULL;
3598 }
3599 *dst++ = (icFloatNumber)value / 255.0f;
3600 }
3601 }
3602 else if (nType == icConvert16Bit){
3603 icUInt32Number num = file->GetLength() / sizeof(icUInt16Number);
3604 icUInt16Number value;
3605 icUInt8Number *ptr = (icUInt8Number*)&value;
3606
3607 if (num<pCLUT->NumPoints()*pCLUT->GetOutputChannels()) {
3608 parseStr += "Error! - Number of entries in file '";
3609 parseStr += filename;
3610 parseStr += "'is not equal to the size of the CLUT Table.\n";
3611 parseStr += " a. Check values of GridGranularity/GridPoints, InputChannel, or OutputChannels.\n";
3612 parseStr += " b. File may not be a valid binary file.\n";
3613 delete file;
3614 delete pCLUT;
3615 return NULL;
3616 }
3617 icFloatNumber *dst = pCLUT->GetData(0);
3618
3620 for (i=0; i<num; i++) {
3621 if (!file->Read16(&value)) { //this assumes data is big endian
3622 perror("Read-File Error");
3623 parseStr += "'";
3624 parseStr += filename;
3625 parseStr += "' may not be a valid binary file.\n";
3626 delete file;
3627 delete pCLUT;
3628 return NULL;
3629 }
3630#ifdef ICC_BYTE_ORDER_LITTLE_ENDIAN
3631 if (little_endian) {
3632#else
3633 if (!little_endian) {
3634#endif
3635 icUInt8Number t = ptr[0];
3636 ptr[0] = ptr[1];
3637 ptr[1] = t;
3638 }
3639 *dst++ = (icFloatNumber)value / 65535.0f;
3640 }
3641 }
3642 else if (nType == icConvertFloat){
3643 icUInt32Number num = file->GetLength()/sizeof(icFloat32Number);
3644 icFloat32Number value;
3645 icUInt8Number *ptr = (icUInt8Number*)&value;
3646
3647 if (num<pCLUT->NumPoints()*pCLUT->GetOutputChannels()) {
3648 parseStr += "Error! - Number of entries in file '";
3649 parseStr += filename;
3650 parseStr += "'is not equal to the size of the CLUT Table.\n";
3651 parseStr += " a. Check values of GridGranularity/GridPoints, InputChannel, or OutputChannels.\n";
3652 parseStr += " b. File may not be a valid binary file.\n";
3653 delete file;
3654 delete pCLUT;
3655 return NULL;
3656 }
3657 icFloatNumber *dst = pCLUT->GetData(0);
3658
3660 for (i=0; i<num; i++) {
3661 if (!file->ReadFloat32Float(&value)) { //this assumes data is big endian
3662 perror("Read-File Error");
3663 parseStr += "'";
3664 parseStr += filename;
3665 parseStr += "' may not be a valid binary file.\n";
3666 delete file;
3667 delete pCLUT;
3668 return NULL;
3669 }
3670#ifdef ICC_BYTE_ORDER_LITTLE_ENDIAN
3671 if (little_endian) {
3672#else
3673 if (!little_endian) {
3674#endif
3675 icUInt8Number tmp;
3676 tmp = ptr[0]; ptr[0] = ptr[3]; ptr[3] = tmp;
3677 tmp = ptr[1]; ptr[1] = ptr[2]; ptr[2] = tmp;
3678 }
3679 *dst++ = value;
3680 }
3681 }
3682 else {
3683 parseStr += "Error! Unknown binary data type.\n";
3684 delete file;
3685 delete pCLUT;
3686 return NULL;
3687 }
3688
3689 }
3690 else {
3691 parseStr += "Error! Unknown Format type.\n";
3692 delete pCLUT;
3693 return NULL;
3694 }
3695
3696 delete file;
3697 }
3698 else { // no file
3699 if (nType == icConvert8Bit) {
3700 CIccUInt8Array data;
3701
3702 if (!data.ParseArray(table->children)) {
3703 parseStr += "Error! - unable to parse data in CLUT.\n";
3704 delete pCLUT;
3705 return NULL;
3706 }
3707
3708 if (data.GetSize()!=pCLUT->NumPoints()*pCLUT->GetOutputChannels()) {
3709 parseStr += "Error! - Number of entries is not equal to the size of the CLUT Table.\n";
3710 delete pCLUT;
3711 return NULL;
3712 }
3713 icUInt8Number *src = data.GetBuf();
3714 icFloatNumber *dst = pCLUT->GetData(0);
3715
3717 for (i=0; i<data.GetSize(); i++) {
3718 *dst++ = (icFloatNumber)(*src++) / 255.0f;
3719 }
3720 }
3721 else if (nType == icConvert16Bit || nType==icConvertVariable) {
3722 CIccUInt16Array data;
3723
3724 if (!data.ParseArray(table->children)) {
3725 parseStr += "Error! - unable to parse data in CLUT.\n";
3726 delete pCLUT;
3727 return NULL;
3728 }
3729
3730 if (data.GetSize()!=pCLUT->NumPoints()*pCLUT->GetOutputChannels()) {
3731 parseStr += "Error! - Number of entries is not equal to the size of the CLUT Table.\n";
3732 delete pCLUT;
3733 return NULL;
3734 }
3735 icUInt16Number *src = data.GetBuf();
3736 icFloatNumber *dst = pCLUT->GetData(0);
3737
3739 for (i=0; i<data.GetSize(); i++) {
3740 *dst++ = (icFloatNumber)(*src++) / 65535.0f;
3741 }
3742 }
3743 else if (nType == icConvertFloat){
3744 CIccFloatArray data;
3745
3746 if (!data.ParseArray(table->children)) {
3747 parseStr += "Error! - unable to parse data in CLUT.\n";
3748 delete pCLUT;
3749 return NULL;
3750 }
3751
3752 if (data.GetSize()!=pCLUT->NumPoints()*pCLUT->GetOutputChannels()) {
3753 parseStr += "Error! - Number of entries is not equal to the size of the CLUT Table.\n";
3754 delete pCLUT;
3755 return NULL;
3756 }
3757 icFloatNumber *src = data.GetBuf();
3758 icFloatNumber *dst = pCLUT->GetData(0);
3759
3761 for (i=0; i<data.GetSize(); i++) {
3762 *dst++ = *src++;
3763 }
3764 }
3765 else {
3766 parseStr += "Error! Unknown table data type.";
3767 delete pCLUT;
3768 return NULL;
3769 }
3770 }
3771 }
3772 else {
3773 parseStr += "Error! Cannot find table data.";
3774 delete pCLUT;
3775 return NULL;
3776 }
3777
3778 return pCLUT;
3779}
float icFloatNumber
All floating point operations/variables in IccProfLib use the icFloatNumber data type.
Definition IccDefs.h:100
CIccIO * IccOpenFileIO(const icChar *szFilename, const char *szAttr)
Definition IccIoXml.cpp:100
xmlAttr * icXmlFindAttr(xmlNode *pNode, const char *szAttrName)
xmlNode * icXmlFindNode(xmlNode *pNode, const char *szNodeName)
const char * icXmlAttrValue(xmlAttr *attr, const char *szDefault)
@ icConvert8Bit
@ icConvertFloat
@ icConvert16Bit
@ icConvertVariable
unsigned int icUInt32Number
Class: CIccCLUT.
Definition IccTagLut.h:326
icUInt16Number GetOutputChannels() const
Definition IccTagLut.h:357
icUInt32Number NumPoints() const
Definition IccTagLut.h:348
void SetPrecision(icUInt8Number nPrecision)
Definition IccTagLut.h:382
icFloatNumber * GetData(int index)
Definition IccTagLut.h:347
bool Init(icUInt8Number nGridPoints, icUInt32Number nMaxSize=0, icUInt8Number nBytesPerPoint=4)
Name: CIccCLUT::Init.
Type: Class.
Definition IccIO.h:97
icInt32Number ReadFloat32Float(void *pBufFloat, icInt32Number nNum=1)
Definition IccIO.cpp:302
virtual icInt32Number GetLength()
Definition IccIO.h:130
virtual icInt32Number Read8(void *pBuf8, icInt32Number nNum=1)
Definition IccIO.h:104
icInt32Number Read16(void *pBuf16, icInt32Number nNum=1)
Definition IccIO.cpp:114
static bool ParseArray(T *buf, icUInt32Number nBufSize, xmlNode *pNode)
bool ParseTextArrayNum(const char *szText, icUInt32Number num, std::string &parseStr)
icUInt32Number GetSize()
Definition IccUtilXml.h:166
unsigned char icUInt8Number
Number definitions.
float icFloat32Number
unsigned short icUInt16Number

References CIccXmlArrayType< T, Tsig >::GetBuf(), CIccCLUT::GetData(), CIccIO::GetLength(), CIccCLUT::GetOutputChannels(), CIccXmlArrayType< T, Tsig >::GetSize(), icConvert16Bit, icConvert8Bit, icConvertFloat, icConvertVariable, IccOpenFileIO(), icXmlAttrValue(), icXmlFindAttr(), icXmlFindNode(), CIccCLUT::Init(), CIccCLUT::NumPoints(), CIccXmlArrayType< T, Tsig >::ParseArray(), CIccXmlArrayType< T, Tsig >::ParseTextArrayNum(), CIccIO::Read16(), CIccIO::Read8(), CIccIO::ReadFloat32Float(), and CIccCLUT::SetPrecision().

Referenced by icMBBFromXml(), CIccMpeXmlCLUT::ParseXml(), CIccMpeXmlEmissionCLUT::ParseXml(), CIccMpeXmlExtCLUT::ParseXml(), and CIccMpeXmlReflectanceCLUT::ParseXml().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ icCurvesFromXml()

bool icCurvesFromXml ( LPIccCurve * pCurve,
icUInt32Number nChannels,
xmlNode * pNode,
icConvertType nType,
std::string & parseStr )

Definition at line 3228 of file IccTagXml.cpp.

3229{
3231 xmlNode *pCurveNode;
3232
3233 for (i=0, pCurveNode = pNode; i<nChannels && pCurveNode; pCurveNode=pCurveNode->next) {
3234 if (pCurveNode->type==XML_ELEMENT_NODE) {
3235 CIccCurve *pCurveTag = NULL;
3236 if (!icXmlStrCmp(pCurveNode->name, "Curve")) {
3237 pCurveTag = new CIccTagXmlCurve;
3238 }
3239 else if (!icXmlStrCmp(pCurveNode->name, "ParametricCurve")) {
3240 pCurveTag = new CIccTagXmlParametricCurve();
3241 }
3242
3243 if (pCurveTag) {
3244 IIccExtensionTag *pExt = pCurveTag->GetExtension();
3245
3246 if (pExt) {
3247 if (!strcmp(pExt->GetExtDerivedClassName(), "CIccCurveXml")) {
3248 CIccCurveXml *pCurveXml = (CIccCurveXml *)pExt;
3249
3250 if (pCurveXml->ParseXml(pCurveNode, nType, parseStr)) {
3251 pCurve[i] = pCurveTag;
3252 i++;
3253 }
3254 // added else statement
3255 else {
3256 char num[40];
3257 parseStr += "Unable to parse curve at Line";
3258 sprintf(num, "%d\n", pCurveNode->line);
3259 parseStr += num;
3260 return false;
3261 }
3262 }
3263 else if (!strcmp(pExt->GetExtClassName(), "CIccTagXml")) {
3264 CIccTagXml *pXmlTag = (CIccTagXml *)pExt;
3265
3266 if (pXmlTag->ParseXml(pCurveNode, parseStr)) {
3267 pCurve[i] = pCurveTag;
3268 i++;
3269 }
3270 // added else statement
3271 else {
3272 char num[40];
3273 parseStr += "Unable to parse curve tag at Line";
3274 sprintf(num, "%d\n", pCurveNode->line);
3275 parseStr += num;
3276 return false;
3277 }
3278 }
3279 }
3280 }
3281 }
3282 }
3283 if (!i != nChannels) {
3284 parseStr += "Channel number mismatch!\n";
3285 }
3286 return i==nChannels;
3287}
#define icXmlStrCmp(x, y)
Definition IccUtilXml.h:134
Class: CIccCurve.
Definition IccTagLut.h:91
virtual bool ParseXml(xmlNode *pNode, icConvertType nType, std::string &parseStr)=0
virtual IIccExtensionTag * GetExtension()
virtual bool ParseXml(xmlNode *pNode, std::string &parseStr)=0
virtual const char * GetExtDerivedClassName() const =0
virtual const char * GetExtClassName() const =0

References IIccExtensionTag::GetExtClassName(), IIccExtensionTag::GetExtDerivedClassName(), CIccTag::GetExtension(), icXmlStrCmp, CIccCurveXml::ParseXml(), and CIccTagXml::ParseXml().

Referenced by icMBBFromXml().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ icCurvesToXml()

bool icCurvesToXml ( std::string & xml,
const char * szName,
CIccCurve ** pCurves,
int numCurve,
icConvertType nType,
std::string blanks )

Definition at line 3038 of file IccTagXml.cpp.

3039{
3040 if (pCurves) {
3041 int i;
3042
3043 xml += blanks + "<" + szName + ">\n";
3044 for (i=0; i<numCurve; i++) {
3045 IIccExtensionTag *pTag = pCurves[i]->GetExtension();
3046 if (!pTag || strcmp(pTag->GetExtDerivedClassName(), "CIccCurveXml"))
3047 return false;
3048
3049 if (!((CIccCurveXml *)pTag)->ToXml(xml, nType, blanks + " "))
3050 return false;
3051 }
3052 xml += blanks + "</" + szName + ">\n";
3053 }
3054 return true;
3055}
const icChar * szName

References IIccExtensionTag::GetExtDerivedClassName(), CIccTag::GetExtension(), and szName.

Referenced by icMBBToXml().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ icMatrixFromXml()

bool icMatrixFromXml ( CIccMatrix * pMatrix,
xmlNode * pNode )

Definition at line 3289 of file IccTagXml.cpp.

3290{
3291 memset(pMatrix->m_e, 0, sizeof(pMatrix->m_e));
3292 pMatrix->m_bUseConstants = false;
3293
3294 char attrName[15];
3295 int i;
3296
3297 for (i=0; i<9; i++) {
3298 sprintf(attrName, "e%d", i+1);
3299 xmlAttr *attr = icXmlFindAttr(pNode, attrName);
3300 if (attr) {
3301 pMatrix->m_e[i] = (icFloatNumber)atof(icXmlAttrValue(attr));
3302 }
3303 }
3304 for (i=9; i<12; i++) {
3305 sprintf(attrName, "e%d", i+1);
3306 xmlAttr *attr = icXmlFindAttr(pNode, attrName);
3307 if (attr) {
3308 pMatrix->m_e[i] = (icFloatNumber)atof(icXmlAttrValue(attr));
3309 pMatrix->m_bUseConstants = true;
3310 }
3311 }
3312 return true;
3313}
icFloatNumber m_e[12]
Definition IccTagLut.h:269
bool m_bUseConstants
Definition IccTagLut.h:270

References icXmlAttrValue(), icXmlFindAttr(), CIccMatrix::m_bUseConstants, and CIccMatrix::m_e.

Referenced by icMBBFromXml().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ icMatrixToXml()

bool icMatrixToXml ( std::string & xml,
CIccMatrix * pMatrix,
std::string blanks )

Definition at line 3103 of file IccTagXml.cpp.

3104{
3105 char buf[128];
3106 xml += blanks + "<Matrix\n";
3107
3108 sprintf(buf, " e1=\"" icXmlFloatFmt "\" e2=\"" icXmlFloatFmt "\" e3=\"" icXmlFloatFmt "\"\n", pMatrix->m_e[0], pMatrix->m_e[1], pMatrix->m_e[2]);
3109 xml += blanks + buf;
3110
3111 sprintf(buf, " e4=\"" icXmlFloatFmt "\" e5=\"" icXmlFloatFmt "\" e6=\"" icXmlFloatFmt "\"\n", pMatrix->m_e[3], pMatrix->m_e[4], pMatrix->m_e[5]);
3112 xml += blanks + buf;
3113
3114 sprintf(buf, " e7=\"" icXmlFloatFmt "\" e8=\"" icXmlFloatFmt "\" e9=\"" icXmlFloatFmt "\"", pMatrix->m_e[6], pMatrix->m_e[7], pMatrix->m_e[8]);
3115 xml += blanks + buf;
3116
3117 if (pMatrix->m_bUseConstants) {
3118 xml += "\n";
3119 sprintf(buf, " e10=\"" icXmlFloatFmt "\" e11=\"" icXmlFloatFmt "\" e12=\"" icXmlFloatFmt "\"", pMatrix->m_e[9], pMatrix->m_e[10], pMatrix->m_e[11]);
3120 xml += blanks + buf;
3121 }
3122 xml += "/>\n";
3123 return true;
3124}
#define icXmlFloatFmt

References icXmlFloatFmt, CIccMatrix::m_bUseConstants, and CIccMatrix::m_e.

Referenced by icMBBToXml().

+ Here is the caller graph for this function:

◆ icMBBFromXml()

bool icMBBFromXml ( CIccMBB * pMBB,
xmlNode * pNode,
icConvertType nType,
std::string & parseStr )

Definition at line 3781 of file IccTagXml.cpp.

3782{
3783 xmlNode *pChannels = icXmlFindNode(pNode, "Channels");
3784
3785 if (!pChannels)
3786 return false;
3787
3788 xmlAttr *in = icXmlFindAttr(pChannels, "InputChannels");
3789 xmlAttr *out = icXmlFindAttr(pChannels, "OutputChannels");
3790
3791 if (!in || !out)
3792 return false;
3793
3794 int nIn = atoi(icXmlAttrValue(in));
3795 int nOut = atoi(icXmlAttrValue(out));
3796
3797 pMBB->Init(nIn, nOut);
3798
3799 for (; pNode; pNode = pNode->next) {
3800 if (pNode->type == XML_ELEMENT_NODE) {
3801 if (!icXmlStrCmp(pNode->name, "ACurves") && !pMBB->GetCurvesA()) {
3802 LPIccCurve *pCurves = pMBB->NewCurvesA();
3803 if (!icCurvesFromXml(pCurves, !pMBB->IsInputB() ? nIn : nOut, pNode->children, nType, parseStr)) {
3804 parseStr += "Error! - Failed to parse ACurves.\n";
3805 return false;
3806 }
3807 }
3808 else if (!icXmlStrCmp(pNode->name, "BCurves") && !pMBB->GetCurvesB()) {
3809 LPIccCurve *pCurves = pMBB->NewCurvesB();
3810 if (!icCurvesFromXml(pCurves, pMBB->IsInputB() ? nIn : nOut, pNode->children, nType, parseStr)) {
3811 parseStr += "Error! - Failed to parse BCurves.\n";
3812 return false;
3813 }
3814 }
3815 else if (!icXmlStrCmp(pNode->name, "MCurves") && !pMBB->GetCurvesM()) {
3816 LPIccCurve *pCurves = pMBB->NewCurvesM();
3817 if (!icCurvesFromXml(pCurves, !pMBB->IsInputMatrix() ? nIn : nOut, pNode->children, nType, parseStr)) {
3818 parseStr += "Error! - Failed to parse MCurves.\n";
3819 return false;
3820 }
3821 }
3822 else if (!icXmlStrCmp(pNode->name, "Matrix") && !pMBB->GetMatrix()) {
3823 CIccMatrix *pMatrix = pMBB->NewMatrix();
3824 if (!icMatrixFromXml(pMatrix, pNode)) {
3825 parseStr += "Error! - Failed to parse Matrix.\n";
3826 return false;
3827 }
3828 }
3829 else if (!icXmlStrCmp(pNode->name, "CLUT") && !pMBB->GetCLUT()) {
3830 CIccCLUT *pCLUT = icCLutFromXml(pNode, nIn, nOut, nType, parseStr);
3831 if (pCLUT) {
3832 if (!pMBB->SetCLUT(pCLUT)) {
3833 parseStr += "Error! - Failed to set CLUT to LUT.\n";
3834 return false;
3835 }
3836 }
3837 else {
3838 parseStr += "Error! - Failed to parse CLUT.\n";
3839 return false;
3840 }
3841 }
3842 }
3843 }
3844
3845 return true;
3846}
CIccCLUT * icCLutFromXml(xmlNode *pNode, int nIn, int nOut, icConvertType nType, std::string &parseStr)
bool icCurvesFromXml(LPIccCurve *pCurve, icUInt32Number nChannels, xmlNode *pNode, icConvertType nType, std::string &parseStr)
bool icMatrixFromXml(CIccMatrix *pMatrix, xmlNode *pNode)
bool IsInputB()
Definition IccTagLut.h:445
LPIccCurve * GetCurvesM() const
Definition IccTagLut.h:472
LPIccCurve * NewCurvesB()
Name: CIccMBB::NewCurvesB.
CIccMatrix * NewMatrix()
Name: CIccMBB::NewMatrix.
virtual bool IsInputMatrix()
Definition IccTagLut.h:442
CIccCLUT * SetCLUT(CIccCLUT *clut)
Name: CIccMBB::SetCLUT.
LPIccCurve * GetCurvesB() const
Definition IccTagLut.h:471
LPIccCurve * NewCurvesM()
Name: CIccMBB::NewCurvesM.
LPIccCurve * NewCurvesA()
Name: CIccMBB::NewCurvesA.
CIccCLUT * GetCLUT() const
Definition IccTagLut.h:469
CIccMatrix * GetMatrix() const
Definition IccTagLut.h:468
LPIccCurve * GetCurvesA() const
Definition IccTagLut.h:470
void Init(icUInt8Number nInputChannels, icUInt8Number nOutputChannels)
Name: CIccMBB::Init.
Class: CIccMatrix.
Definition IccTagLut.h:260

References CIccMBB::GetCLUT(), CIccMBB::GetCurvesA(), CIccMBB::GetCurvesB(), CIccMBB::GetCurvesM(), CIccMBB::GetMatrix(), icCLutFromXml(), icCurvesFromXml(), icMatrixFromXml(), icXmlAttrValue(), icXmlFindAttr(), icXmlFindNode(), icXmlStrCmp, CIccMBB::Init(), CIccMBB::IsInputB(), CIccMBB::IsInputMatrix(), CIccMBB::NewCurvesA(), CIccMBB::NewCurvesB(), CIccMBB::NewCurvesM(), CIccMBB::NewMatrix(), and CIccMBB::SetCLUT().

Referenced by CIccTagXmlLut16::ParseXml(), CIccTagXmlLut8::ParseXml(), CIccTagXmlLutAtoB::ParseXml(), and CIccTagXmlLutBtoA::ParseXml().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ icMBBToXml()

bool icMBBToXml ( std::string & xml,
CIccMBB * pMBB,
icConvertType nType,
std::string blanks = "",
bool bSaveGridPoints = false )

Definition at line 3127 of file IccTagXml.cpp.

3128{
3129 //blanks += " ";
3130 char buf[256];
3131
3132 sprintf(buf, "<Channels InputChannels=\"%d\" OutputChannels=\"%d\"/>\n", pMBB->InputChannels(), pMBB->OutputChannels());
3133 xml += blanks + buf;
3134
3135 if (pMBB->IsInputMatrix()) {
3136 if (pMBB->SwapMBCurves()) {
3137 if (pMBB->GetMatrix()) {
3138 // added if-statement
3139 if (!icMatrixToXml(xml, pMBB->GetMatrix(), blanks)) {
3140 return false;
3141 }
3142 }
3143
3144 if (pMBB->GetCurvesB()) {
3145 // added if-statement
3146 if (!icCurvesToXml(xml, "BCurves", pMBB->GetCurvesM(), pMBB->InputChannels(), nType, blanks)) {
3147 return false;
3148 }
3149 }
3150 }
3151 else {
3152 if (pMBB->GetCurvesB()) {
3153 // added if-statement
3154 if (!icCurvesToXml(xml, "BCurves", pMBB->GetCurvesB(), pMBB->InputChannels(), nType, blanks)) {
3155 return false;
3156 }
3157 }
3158
3159 if (pMBB->GetMatrix()) {
3160 // added if-statement
3161 if (!icMatrixToXml(xml, pMBB->GetMatrix(), blanks)) {
3162 return false;
3163 }
3164 }
3165
3166 if (pMBB->GetCurvesM()) {
3167 // added if-statement
3168 if (!icCurvesToXml(xml, "MCurves", pMBB->GetCurvesM(), 3, nType, blanks)){
3169 return false;
3170 }
3171 }
3172 }
3173
3174 if (pMBB->GetCLUT()) {
3175 // added if-statement
3176 if (!icCLUTToXml(xml, pMBB->GetCLUT(), nType, blanks, bSaveGridPoints)){
3177 return false;
3178 }
3179 }
3180
3181 if (pMBB->GetCurvesA()) {
3182 // added if-statement
3183 if (!icCurvesToXml(xml, "ACurves", pMBB->GetCurvesA(), pMBB->OutputChannels(), nType, blanks)){
3184 return false;
3185 }
3186 }
3187 }
3188 else {
3189 if (pMBB->GetCurvesA()) {
3190 // added if-statement
3191 if (!icCurvesToXml(xml, "ACurves", pMBB->GetCurvesA(), pMBB->InputChannels(), nType, blanks)){
3192 return false;
3193 }
3194 }
3195
3196 if (pMBB->GetCLUT()) {
3197 // added if-statement
3198 if (!icCLUTToXml(xml, pMBB->GetCLUT(), nType, blanks, bSaveGridPoints)){
3199 return false;
3200 }
3201 }
3202
3203 if (pMBB->GetCurvesM()) {
3204 // added if-statement
3205 if (!icCurvesToXml(xml, "MCurves", pMBB->GetCurvesM(), 3, nType, blanks)){
3206 return false;
3207 }
3208 }
3209
3210 if (pMBB->GetMatrix()) {
3211 // added if-statement
3212 if (!icMatrixToXml(xml, pMBB->GetMatrix(), blanks)) {
3213 return false;
3214 }
3215 }
3216
3217 if (pMBB->GetCurvesB()) {
3218 // added if-statement
3219 if (!icCurvesToXml(xml, "BCurves", pMBB->GetCurvesB(), pMBB->OutputChannels(), nType, blanks)){
3220 return false;
3221 }
3222 }
3223 }
3224 return true;
3225}
bool icCurvesToXml(std::string &xml, const char *szName, CIccCurve **pCurves, int numCurve, icConvertType nType, std::string blanks)
bool icMatrixToXml(std::string &xml, CIccMatrix *pMatrix, std::string blanks)
bool icCLUTToXml(std::string &xml, CIccCLUT *pCLUT, icConvertType nType, std::string blanks, bool bSaveGridPoints, const char *szExtraAttrs, const char *szName)
icUInt8Number InputChannels() const
Definition IccTagLut.h:451
icUInt8Number OutputChannels() const
Definition IccTagLut.h:452
bool SwapMBCurves()
Definition IccTagLut.h:446

References CIccMBB::GetCLUT(), CIccMBB::GetCurvesA(), CIccMBB::GetCurvesB(), CIccMBB::GetCurvesM(), CIccMBB::GetMatrix(), icCLUTToXml(), icCurvesToXml(), icMatrixToXml(), CIccMBB::InputChannels(), CIccMBB::IsInputMatrix(), CIccMBB::OutputChannels(), and CIccMBB::SwapMBCurves().

Referenced by CIccTagXmlLut16::ToXml(), CIccTagXmlLut8::ToXml(), CIccTagXmlLutAtoB::ToXml(), and CIccTagXmlLutBtoA::ToXml().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ icProfDescToXml()

bool icProfDescToXml ( std::string & xml,
CIccProfileDescStruct & p,
std::string blanks = "" )

Definition at line 2181 of file IccTagXml.cpp.

2182{
2183 char fix[256];
2184 char buf[256];
2185 char data[256];
2186
2187 sprintf(buf, "<ProfileDesc>\n");
2188 xml += blanks + buf;
2189
2190 sprintf(buf, "<DeviceManufacturerSignature>%s</DeviceManufacturerSignature>\n", icFixXml(fix, icGetSigStr(data, p.m_deviceMfg)));
2191 xml += blanks + blanks + buf;
2192
2193 sprintf(buf, "<DeviceModelSignature>%s</DeviceModelSignature>\n", icFixXml(fix, icGetSigStr(data, p.m_deviceModel)));
2194 xml += blanks + blanks + buf;
2195
2196 std::string szAttributes = icGetDeviceAttrName(p.m_attributes);
2197 //sprintf(buf, "<DeviceAttributes>\"%016lX\" technology=\"%s\">\n", p.m_attributes, icFixXml(fix, icGetSigStr(data, p.m_technology)));
2198 //xml += buf;
2199 xml += blanks + blanks + icGetDeviceAttrName(p.m_attributes);
2200
2201 sprintf(buf, "<Technology>%s</Technology>\n", icFixXml(fix, icGetSigStr(data, p.m_technology)));
2202 xml += blanks + blanks + buf;
2203
2204 CIccTag *pTag = p.m_deviceMfgDesc.GetTag();
2205 CIccTagXml *pExt;
2206
2207 if (pTag) {
2208
2209 pExt = (CIccTagXml*)(pTag->GetExtension());
2210
2211 if (!pExt || !pExt->GetExtClassName() || strcmp(pExt->GetExtClassName(), "CIccTagXml"))
2212 return false;
2213
2214 xml += blanks + blanks + "<DeviceManufacturer>\n";
2215
2216 const icChar* tagSig = icGetTagSigTypeName(pTag->GetType());
2217 sprintf(buf, "<%s>\n", tagSig);
2218 xml += blanks + blanks + blanks + buf;
2219
2220 if (!pExt->ToXml(xml, blanks + " "))
2221 return false;
2222
2223 sprintf(buf, "</%s>\n", tagSig);
2224 xml += blanks + blanks + blanks + buf;
2225
2226 xml += blanks + blanks +"</DeviceManufacturer>\n";
2227 }
2228
2229 pTag = p.m_deviceModelDesc.GetTag();
2230
2231 if (pTag) {
2232 pExt = (CIccTagXml*)(pTag->GetExtension());
2233
2234 if (!pExt || !pExt->GetExtClassName() || strcmp(pExt->GetExtClassName(), "CIccTagXml"))
2235 return false;
2236
2237 xml += blanks + blanks + "<DeviceModel>\n";
2238
2239 const icChar* tagSig = icGetTagSigTypeName(pTag->GetType());
2240 sprintf(buf, "<%s>\n", tagSig);
2241 xml += blanks + blanks + blanks + buf;
2242
2243 if (!pExt->ToXml(xml, blanks + " "))
2244 return false;
2245
2246 sprintf(buf, "</%s>\n", tagSig);
2247 xml += blanks + blanks + blanks + buf;
2248
2249 xml += blanks + " </DeviceModel>\n";
2250 }
2251
2252 xml += blanks + "</ProfileDesc>\n";
2253
2254 return true;
2255}
char icChar
Definition IccDefs.h:109
const icChar * icGetSigStr(icChar *pBuf, icUInt32Number nSig)
Definition IccUtil.cpp:1056
const std::string icGetDeviceAttrName(icUInt64Number devAttr)
const icChar * icGetTagSigTypeName(icTagTypeSignature tagTypeSig)
const char * icFixXml(std::string &buf, const char *szStr)
CIccProfileDescText m_deviceMfgDesc
icSignature m_deviceModel
icTechnologySignature m_technology
CIccProfileDescText m_deviceModelDesc
icUInt64Number m_attributes
CIccTag * GetTag() const
Class: CIccTag.
virtual icTagTypeSignature GetType() const
Function: GetType()
virtual const char * GetExtClassName() const
Definition IccTagXml.h:79
virtual bool ToXml(std::string &xml, std::string blanks="")=0

References CIccTagXml::GetExtClassName(), CIccTag::GetExtension(), CIccProfileDescText::GetTag(), CIccTag::GetType(), icFixXml(), icGetDeviceAttrName(), icGetSigStr(), icGetTagSigTypeName(), CIccProfileDescStruct::m_attributes, CIccProfileDescStruct::m_deviceMfg, CIccProfileDescStruct::m_deviceMfgDesc, CIccProfileDescStruct::m_deviceModel, CIccProfileDescStruct::m_deviceModelDesc, CIccProfileDescStruct::m_technology, and CIccTagXml::ToXml().

Referenced by CIccTagXmlProfileSeqDesc::ToXml().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ icXmlDumpTextData()

static bool icXmlDumpTextData ( std::string & xml,
std::string blanks,
const char * szText,
bool bConvert = true )
static

Definition at line 124 of file IccTagXml.cpp.

125{
126 if (strstr(szText, "]]>")) {
127 xml += blanks + "<HexTextData>";
128 icXmlDumpHexData(xml, blanks+" ", (void*)szText, (icUInt32Number)strlen(szText));
129 xml += blanks + "</HexTextData>\n";
130 }
131 else {
132 std::string buf;
133
134 xml += blanks + "<TextData>";
135 xml += "<![CDATA[";
136 if (bConvert)
137 xml += icAnsiToUtf8(buf, szText);
138 else
139 xml += szText;
140 xml += "]]></TextData>\n";
141 }
142
143 return true;
144}
icUInt32Number icXmlDumpHexData(std::string &xml, std::string blanks, void *pBuf, icUInt32Number nBufSize)
const char * icAnsiToUtf8(std::string &buf, const char *szSrc)

References icAnsiToUtf8(), and icXmlDumpHexData().

Referenced by CIccTagXmlText::ToXml(), CIccTagXmlTextDescription::ToXml(), CIccTagXmlUtf16Text::ToXml(), and CIccTagXmlUtf8Text::ToXml().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ icXmlParseProfDesc()

bool icXmlParseProfDesc ( xmlNode * pNode,
CIccProfileDescStruct & p,
std::string & parseStr )

Definition at line 2257 of file IccTagXml.cpp.

2258{
2259 if (pNode->type==XML_ELEMENT_NODE && !icXmlStrCmp(pNode->name, "ProfileDesc")) {
2260 xmlNode *pDescNode;
2261
2262 for (pDescNode = pNode->children; pDescNode; pDescNode=pDescNode->next) {
2263 if (pDescNode->type == XML_ELEMENT_NODE) {
2264 if (!icXmlStrCmp(pDescNode->name, "DeviceManufacturerSignature")){
2265 p.m_deviceMfg = icXmlStrToSig(pDescNode->children ? (const icChar*)pDescNode->children->content: "");
2266 }
2267 else if (!icXmlStrCmp(pDescNode->name, "DeviceModelSignature")){
2268 p.m_deviceModel = icXmlStrToSig(pDescNode->children ? (const icChar*)pDescNode->children->content : "");
2269 }
2270 else if (!icXmlStrCmp(pDescNode->name, "DeviceAttributes")){
2271 p.m_attributes = icGetDeviceAttrValue(pDescNode);
2272 }
2273 else if (!icXmlStrCmp(pDescNode->name, "Technology")){
2274 p.m_technology = (icTechnologySignature)icXmlStrToSig(pDescNode->children ? (const icChar*)pDescNode->children->content : "");
2275 }
2276 else if (!icXmlStrCmp(pDescNode->name, "DeviceManufacturer")) {
2277 xmlNode *pDevManNode = icXmlFindNode(pDescNode->children, "multiLocalizedUnicodeType");
2278
2279 if (!pDevManNode){
2280 pDevManNode = icXmlFindNode(pDescNode->children, "textDescriptionType");
2281 }
2282
2283 if (pDevManNode){
2284 icTagTypeSignature tagSig = icGetTypeNameTagSig ((icChar*) pDevManNode->name);
2285
2286 if (!p.m_deviceMfgDesc.SetType(tagSig)){
2287 return false;
2288 }
2289 CIccTag *pTag = p.m_deviceMfgDesc.GetTag();
2290
2291 if (!pTag)
2292 return false;
2293
2294 CIccTagXml *pExt = (CIccTagXml*)(pTag->GetExtension());
2295
2296 if (!pExt || !pExt->GetExtClassName() || strcmp(pExt->GetExtClassName(), "CIccTagXml"))
2297 return false;
2298
2299 pExt->ParseXml(pDevManNode->children, parseStr);
2300 }
2301 }
2302 else if (!icXmlStrCmp(pDescNode->name, "DeviceModel")) {
2303 xmlNode *pDevModNode = icXmlFindNode(pDescNode->children, "multiLocalizedUnicodeType");
2304
2305 if (!pDevModNode){
2306 pDevModNode = icXmlFindNode(pDescNode->children, "textDescriptionType");
2307 }
2308
2309 if (pDevModNode){
2310 icTagTypeSignature tagSig = icGetTypeNameTagSig ((icChar*) pDevModNode->name);
2311
2312 if (!p.m_deviceModelDesc.SetType(tagSig)) {
2313 return false;
2314 }
2315 CIccTag *pTag = p.m_deviceModelDesc.GetTag();
2316
2317 if (!pTag)
2318 return false;
2319
2320 CIccTagXml *pExt = (CIccTagXml*)(pTag->GetExtension());
2321
2322 if (!pExt || !pExt->GetExtClassName() || strcmp(pExt->GetExtClassName(), "CIccTagXml"))
2323 return false;
2324
2325 pExt->ParseXml(pDevModNode->children, parseStr);
2326 }
2327 }
2328 }
2329 }
2330 }
2331 else
2332 return false;
2333
2335 return false;
2336
2337 return true;
2338}
icTagTypeSignature icGetTypeNameTagSig(const icChar *szTagType)
icUInt64Number icGetDeviceAttrValue(xmlNode *pNode)
icSignature icXmlStrToSig(const char *szStr)
icTagTypeSignature
bool SetType(icTagTypeSignature nType)
Name: CIccProfileDescText::SetType.
icTechnologySignature
technology signature descriptions

References CIccTagXml::GetExtClassName(), CIccTag::GetExtension(), CIccProfileDescText::GetTag(), icGetDeviceAttrValue(), icGetTypeNameTagSig(), icXmlFindNode(), icXmlStrCmp, icXmlStrToSig(), CIccProfileDescStruct::m_attributes, CIccProfileDescStruct::m_deviceMfg, CIccProfileDescStruct::m_deviceMfgDesc, CIccProfileDescStruct::m_deviceModel, CIccProfileDescStruct::m_deviceModelDesc, CIccProfileDescStruct::m_technology, CIccTagXml::ParseXml(), and CIccProfileDescText::SetType().

Referenced by CIccTagXmlProfileSeqDesc::ParseXml().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ icXmlParseTextString()

static std::string icXmlParseTextString ( xmlNode * pNode,
std::string & parseStr,
bool bConvert = true )
static

Definition at line 180 of file IccTagXml.cpp.

181{
182 std::string str;
183
184 while (pNode) {
185 if (pNode->type==XML_ELEMENT_NODE) {
186 if (!icXmlStrCmp(pNode->name, "HexTextData") && pNode->children && pNode->children->content) {
187 CIccUInt8Array buf;
188 if (!buf.SetSize(icXmlGetHexDataSize((const icChar*)pNode->children->content) ||
189 icXmlGetHexData(buf.GetBuf(), (const icChar*)pNode->children->content, buf.GetSize())!=buf.GetSize()))
190 return str;
191
192 str += (char*)buf.GetBuf();
193 }
194 else if (!icXmlStrCmp(pNode->name, "TextData") ) {
195 std::string buf;
196 const icChar *filename = icXmlAttrValue(pNode, "File");
197
198 // file exists
199 if (filename[0]) {
200 CIccIO *file = IccOpenFileIO(filename, "rb");
201 if (!file){
202 parseStr += "Error! - File '";
203 parseStr += filename;
204 parseStr +="' not found.\n";
205 delete file;
206 return str;
207 }
208
209 icUInt32Number fileLength = file->GetLength();
210 char *ansiStr = (char *)malloc(fileLength+1);
211
212 if (!ansiStr) {
213 perror("Memory Error");
214 parseStr += "'";
215 parseStr += filename;
216 parseStr += "' may not be a valid text file.\n";
217 delete file;
218 return str;
219 }
220 // read the contents of the file
221 if (file->ReadLine(ansiStr, fileLength)!=fileLength) {
222 parseStr += "Error while reading file '";
223 parseStr += filename;
224 parseStr += "'. Size read is not equal to file length. File may not be a valid text file.\n";
225 free(ansiStr);
226 delete file;
227 return str;
228 }
229 // convert utf8 (xml format) to ansi (icc format)
230 if (bConvert)
231 icUtf8ToAnsi(buf, ansiStr);
232 else
233 buf = ansiStr;
234 free(ansiStr);
235 delete file;
236 }
237 // file does not exist
238 else if (pNode->children && pNode->children->content){
239 if (bConvert)
240 icUtf8ToAnsi(buf, (const icChar*)pNode->children->content);
241 else
242 buf = (const icChar*)pNode->children->content;
243 }
244 str += buf;
245 }
246 }
247 pNode = pNode->next;
248 }
249
250 return str;
251}
const char * icUtf8ToAnsi(std::string &buf, const char *szSrc)
icUInt32Number icXmlGetHexDataSize(const char *szText)
icUInt32Number icXmlGetHexData(void *pBuf, const char *szText, icUInt32Number nBufSize)
icInt32Number ReadLine(void *pBuf8, icInt32Number nNum=256)
Definition IccIO.cpp:93
bool SetSize(icUInt32Number nSize)

References CIccXmlArrayType< T, Tsig >::GetBuf(), CIccIO::GetLength(), CIccXmlArrayType< T, Tsig >::GetSize(), IccOpenFileIO(), icUtf8ToAnsi(), icXmlAttrValue(), icXmlGetHexData(), icXmlGetHexDataSize(), icXmlStrCmp, CIccIO::ReadLine(), and CIccXmlArrayType< T, Tsig >::SetSize().

Referenced by CIccTagXmlText::ParseXml(), CIccTagXmlTextDescription::ParseXml(), CIccTagXmlUtf16Text::ParseXml(), CIccTagXmlUtf8Text::ParseXml(), CIccTagXmlZipUtf8Text::ParseXml(), and CIccTagXmlZipXml::ParseXml().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: