IccMAX 2.1.27
Color Profile Tools
Loading...
Searching...
No Matches
IccTagXml.cpp File Reference
#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: © see ICC Software License

Definition in file IccTagXml.cpp.

Typedef Documentation

◆ IccOffsetTagSigMap

Function Documentation

◆ icCLutFromXml()

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

References CIccCLUT::CIccCLUT(), CIccXmlArrayType< T, Tsig >::GetBuf(), CIccCLUT::GetData(), CIccIO::GetLength(), CIccCLUT::GetOutputChannels(), CIccXmlArrayType< T, Tsig >::GetSize(), icConvert16Bit, icConvert8Bit, icConvertFloat, icConvertVariable, IccOpenFileIO(), icXmlAttrValue(), icXmlAttrValue(), icXmlFindAttr(), icXmlFindNode(), CIccCLUT::Init(), 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(), CIccMpeXmlExtCLUT::ParseXml(), CIccMpeXmlEmissionCLUT::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 
)
3233{
3235 xmlNode *pCurveNode;
3236
3237 for (i=0, pCurveNode = pNode; i<nChannels && pCurveNode; pCurveNode=pCurveNode->next) {
3238 if (pCurveNode->type==XML_ELEMENT_NODE) {
3239 CIccCurve *pCurveTag = NULL;
3240 if (!icXmlStrCmp(pCurveNode->name, "Curve")) {
3241 pCurveTag = new CIccTagXmlCurve;
3242 }
3243 else if (!icXmlStrCmp(pCurveNode->name, "ParametricCurve")) {
3244 pCurveTag = new CIccTagXmlParametricCurve();
3245 }
3246
3247 if (pCurveTag) {
3248 IIccExtensionTag *pExt = pCurveTag->GetExtension();
3249
3250 if (pExt) {
3251 if (!strcmp(pExt->GetExtDerivedClassName(), "CIccCurveXml")) {
3252 CIccCurveXml *pCurveXml = (CIccCurveXml *)pExt;
3253
3254 if (pCurveXml->ParseXml(pCurveNode, nType, parseStr)) {
3255 pCurve[i] = pCurveTag;
3256 i++;
3257 }
3258 // added else statement
3259 else {
3260 char num[40];
3261 parseStr += "Unable to parse curve at Line";
3262 sprintf(num, "%d\n", pCurveNode->line);
3263 parseStr += num;
3264
3265 delete pCurveTag;
3266 return false;
3267 }
3268 }
3269 else if (!strcmp(pExt->GetExtClassName(), "CIccTagXml")) {
3270 CIccTagXml *pXmlTag = (CIccTagXml *)pExt;
3271
3272 if (pXmlTag->ParseXml(pCurveNode, parseStr)) {
3273 pCurve[i] = pCurveTag;
3274 i++;
3275 }
3276 // added else statement
3277 else {
3278 char num[40];
3279 parseStr += "Unable to parse curve tag at Line";
3280 sprintf(num, "%d\n", pCurveNode->line);
3281 parseStr += num;
3282
3283 delete pCurveTag;
3284 return false;
3285 }
3286 }
3287 else {
3288 delete pCurveTag;
3289 return false;
3290 }
3291 }
3292 }
3293 }
3294 }
3295 if (!i != nChannels) {
3296 parseStr += "Channel number mismatch!\n";
3297 }
3298 return i==nChannels;
3299}
#define icXmlStrCmp(x, y)
Definition IccUtilXml.h:134
Definition IccTagBasic.h:90
virtual const char * GetExtDerivedClassName() const =0
virtual const char * GetExtClassName() const =0
virtual IIccExtensionTag * GetExtension()
Definition IccTagBasic.h:143
Definition IccTagLut.h:91
Definition IccTagXml.h:75
virtual bool ParseXml(xmlNode *pNode, std::string &parseStr)=0
Definition IccTagXml.h:488
virtual bool ParseXml(xmlNode *pNode, icConvertType nType, std::string &parseStr)=0
Definition IccTagXml.h:499
Definition IccTagXml.h:514

