Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
CIccTagXmlStruct Class Reference

#include <IccTagXml.h>

+ Inheritance diagram for CIccTagXmlStruct:
+ Collaboration diagram for CIccTagXmlStruct:

Public Member Functions

virtual const char * GetClassName () const
 
virtual IIccExtensionTagGetExtension ()
 
virtual bool ParseXml (xmlNode *pNode, std::string &parseStr)
 
virtual bool ToXml (std::string &xml, std::string blanks="")
 
virtual ~CIccTagXmlStruct ()
 
- Public Member Functions inherited from CIccTagStruct
bool AreElemsUnique () const
 Name: CIccTagStruct::AreElemsUnique.
 
bool AttachElem (icSignature sig, CIccTag *pTag)
 Name: CIccTagStruct::AttachTag.
 
 CIccTagStruct ()
 Name: CIccTagStruct::CIccTagStruct.
 
 CIccTagStruct (const CIccTagStruct &lut)
 Name: CIccTagStruct::CIccTagStruct.
 
bool DeleteElem (icSignature sig)
 Name: CIccTagStruct::DeleteSubTag.
 
virtual void Describe (std::string &sDescription, int nVerboseness)
 Name: CIccTagStruct::Describe.
 
CIccTagFindElem (icSignature sig)
 Name: CIccTagStruct::FindElem.
 
CIccTagFindElemOfType (icSignature sig, icTagTypeSignature sigType)
 Name: CIccTagStruct::FindElemOfType.
 
TagEntryList * GetElemList ()
 
icFloatNumber GetElemNumberValue (icSignature sig, icFloatNumber defaultValue=0)
 Name: CIccTagStruct::GetElemNumberValue.
 
IIccStructGetStructHandler ()
 Name: CIccTagStruct::GetStructHandler.
 
virtual icStructSignature GetTagStructType () const
 
virtual icTagTypeSignature GetType () const
 Function: GetType()
 
virtual CIccTagNewCopy () const
 Function: NewCopy(sDescription) Each derived tag will implement it's own NewCopy() function.
 
CIccTagStructoperator= (const CIccTagStruct &lut)
 Name: &operator=.
 
virtual bool Read (icUInt32Number size, CIccIO *pIO)
 Name: CIccTagStruct::Read.
 
virtual bool SetTagStructType (icStructSignature sig)
 Name: CIccTagStruct::SetTagStructType.
 
virtual icValidateStatus Validate (std::string sigPath, std::string &sReport, const CIccProfile *pProfile=NULL) const
 Name: CIccTagStruct::Validate.
 
virtual bool Write (CIccIO *pIO)
 Name: CIccTagStruct::Write.
 
virtual ~CIccTagStruct ()
 Name: CIccTagStruct::~CIccTagStruct.
 
- Public Member Functions inherited from CIccTag
 CIccTag ()
 Name: CIccTag::CIccTag.
 
virtual void DetachIO ()
 Function: ReadAll() - Read All sub data for tag from file.
 
virtual icArraySignature GetTagArrayType () const
 
virtual bool IsArrayType ()
 
virtual bool IsMBBType ()
 
virtual bool IsNumArrayType () const
 
virtual bool IsSupported ()
 Function: IsSupported(size, pIO) - Check if tag fully supported for apply purposes.
 
virtual bool Read (icUInt32Number size, CIccIO *pIO, CIccProfile *pProfile)
 Function: Read(size, pIO) - Read tag from file.
 
virtual bool ReadAll ()
 Function: ReadAll() - Read All sub data for tag from file.
 
virtual ~CIccTag ()
 Name: CIccTag::CIccTag.
 
- Public Member Functions inherited from CIccTagXml
virtual const char * GetExtClassName () const
 
virtual const char * GetExtDerivedClassName () const
 
virtual ~CIccTagXml (void)
 

Protected Member Functions

bool ParseTag (xmlNode *pNode, std::string &parseStr)
 Name: CIccTagXmlStruct::ParseTag.
 
- Protected Member Functions inherited from CIccTagStruct
void Cleanup ()
 Name: CIccTagStruct::Cleanup.
 
bool DetachElem (CIccTag *pTag)
 Name: CIccTagStruct::DetachSubTag.
 