References IIccExtensionTag::GetExtClassName(), IIccExtensionTag::GetExtDerivedClassName(), CIccTag::GetExtension(), 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 
)
3043{
3044 if (pCurves) {
3045 int i;
3046
3047 xml += blanks + "<" + szName + ">\n";
3048 for (i=0; i<numCurve; i++) {
3049 IIccExtensionTag *pTag = pCurves[i]->GetExtension();
3050 if (!pTag || strcmp(pTag->GetExtDerivedClassName(), "CIccCurveXml"))
3051 return false;
3052
3053 if (!((CIccCurveXml *)pTag)->ToXml(xml, nType, blanks + " "))
3054 return false;
3055 }
3056 xml += blanks + "</" + szName + ">\n";
3057 }
3058 return true;
3059}

References IIccExtensionTag::GetExtDerivedClassName(), CIccTag::GetExtension(), and CIccCurveXml::ToXml().

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 
)
3302{
3303 memset(pMatrix->m_e, 0, sizeof(pMatrix->m_e));
3304 pMatrix->m_bUseConstants = false;
3305
3306 char attrName[15];
3307 int i;
3308
3309 for (i=0; i<9; i++) {
3310 sprintf(attrName, "e%d", i+1);
3311 xmlAttr *attr = icXmlFindAttr(pNode, attrName);
3312 if (attr) {
3313 pMatrix->m_e[i] = (icFloatNumber)atof(icXmlAttrValue(attr));
3314 }
3315 }
3316 for (i=9; i<12; i++) {
3317 sprintf(attrName, "e%d", i+1);
3318 xmlAttr *attr = icXmlFindAttr(pNode, attrName);
3319 if (attr) {
3320 pMatrix->m_e[i] = (icFloatNumber)atof(icXmlAttrValue(attr));
3321 pMatrix->m_bUseConstants = true;
3322 }
3323 }
3324 return true;
3325}
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 
)
3108{
3109 char buf[128];
3110 xml += blanks + "<Matrix\n";
3111
3112 sprintf(buf, " e1=\"" icXmlFloatFmt "\" e2=\"" icXmlFloatFmt "\" e3=\"" icXmlFloatFmt "\"\n", pMatrix->m_e[0], pMatrix->m_e[1], pMatrix->m_e[2]);
3113 xml += blanks + buf;
3114
3115 sprintf(buf, " e4=\"" icXmlFloatFmt "\" e5=\"" icXmlFloatFmt "\" e6=\"" icXmlFloatFmt "\"\n", pMatrix->m_e[3], pMatrix->m_e[4], pMatrix->m_e[5]);
3116 xml += blanks + buf;
3117
3118 sprintf(buf, " e7=\"" icXmlFloatFmt "\" e8=\"" icXmlFloatFmt "\" e9=\"" icXmlFloatFmt "\"", pMatrix->m_e[6], pMatrix->m_e[7], pMatrix->m_e[8]);
3119 xml += blanks + buf;
3120
3121 if (pMatrix->m_bUseConstants) {
3122 xml += "\n";
3123 sprintf(buf, " e10=\"" icXmlFloatFmt "\" e11=\"" icXmlFloatFmt "\" e12=\"" icXmlFloatFmt "\"", pMatrix->m_e[9], pMatrix->m_e[10], pMatrix->m_e[11]);
3124 xml += blanks + buf;
3125 }
3126 xml += "/>\n";
3127 return true;
3128}
#define icXmlFloatFmt
Definition IccXmlConfig.h:75