IccTagEntry * GetElem (CIccTag *pTag) const
 Name: CIccTagStruct::GetElem.
 
IccTagEntry * GetElem (icSignature sig) const
 Name: CIccTagStruct::GetElem.
 
bool LoadElem (IccTagEntry *pTagEntry, CIccIO *pIO)
 Name: CIccTagStruct::LoadSubTag.
 

Additional Inherited Members

- Static Public Member Functions inherited from CIccTagStruct
static std::string GetElemName (icTagSignature sig, icStructSignature sigThis)
 
static CIccTagStructParseMem (icUInt8Number *pMem, icUInt32Number size)
 Name: CIccTagStruct::ParseMem.
 
- Static Public Member Functions inherited from CIccTag
static CIccTagCreate (icTagTypeSignature sig)
 Name: CIccTag::Create.
 
- Public Attributes inherited from CIccTag
icUInt32Number m_nReserved
 
- Protected Attributes inherited from CIccTagStruct
TagEntryList * m_ElemEntries
 
TagPtrList * m_ElemVals
 
IIccStructm_pStruct
 
icStructSignature m_sigStructType
 
icUInt32Number m_tagSize
 
icUInt32Number m_tagStart
 

Detailed Description

Definition at line 641 of file IccTagXml.h.

Constructor & Destructor Documentation

◆ ~CIccTagXmlStruct()

virtual CIccTagXmlStruct::~CIccTagXmlStruct ( )
inlinevirtual

Definition at line 644 of file IccTagXml.h.

644{}

Member Function Documentation

◆ GetClassName()

virtual const char * CIccTagXmlStruct::GetClassName ( ) const
inlinevirtual

Reimplemented from CIccTagStruct.

Definition at line 646 of file IccTagXml.h.

646{return "CIccTagXmlStruct"; }

◆ GetExtension()

virtual IIccExtensionTag * CIccTagXmlStruct::GetExtension ( )
inlinevirtual

Reimplemented from CIccTag.

Definition at line 648 of file IccTagXml.h.

648{return this; }

◆ ParseTag()

bool CIccTagXmlStruct::ParseTag ( xmlNode * pNode,
std::string & parseStr )
protected

Name: CIccTagXmlStruct::ParseTag.

Purpose: This will load from the indicated IO object and associate a tag object to a tag directory entry. Nothing happens if tag directory entry is associated with a tag object.

Args: pNode - pointer to xmlNode object to parse from

Return: true - tag from node successfully parsed, false - failure

Definition at line 4483 of file IccTagXml.cpp.

4484{
4485 xmlAttr *attr;
4486
4487 if (pNode->type != XML_ELEMENT_NODE) {// || icXmlStrCmp(pNode->name, "Tag")) {
4488 parseStr += "Invalid Tag Node: ";
4489 parseStr += (const char *)pNode->name;
4490 parseStr += "\n";
4491 return false;
4492 }
4493
4494 CIccTag *pTag = NULL;
4495
4496 std::string nodeName = (icChar*)pNode->name;
4497 icSignature sigTag;
4498 if (m_pStruct)
4499 sigTag = m_pStruct->GetElemSig(nodeName.c_str());
4500 else
4501 sigTag = 0;
4502
4503 if (sigTag != 0 || nodeName == "PrivateSubTag") { //Parsing of XML tags by name
4504 if (nodeName == "PrivateSubTag") {
4505 const char *tagSig = icXmlAttrValue(pNode, "TagSignature", "");
4506 if (tagSig[0]) {
4507 sigTag = (icTagSignature)icGetSigVal(tagSig);
4508 }
4509 else {
4510 parseStr += "Invalid TagSignature for PrivateSubTag\n";
4511 return false;
4512 }
4513 }
4514
4515 const char *sameAs = icXmlAttrValue(pNode, "SameAs", "");
4516
4517 if (sameAs[0]) {
4518 icTagSignature sigParentTag = icGetTagNameSig(sameAs);
4519 if (!strcmp(sameAs, "PrivateSubTag") || sigParentTag == icSigUnknownTag) {
4520 const char *sameAsSig = icXmlAttrValue(pNode, "SameAsSignature", "");
4521 if (sameAsSig[0]) {
4522 sigParentTag = (icTagSignature)icGetSigVal(sameAsSig);
4523 }
4524 else {
4525 parseStr += "Invalid SameAsSignature for PrivateSubTag\n";
4526 return false;
4527 }
4528 }
4529 pTag = this->FindElem(sigParentTag);
4530 if (pTag) {
4531 AttachElem(sigTag, pTag);
4532 }
4533 else {
4534 parseStr += "SameAs tag ";
4535 parseStr += sameAs;
4536 parseStr += " for ";
4537 parseStr += nodeName + " does not exist\n";
4538 return false;
4539 }
4540
4541 return true;
4542 }
4543 else { //Parse the type node as the first child
4544 xmlNode *pTypeNode;
4545 for (pTypeNode = pNode->children; pTypeNode; pTypeNode = pTypeNode->next) {
4546 if (pTypeNode->type == XML_ELEMENT_NODE) {
4547 break;
4548 }
4549 }
4550
4551 if (!pTypeNode) {
4552 parseStr += "No tag type node defined for ";
4553 parseStr += nodeName;
4554 parseStr += "\n";
4555 return false;
4556 }
4557
4558 // get the tag type signature
4559 icTagTypeSignature sigType = icGetTypeNameTagSig((const icChar*)pTypeNode->name);
4560
4561 if (sigType == icSigUnknownType) {
4562 xmlAttr *attr = icXmlFindAttr(pTypeNode, "type");
4564 }
4565
4566 CIccInfo info;
4567
4568 // create a tag based on the signature
4569 pTag = CIccTag::Create(sigType);
4570
4571 IIccExtensionTag *pExt;
4572
4573 if (pTag && (pExt = pTag->GetExtension()) && !strcmp(pExt->GetExtClassName(), "CIccTagXml")) {
4574 CIccTagXml* pXmlTag = (CIccTagXml*)pExt;
4575
4576 if (pXmlTag->ParseXml(pTypeNode->children, parseStr)) {
4577 if ((attr = icXmlFindAttr(pTypeNode, "reserved"))) {
4578 sscanf(icXmlAttrValue(attr), "%u", &pTag->m_nReserved);
4579 }
4580 AttachElem(sigTag, pTag);
4581 }
4582 else {
4583 parseStr += "Unable to Parse \"";
4584 parseStr += (const char*)pTypeNode->name;
4585 parseStr += "\" (";
4586 parseStr += nodeName;
4587 parseStr += ") Tag\n";
4588 return false;
4589 }
4590 }
4591 else {
4592 parseStr += "Invalid tag extension for \"";
4593 parseStr += (const char*)pTypeNode->name;
4594 parseStr += "\" (";
4595 parseStr += nodeName;
4596 parseStr += ") Tag\n";
4597 return false;
4598 }
4599 }
4600 }
4601 else { //Legacy parsing of XML tags by type
4602 sigTag = (icTagSignature)0;
4603 // get the tag type signature
4604 icTagTypeSignature sigType = icGetTypeNameTagSig(nodeName.c_str());
4605
4606 if (sigType == icSigUnknownType) {
4607 xmlAttr *attr = icXmlFindAttr(pNode, "type");
4609 }
4610
4611 CIccInfo info;
4612
4613 // create a tag based on the signature
4614 pTag = CIccTag::Create(sigType);
4615
4616 IIccExtensionTag *pExt;
4617
4618 if (pTag && (pExt = pTag->GetExtension()) && !strcmp(pExt->GetExtClassName(), "CIccTagXml")) {
4619 CIccTagXml* pXmlTag = (CIccTagXml*)pExt;
4620
4621 if (pXmlTag->ParseXml(pNode->children, parseStr)) {
4622 if ((attr = icXmlFindAttr(pNode, "reserved"))) {
4623 sscanf(icXmlAttrValue(attr), "%u", &pTag->m_nReserved);
4624 }
4625
4626 for (xmlNode *tagSigNode = pNode->children; tagSigNode; tagSigNode = tagSigNode->next) {
4627 if (tagSigNode->type == XML_ELEMENT_NODE && !icXmlStrCmp(tagSigNode->name, "TagSignature")) {
4628 sigTag = (icTagSignature)icGetSigVal((const icChar*)tagSigNode->children->content);
4629 AttachElem(sigTag, pTag);
4630 }
4631 }
4632 }
4633 else {
4634 parseStr += "Unable to Parse \"";
4635 parseStr += info.GetTagTypeSigName(sigType);
4636 parseStr += "\" (";
4637 parseStr += nodeName;
4638 parseStr += ") Tag\n";
4639 return false;
4640 }
4641 }
4642 else {
4643 parseStr += "Invalid tag extension for \"";
4644 parseStr += info.GetTagTypeSigName(sigType);
4645 parseStr += "\" (";
4646 parseStr += nodeName;
4647 parseStr += ") Tag\n";
4648 return false;
4649 }
4650 }
4651
4652 return true;
4653}
char icChar
Definition IccDefs.h:109
icUInt32Number icGetSigVal(const icChar *pBuf)
Definition IccUtil.cpp:1258
xmlAttr * icXmlFindAttr(xmlNode *pNode, const char *szAttrName)
icTagTypeSignature icGetTypeNameTagSig(const icChar *szTagType)
icTagSignature icGetTagNameSig(const icChar *szName)
const char * icXmlAttrValue(xmlAttr *attr, const char *szDefault)
#define icXmlStrCmp(x, y)
Definition IccUtilXml.h:134
icTagTypeSignature
Type: Class.
Definition IccUtil.h:303
const icChar * GetTagTypeSigName(icTagTypeSignature sig)
Definition IccUtil.cpp:1594
Class: CIccTag.
static CIccTag * Create(icTagTypeSignature sig)
Name: CIccTag::Create.
bool AttachElem(icSignature sig, CIccTag *pTag)
Name: CIccTagStruct::AttachTag.
CIccTag * FindElem(icSignature sig)
Name: CIccTagStruct::FindElem.
IIccStruct * m_pStruct
virtual bool ParseXml(xmlNode *pNode, std::string &parseStr)=0
virtual const char * GetExtClassName() const =0
virtual icSignature GetElemSig(const icChar *szElemName) const =0
#define icSigUnknownType
Convenience Enum Definitions - Not defined in ICC specification.
icUInt32Number icSignature
#define icSigUnknownTag
Convenience Enum Definitions - Not defined in ICC specification.
icTagSignature
public tags and sizes