References 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 
)
3794{
3795 xmlNode *pChannels = icXmlFindNode(pNode, "Channels");
3796
3797 if (!pChannels)
3798 return false;
3799
3800 xmlAttr *in = icXmlFindAttr(pChannels, "InputChannels");
3801 xmlAttr *out = icXmlFindAttr(pChannels, "OutputChannels");
3802
3803 if (!in || !out)
3804 return false;
3805
3806 int nIn = atoi(icXmlAttrValue(in));
3807 int nOut = atoi(icXmlAttrValue(out));
3808
3809 pMBB->Init(nIn, nOut);
3810
3811 for (; pNode; pNode = pNode->next) {
3812 if (pNode->type == XML_ELEMENT_NODE) {
3813 if (!icXmlStrCmp(pNode->name, "ACurves") && !pMBB->GetCurvesA()) {
3814 LPIccCurve *pCurves = pMBB->NewCurvesA();
3815 if (!icCurvesFromXml(pCurves, !pMBB->IsInputB() ? nIn : nOut, pNode->children, nType, parseStr)) {
3816 parseStr += "Error! - Failed to parse ACurves.\n";
3817 return false;
3818 }
3819 }
3820 else if (!icXmlStrCmp(pNode->name, "BCurves") && !pMBB->GetCurvesB()) {
3821 LPIccCurve *pCurves = pMBB->NewCurvesB();
3822 if (!icCurvesFromXml(pCurves, pMBB->IsInputB() ? nIn : nOut, pNode->children, nType, parseStr)) {
3823 parseStr += "Error! - Failed to parse BCurves.\n";
3824 return false;
3825 }
3826 }
3827 else if (!icXmlStrCmp(pNode->name, "MCurves") && !pMBB->GetCurvesM()) {
3828 LPIccCurve *pCurves = pMBB->NewCurvesM();
3829 if (!icCurvesFromXml(pCurves, !pMBB->IsInputMatrix() ? nIn : nOut, pNode->children, nType, parseStr)) {
3830 parseStr += "Error! - Failed to parse MCurves.\n";
3831 return false;
3832 }
3833 }
3834 else if (!icXmlStrCmp(pNode->name, "Matrix") && !pMBB->GetMatrix()) {
3835 CIccMatrix *pMatrix = pMBB->NewMatrix();
3836 if (!icMatrixFromXml(pMatrix, pNode)) {
3837 parseStr += "Error! - Failed to parse Matrix.\n";
3838 return false;
3839 }
3840 }
3841 else if (!icXmlStrCmp(pNode->name, "CLUT") && !pMBB->GetCLUT()) {
3842 CIccCLUT *pCLUT = icCLutFromXml(pNode, nIn, nOut, nType, parseStr);
3843 if (pCLUT) {
3844 if (!pMBB->SetCLUT(pCLUT)) {
3845 parseStr += "Error! - Failed to set CLUT to LUT.\n";
3846 return false;
3847 }
3848 }
3849 else {
3850 parseStr += "Error! - Failed to parse CLUT.\n";
3851 return false;
3852 }
3853 }
3854 }
3855 }
3856
3857 return true;
3858}
CIccCLUT * icCLutFromXml(xmlNode *pNode, int nIn, int nOut, icConvertType nType, std::string &parseStr)
Definition IccTagXml.cpp:3327
bool icCurvesFromXml(LPIccCurve *pCurve, icUInt32Number nChannels, xmlNode *pNode, icConvertType nType, std::string &parseStr)
Definition IccTagXml.cpp:3232
bool icMatrixFromXml(CIccMatrix *pMatrix, xmlNode *pNode)
Definition IccTagXml.cpp:3301
Definition IccTagLut.h:260
bool IsInputB()
Definition IccTagLut.h:445
LPIccCurve * GetCurvesM() const
Definition IccTagLut.h:472
LPIccCurve * NewCurvesB()
Definition IccTagLut.cpp:3718
CIccMatrix * NewMatrix()
Definition IccTagLut.cpp:3740
virtual bool IsInputMatrix()
Definition IccTagLut.h:442
CIccCLUT * SetCLUT(CIccCLUT *clut)
Definition IccTagLut.cpp:3788
LPIccCurve * GetCurvesB() const
Definition IccTagLut.h:471
LPIccCurve * NewCurvesM()
Definition IccTagLut.cpp:3696
LPIccCurve * NewCurvesA()
Definition IccTagLut.cpp:3673
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)
Definition IccTagLut.cpp:3410

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

Referenced by CIccTagXmlLutAtoB::ParseXml(), CIccTagXmlLutBtoA::ParseXml(), CIccTagXmlLut8::ParseXml(), and CIccTagXmlLut16::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 
)
3132{
3133 //blanks += " ";
3134 char buf[256];
3135
3136 sprintf(buf, "<Channels InputChannels=\"%d\" OutputChannels=\"%d\"/>\n", pMBB->InputChannels(), pMBB->OutputChannels());
3137 xml += blanks + buf;
3138
3139 if (pMBB->IsInputMatrix()) {
3140 if (pMBB->SwapMBCurves()) {
3141 if (pMBB->GetMatrix()) {
3142 // added if-statement
3143 if (!icMatrixToXml(xml, pMBB->GetMatrix(), blanks)) {
3144 return false;
3145 }
3146 }
3147
3148 if (pMBB->GetCurvesB()) {
3149 // added if-statement
3150 if (!icCurvesToXml(xml, "BCurves", pMBB->GetCurvesM(), pMBB->InputChannels(), nType, blanks)) {
3151 return false;
3152 }
3153 }
3154 }
3155 else {
3156 if (pMBB->GetCurvesB()) {
3157 // added if-statement
3158 if (!icCurvesToXml(xml, "BCurves", pMBB->GetCurvesB(), pMBB->InputChannels(), nType, blanks)) {
3159 return false;
3160 }
3161 }
3162
3163 if (pMBB->GetMatrix()) {
3164 // added if-statement
3165 if (!icMatrixToXml(xml, pMBB->GetMatrix(), blanks)) {
3166 return false;
3167 }
3168 }
3169
3170 if (pMBB->GetCurvesM()) {
3171 // added if-statement
3172 if (!icCurvesToXml(xml, "MCurves", pMBB->GetCurvesM(), 3, nType, blanks)){
3173 return false;
3174 }
3175 }
3176 }
3177
3178 if (pMBB->GetCLUT()) {
3179 // added if-statement
3180 if (!icCLUTToXml(xml, pMBB->GetCLUT(), nType, blanks, bSaveGridPoints)){
3181 return false;
3182 }
3183 }
3184
3185 if (pMBB->GetCurvesA()) {
3186 // added if-statement
3187 if (!icCurvesToXml(xml, "ACurves", pMBB->GetCurvesA(), pMBB->OutputChannels(), nType, blanks)){
3188 return false;
3189 }
3190 }
3191 }
3192 else {
3193 if (pMBB->GetCurvesA()) {
3194 // added if-statement
3195 if (!icCurvesToXml(xml, "ACurves", pMBB->GetCurvesA(), pMBB->InputChannels(), nType, blanks)){
3196 return false;
3197 }
3198 }
3199
3200 if (pMBB->GetCLUT()) {
3201 // added if-statement
3202 if (!icCLUTToXml(xml, pMBB->GetCLUT(), nType, blanks, bSaveGridPoints)){
3203 return false;
3204 }
3205 }
3206
3207 if (pMBB->GetCurvesM()) {
3208 // added if-statement
3209 if (!icCurvesToXml(xml, "MCurves", pMBB->GetCurvesM(), 3, nType, blanks)){
3210 return false;
3211 }
3212 }
3213
3214 if (pMBB->GetMatrix()) {
3215 // added if-statement
3216 if (!icMatrixToXml(xml, pMBB->GetMatrix(), blanks)) {
3217 return false;
3218 }
3219 }
3220
3221 if (pMBB->GetCurvesB()) {
3222 // added if-statement
3223 if (!icCurvesToXml(xml, "BCurves", pMBB->GetCurvesB(), pMBB->OutputChannels(), nType, blanks)){
3224 return false;
3225 }
3226 }
3227 }
3228 return true;
3229}
bool icCurvesToXml(std::string &xml, const char *szName, CIccCurve **pCurves, int numCurve, icConvertType nType, std::string blanks)
Definition IccTagXml.cpp:3042
bool icMatrixToXml(std::string &xml, CIccMatrix *pMatrix, std::string blanks)
Definition IccTagXml.cpp:3107
bool icCLUTToXml(std::string &xml, CIccCLUT *pCLUT, icConvertType nType, std::string blanks, bool bSaveGridPoints=false, const char *szExtraAttrs="", const char *szName="CLUT")
Definition IccUtilXml.cpp:537
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 CIccTagXmlLutAtoB::ToXml(), CIccTagXmlLutBtoA::ToXml(), CIccTagXmlLut8::ToXml(), and CIccTagXmlLut16::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 = "" 
)
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:110
ICCPROFLIB_API const icChar * icGetSigStr(icChar *pBuf, icUInt32Number nSig)
Definition IccUtil.cpp:1056
const std::string icGetDeviceAttrName(icUInt64Number devAttr)
Definition IccUtilXml.cpp:1426
const icChar * icGetTagSigTypeName(icTagTypeSignature tagTypeSig)
Definition IccUtilXml.cpp:1141
const char * icFixXml(char *szDest, const char *szStr)
Definition IccUtilXml.cpp:305
Definition IccTagBasic.h:108
virtual icTagTypeSignature GetType() const
Definition IccTagBasic.h:131
CIccTag * GetTag() const
Definition IccTagBasic.h:1468
CIccProfileDescText m_deviceMfgDesc
Definition IccTagBasic.h:1502
icSignature m_deviceMfg
Definition IccTagBasic.h:1498
icSignature m_deviceModel
Definition IccTagBasic.h:1499
icTechnologySignature m_technology
Definition IccTagBasic.h:1501
CIccProfileDescText m_deviceModelDesc
Definition IccTagBasic.h:1503
icUInt64Number m_attributes
Definition IccTagBasic.h:1500
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
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)
Definition IccUtilXml.cpp:648
const char * icAnsiToUtf8(std::string &buf, const char *szSrc)
Definition IccUtilXml.cpp:372