References CIccTag::Create(), IIccExtensionTag::GetExtClassName(), CIccTag::GetExtension(), CIccInfo::GetTagTypeSigName(), icGetSigVal(), icGetTagNameSig(), icGetTypeNameTagSig(), icSigUnknownTag, icSigUnknownType, icXmlAttrValue(), icXmlFindAttr(), icXmlStrCmp, CIccTag::m_nReserved, and CIccTagXml::ParseXml().

+ Here is the call graph for this function:

◆ ParseXml()

bool CIccTagXmlStruct::ParseXml ( xmlNode * pNode,
std::string & parseStr )
virtual

Implements CIccTagXml.

Definition at line 4656 of file IccTagXml.cpp.

4657{
4658 // parse each tag
4659 xmlNode *tagNode, *firstNode=pNode;
4660
4661 for (; pNode; pNode = pNode->next) {
4662 if (pNode->type == XML_ELEMENT_NODE)
4663 break;
4664 }
4665 if (!pNode) {
4666 parseStr += "Invalid Tag Structure: ";
4667 parseStr += (const char *)firstNode->name;
4668 parseStr += "\n";
4669 return false;
4670 }
4671
4672 std::string nodeName = (icChar*)pNode->name;
4673
4674 icStructSignature sigStruct = CIccStructCreator::GetStructSig(nodeName.c_str());
4675
4676 if (sigStruct) {
4677 SetTagStructType(sigStruct);
4678 pNode = pNode->children;
4679 }
4680 else {
4681 tagNode = icXmlFindNode(firstNode, "StructureSignature");
4682 if (!tagNode) {
4683 parseStr += "Unable to find StructureSignature\n";
4684 return false;
4685 }
4686
4687 if (tagNode->type == XML_ELEMENT_NODE && tagNode->children && tagNode->children->content) {
4688
4689 sigStruct = (icStructSignature)icGetSigVal(tagNode->children ? (const icChar*)tagNode->children->content : "");
4690 SetTagStructType(sigStruct);
4691 }
4692 else {
4693 parseStr += "Invalid XNode type for StructureSignature\n";
4694 return false;
4695 }
4696 }
4697
4698 tagNode = icXmlFindNode(pNode, "MemberTags");
4699 if (!tagNode) {
4700 parseStr += "Unable to find structure MemberTags\n";
4701 return false;
4702 }
4703
4704 for (tagNode = tagNode->children; tagNode; tagNode = tagNode->next) {
4705 if (tagNode->type == XML_ELEMENT_NODE) {
4706 if (!ParseTag(tagNode, parseStr)) {
4707 parseStr += "Failed to parse tag member (";
4708 parseStr += (char*)tagNode->name;
4709 parseStr += ")\n";
4710 return false;
4711 }
4712 }
4713 }
4714
4715 return true;
4716}
xmlNode * icXmlFindNode(xmlNode *pNode, const char *szNodeName)
static icStructSignature GetStructSig(const icChar *structName)
Function: GetStructSig(structName) Get signature of structure from display name.
virtual bool SetTagStructType(icStructSignature sig)
Name: CIccTagStruct::SetTagStructType.
bool ParseTag(xmlNode *pNode, std::string &parseStr)
Name: CIccTagXmlStruct::ParseTag.
icStructSignature
Tag Structure type signatures.