References icAnsiToUtf8(), and icXmlDumpHexData().

Referenced by CIccTagXmlText::ToXml(), CIccTagXmlUtf8Text::ToXml(), CIccTagXmlUtf16Text::ToXml(), and CIccTagXmlTextDescription::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 
)
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}
icTechnologySignature
Definition icProfileHeader.h:491
icTagTypeSignature
Definition icProfileHeader.h:526
icTagTypeSignature icGetTypeNameTagSig(const icChar *szTagType)
Definition IccUtilXml.cpp:1152
icUInt64Number icGetDeviceAttrValue(xmlNode *pNode)
Definition IccUtilXml.cpp:1344
icSignature icXmlStrToSig(const char *szStr)
Definition IccUtilXml.cpp:567
bool SetType(icTagTypeSignature nType)
Definition IccTagBasic.cpp:9263

References CIccTagXml::GetExtClassName(), CIccTag::GetExtension(), CIccProfileDescText::GetTag(), icGetDeviceAttrValue(), icGetTypeNameTagSig(), icXmlFindNode(), 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
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)
Definition IccUtilXml.cpp:397
icUInt32Number icXmlGetHexDataSize(const char *szText)
Definition IccUtilXml.cpp:630
icUInt32Number icXmlGetHexData(void *pBuf, const char *szText, icUInt32Number nBufSize)
Definition IccUtilXml.cpp:609
icInt32Number ReadLine(void *pBuf8, icInt32Number nNum=256)
Definition IccIO.cpp:93
bool SetSize(icUInt32Number nSize)
Definition IccUtilXml.cpp:1102

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

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

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