References CIccStructCreator::GetStructSig(), icGetSigVal(), and icXmlFindNode().

+ Here is the call graph for this function:

◆ ToXml()

bool CIccTagXmlStruct::ToXml ( std::string & xml,
std::string blanks = "" )
virtual

Implements CIccTagXml.

Definition at line 4350 of file IccTagXml.cpp.

4351{
4352 std::string info;
4353 char buf[256], fix[256], line[256];
4354 IIccStruct *pStruct = GetStructHandler();
4355
4356 const icChar *structName = ((pStruct != NULL) ? pStruct->GetDisplayName() : NULL);
4357 blanks += " ";
4358
4359 if (structName && strcmp(structName, "privateStruct")) {
4360 sprintf(line, "<%s> <MemberTags>\n", structName);
4361 }
4362 else {
4363 // print out the struct signature
4364 sprintf(line, "<privateStruct StructSignature=\"%s\"/> <MemberTags>\n", icFixXml(fix, icGetSigStr(buf, m_sigStructType)));
4365 structName = "privateStruct";
4366 }
4367
4368 xml += blanks + line;
4369 TagEntryList::iterator i, j;
4370 std::set<icTagSignature> sigSet;
4371 CIccInfo Fmt;
4372 IccOffsetTagSigMap offsetTags;
4373
4374 for (i=m_ElemEntries->begin(); i!=m_ElemEntries->end(); i++) {
4375 if (sigSet.find(i->TagInfo.sig)==sigSet.end()) {
4376 CIccTag *pTag = FindElem(i->TagInfo.sig);
4377
4378 if (pTag) {
4379 CIccTagXml *pTagXml = (CIccTagXml*)(pTag->GetExtension());
4380 if (pTagXml) {
4381 IccOffsetTagSigMap::iterator prevTag = offsetTags.find(i->TagInfo.offset);
4382 std::string tagName = ((pStruct!=NULL) ? pStruct->GetElemName((icSignature)i->TagInfo.sig) : "");
4383 if (prevTag == offsetTags.end()) {
4384 const icChar* tagSig = icGetTagSigTypeName(pTag->GetType());
4385
4386 if (tagName.size() && strncmp(tagName.c_str(), "PrivateSubTag", 13)) {
4387 sprintf(line, " <%s>", icFixXml(fix, tagName.c_str()));
4388 }
4389 else {
4390 sprintf(line, " <PrivateSubTag TagSignature=\"%s\">", icFixXml(fix, icGetSigStr(buf, i->TagInfo.sig)));
4391 tagName = "PrivateSubTag";
4392 }
4393 xml += blanks + line;
4394
4395 // PrivateType - a type that does not belong to the list in the icc specs - custom for vendor.
4396 if (!strcmp("PrivateType", tagSig))
4397 sprintf(line, " <PrivateType type=\"%s\">\n", icFixXml(fix, icGetSigStr(buf, pTag->GetType())));
4398 else
4399 sprintf(line, " <%s>\n", tagSig); //parent node is the tag type
4400
4401 xml += line;
4402 j = i;
4403#if 0
4404 // print out the tag signature (there is at least one)
4405 sprintf(line, " <TagSignature>%s</TagSignature>\n", icFixXml(fix, icGetSigStr(buf, i->TagInfo.sig)));
4406 xml += blanks + line;
4407
4408 sigSet.insert(i->TagInfo.sig);
4409
4410 // print out the rest of the tag signatures
4411 for (j++; j != m_ElemEntries->end(); j++) {
4412 if (j->pTag == i->pTag || j->TagInfo.offset == i->TagInfo.offset) {
4413 sprintf(line, " <TagSignature>%s</TagSignature>\n", icFixXml(fix, icGetSigStr(buf, j->TagInfo.sig)));
4414 xml += blanks + line;
4415 sigSet.insert(j->TagInfo.sig);
4416 }
4417 }
4418 // if (pTag->m_nReserved) {
4419 // sprintf(line, " Reserved=\"%08x\"", pTag->m_nReserved);
4420 // xml += line;
4421 // }
4422 // xml += ">\n";
4423#endif
4424 //convert the rest of the tag to xml
4425 if (!pTagXml->ToXml(xml, blanks + " ")) {
4426 printf("Unable to output sub-tag with type %s\n", icGetSigStr(buf, i->TagInfo.sig));
4427 return false;
4428 }
4429 sprintf(line, " </%s> </%s>\n", tagSig, tagName.c_str());
4430 xml += blanks + line;
4431 offsetTags[i->TagInfo.offset] = i->TagInfo.sig;
4432 }
4433 else {
4434 std::string prevTagName = ((pStruct != NULL) ? pStruct->GetElemName(prevTag->second) : "");
4435 char fix2[200];
4436
4437 if (tagName.size() && strncmp(tagName.c_str(), "PrivateSubTag", 13))
4438 sprintf(line, " <%s SameAs=\"%s\"", icFixXml(fix, tagName.c_str()), icFixXml(fix2, prevTagName.c_str())); //parent node is the tag type
4439 else
4440 sprintf(line, " <PrivateSubTag TagSignature=\"%s\" SameAs=\"%s\"", icFixXml(fix2, icGetSigStr(buf, i->TagInfo.sig)), icFixXml(fix, prevTagName.c_str()));
4441
4442 xml += line;
4443 if (prevTagName.size() || !strncmp(prevTagName.c_str(), "PrivateSubTag", 13)) {
4444 sprintf(line, " SameAsSignature=\"%s\"", icFixXml(fix2, icGetSigStr(buf, prevTag->second)));
4445 xml += line;
4446 }
4447
4448 xml += "/>\n";
4449 }
4450 }
4451 else {
4452 printf("Non XML tag in list with type %s!\n", icGetSigStr(buf, i->TagInfo.sig));
4453 return false;
4454 }
4455 }
4456 else {
4457 printf("Unable to find tag with type %s!\n", icGetSigStr(buf, i->TagInfo.sig));
4458 return false;
4459 }
4460 }
4461 }
4462
4463 xml += blanks + "</MemberTags> </" + structName + ">\n";
4464 return true;
4465}
std::map< icUInt32Number, icTagSignature > IccOffsetTagSigMap
const icChar * icGetSigStr(icChar *pBuf, icUInt32Number nSig)
Definition IccUtil.cpp:1056
const icChar * icGetTagSigTypeName(icTagTypeSignature tagTypeSig)
const char * icFixXml(std::string &buf, const char *szStr)
virtual icTagTypeSignature GetType() const
Function: GetType()
virtual IIccExtensionTag * GetExtension()
TagEntryList * m_ElemEntries
icStructSignature m_sigStructType
IIccStruct * GetStructHandler()
Name: CIccTagStruct::GetStructHandler.
virtual bool ToXml(std::string &xml, std::string blanks="")=0
Class: IIccStruct.
virtual std::string GetElemName(icSignature sigElem) const =0
virtual const icChar * GetDisplayName() const =0

References IIccStruct::GetDisplayName(), IIccStruct::GetElemName(), CIccTag::GetExtension(), CIccTag::GetType(), icFixXml(), icGetSigStr(), icGetTagSigTypeName(), and CIccTagXml::ToXml().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: