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

#include <IccTagXml.h>

+ Inheritance diagram for CIccTagXmlTextDescription:
+ Collaboration diagram for CIccTagXmlTextDescription:

Public Member Functions

 CIccTagXmlTextDescription ()
 
 CIccTagXmlTextDescription (const CIccTagXmlTextDescription &ITTD)
 
virtual const char * GetClassName () const
 
virtual IIccExtensionTagGetExtension ()
 
virtual CIccTagNewCopy () const
 Function: NewCopy(sDescription) Each derived tag will implement it's own NewCopy() function.
 
virtual bool ParseXml (xmlNode *pNode, std::string &parseStr)
 
virtual bool ToXml (std::string &xml, std::string blanks="")
 
virtual ~CIccTagXmlTextDescription ()
 
- Public Member Functions inherited from CIccTagTextDescription
icUInt32Number Capacity () const
 
 CIccTagTextDescription ()
 Name: CIccTagTextDescription::CIccTagTextDescription.
 
 CIccTagTextDescription (const CIccTagTextDescription &ITTD)
 Name: CIccTagTextDescription::CIccTagTextDescription.
 
virtual void Describe (std::string &sDescription, int nVerboseness)
 Name: CIccTagTextDescription::Describe.
 
icCharGetBuffer (icUInt32Number nSize)
 Name: CIccTagTextDescription::GetBuffer.
 
const icCharGetText () const
 
virtual icTagTypeSignature GetType () const
 Function: GetType()
 
icUInt16NumberGetUnicodeBuffer (icUInt32Number nSize)
 Name: CIccTagTextDescription::GetUnicodeBuffer.
 
CIccTagTextDescriptionoperator= (const CIccTagTextDescription &TextDescTag)
 Name: CIccTagTextDescription::operator=.
 
const icCharoperator= (const icChar *szText)
 Name: CIccTagTextDescription::operator=.
 
virtual bool Read (icUInt32Number size, CIccIO *pIO)
 Name: CIccTagTextDescription::Read.
 
void Release ()
 Name: CIccTagTextDescription::Release.
 
void ReleaseUnicode ()
 Name: CIccTagTextDescription::ReleaseUnicode.
 
void SetText (const icChar *szText)
 Name: CIccTagTextDescription::SetText.
 
virtual icValidateStatus Validate (std::string sigPath, std::string &sReport, const CIccProfile *pProfile=NULL) const
 Name: CIccTagTextDescription::Validate.
 
virtual bool Write (CIccIO *pIO)
 Name: CIccTagTextDescription::Write.
 
virtual ~CIccTagTextDescription ()
 Name: CIccTagTextDescription::~CIccTagTextDescription.
 
- 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 icStructSignature GetTagStructType () 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)
 

Additional Inherited Members

- 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 CIccTagTextDescription
bool m_bInvalidScript
 
icUInt32Number m_nASCIISize
 
icUInt16Number m_nScriptCode
 
icUInt8Number m_nScriptSize
 
icUInt32Number m_nUnicodeLanguageCode
 
icUInt32Number m_nUnicodeSize
 
icUInt8Number m_szScriptText [67]
 
icCharm_szText
 
icUInt16Numberm_uzUnicodeText
 

Detailed Description

Definition at line 186 of file IccTagXml.h.

Constructor & Destructor Documentation

◆ CIccTagXmlTextDescription() [1/2]

CIccTagXmlTextDescription::CIccTagXmlTextDescription ( )
inline

Definition at line 189 of file IccTagXml.h.

CIccTagTextDescription()
Name: CIccTagTextDescription::CIccTagTextDescription.

Referenced by NewCopy().

+ Here is the caller graph for this function:

◆ CIccTagXmlTextDescription() [2/2]

CIccTagXmlTextDescription::CIccTagXmlTextDescription ( const CIccTagXmlTextDescription & ITTD)
inline

Definition at line 190 of file IccTagXml.h.

190: CIccTagTextDescription(ITTD) {}

◆ ~CIccTagXmlTextDescription()

virtual CIccTagXmlTextDescription::~CIccTagXmlTextDescription ( )
inlinevirtual

Definition at line 191 of file IccTagXml.h.

191{}

Member Function Documentation

◆ GetClassName()

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

Reimplemented from CIccTagTextDescription.

Definition at line 195 of file IccTagXml.h.

195{return "CIccTagXmlTextDescription"; }

◆ GetExtension()

virtual IIccExtensionTag * CIccTagXmlTextDescription::GetExtension ( )
inlinevirtual

Reimplemented from CIccTag.

Definition at line 197 of file IccTagXml.h.

197{return this; }

◆ NewCopy()

virtual CIccTag * CIccTagXmlTextDescription::NewCopy ( ) const
inlinevirtual

Function: NewCopy(sDescription) Each derived tag will implement it's own NewCopy() function.

Parameter(s): none

Returns a new CIccTag object that is a copy of this object.

Reimplemented from CIccTagTextDescription.

Definition at line 193 of file IccTagXml.h.

193{return new CIccTagXmlTextDescription(*this);}

References CIccTagXmlTextDescription().

+ Here is the call graph for this function:

◆ ParseXml()

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

Implements CIccTagXml.

Definition at line 381 of file IccTagXml.cpp.

382{
383 pNode = icXmlFindNode(pNode, "TextData");
384
385 // support for reading desc, dmmd, and dmnd tags from file.
386 // if (!pNode || !pNode->children)
387 if (!pNode)
388 return false;
389
390 // search for "file" attribute in <TextDescription/> tag
391 const icChar *filename = icXmlAttrValue(pNode, "File");
392
393 // file exists
394 if (filename[0]) {
395 CIccIO *file = IccOpenFileIO(filename, "rb");
396
397 if (!file){
398 parseStr += "Error! - File '";
399 parseStr += filename;
400 parseStr +="' not found.\n";
401 delete file;
402 return false;
403 }
404
405 icUInt32Number fileLength = file->GetLength();
406 char *buf = (char *)malloc(fileLength);
407
408 if (!buf) {
409 perror("Memory Error");
410 parseStr += "'";
411 parseStr += filename;
412 parseStr += "' may not be a valid text file.\n";
413 delete file;
414 return false;
415 }
416
417 if (file->ReadLine(buf, fileLength)!=fileLength) {
418 parseStr += "Error while reading file '";
419 parseStr += filename;
420 parseStr += "'. Size read is not equal to file length. File may not be a valid text file.\n";
421 free(buf);
422 delete file;
423 return false;
424 }
425
426 // set ANSII string
427 std::string ansiStr;
428 icUtf8ToAnsi(ansiStr, buf);
429
430 icUInt32Number nStrSize = (icUInt32Number)ansiStr.size();
431 GetBuffer(nStrSize);
432 if (nStrSize) {
433 memcpy(m_szText, ansiStr.c_str(), nStrSize);
434 m_nASCIISize = nStrSize + 1;
435 }
436 else
437 m_szText[0] = '\0';
438
439 // set Unicode String
440 CIccUTF16String wstr(buf);
441
442 nStrSize = (icUInt32Number)wstr.Size();
444
445 if (nStrSize) {
446 // assign each entry in wstr to m_uzUnicodeText
447 for (int i=0; i < (int) nStrSize; i++) {
448 m_uzUnicodeText[i] = wstr[i];
449 }
450
451 // include the null termintor in the string size.
452 m_nUnicodeSize = nStrSize + 1;
453 }
454 else
455 m_uzUnicodeText[0] = 0;
456
457 // Set ScriptCode
459 m_nScriptSize = (icUInt8Number) fileLength + 1;
460 memcpy(m_szScriptText, buf, 67);
461
462 delete file;
463 }
464
465 // file does not exist
466 else {
467 std::string str = icXmlParseTextString(pNode, parseStr);
468 icUInt32Number nSize = (icUInt32Number)str.size();
469 icChar *pBuf = GetBuffer(nSize);
470
471 if (nSize) {
472 memcpy(m_szText, str.c_str(), nSize);
473
474 // include the null termintor in the string size.
475 m_nASCIISize = nSize + 1;
476 }
477 else
478 m_szText[0] = '\0';
479
480 Release();
481
482 // support for automatically generating unicode and scriptcode tags if these do not
483 // exist in the XML file.
484 bool unicodeExists = false;
485 bool scriptcodeExists = false;
486 for (;pNode; pNode = pNode->next) {
487 if (pNode->type==XML_ELEMENT_NODE) {
488 if (!icXmlStrCmp(pNode->name, "Unicode")) {
489 const icChar *pRegion = icXmlAttrValue(pNode, "LanguageCode");
490
491 // *pRegion may not have value.
492 if (pRegion && /* *pRegion && */pNode->children && pNode->children->content) {
493 CIccUTF16String wstr((const char*)pNode->children->content);
494
495 nSize = (icUInt32Number)wstr.Size();
496
497 // set size of m_uzUnicodeText
499 if (nSize) {
500
501 // assign each entry in wstr to m_uzUnicodeText
502 for (int i=0; i < (int) nSize; i++) {
503 m_uzUnicodeText[i] = wstr[i];
504 }
505
506 // include the null termintor in the string size.
507 m_nUnicodeSize = nSize + 1;
508
509 unicodeExists = true;
510 }
511 else
512 m_uzUnicodeText[0] = 0;
513 }
514 }
515 else if (!icXmlStrCmp(pNode->name, "MacScript")) {
516 const icChar *pScript = icXmlAttrValue(pNode, "ScriptCode");
517
518 if (pScript && *pScript) {
519 icUInt32Number nCode=0;
520
521 sscanf(pScript, "%x", &nCode);
523 if (pNode->children && pNode->children->content) {
524 // set m_nScriptSize as receiver the return value of icXmlGetHexData
525 // no need to add 1 since the return value is already exact.
526 m_nScriptSize = (icUInt8Number) icXmlGetHexData(m_szScriptText, (const char*)pNode->children->content, sizeof(m_szScriptText));
527 scriptcodeExists = true;
528 }
529 else
530 m_szScriptText[0] = 0;
531 }
532 }
533 }
534 }
535#if 0
536 // automatically generate unicode tag in the profile if it does not exist
537 if (!unicodeExists){
538
540
541 if (nSize) {
542 // assign each entry in wstr to m_uzUnicodeText
543 for (int i=0; i < (int) nSize; i++) {
544 m_uzUnicodeText[i] = str[i];
545 }
546
547 // include the null termintor in the string size.
548 m_nUnicodeSize = nSize + 1;
549 }
550 else
551 m_uzUnicodeText[0] = 0;
552 }
553
554 // automatically generate scriptcode tag in the profile if it does not exist
555 if (!scriptcodeExists){
558 memcpy(m_szScriptText, m_szText, 67);
559
560 }
561#endif
562 }
563
564 return true;
565}
char icChar
Definition IccDefs.h:109
CIccIO * IccOpenFileIO(const icChar *szFilename, const char *szAttr)
Definition IccIoXml.cpp:100
static std::string icXmlParseTextString(xmlNode *pNode, std::string &parseStr, bool bConvert=true)
const char * icUtf8ToAnsi(std::string &buf, const char *szSrc)
xmlNode * icXmlFindNode(xmlNode *pNode, const char *szNodeName)
icUInt32Number icXmlGetHexData(void *pBuf, const char *szText, icUInt32Number nBufSize)
const char * icXmlAttrValue(xmlAttr *attr, const char *szDefault)
#define icXmlStrCmp(x, y)
Definition IccUtilXml.h:134
unsigned int icUInt32Number
Type: Class.
Definition IccIO.h:97
virtual icInt32Number GetLength()
Definition IccIO.h:130
icInt32Number ReadLine(void *pBuf8, icInt32Number nNum=256)
Definition IccIO.cpp:93
icUInt16Number m_nScriptCode
icUInt16Number * m_uzUnicodeText
icChar * GetBuffer(icUInt32Number nSize)
Name: CIccTagTextDescription::GetBuffer.
icUInt8Number m_szScriptText[67]
icUInt32Number m_nUnicodeSize
icUInt16Number * GetUnicodeBuffer(icUInt32Number nSize)
Name: CIccTagTextDescription::GetUnicodeBuffer.
void Release()
Name: CIccTagTextDescription::Release.
icUInt32Number m_nASCIISize
icUInt8Number m_nScriptSize
unsigned char icUInt8Number
Number definitions.
unsigned short icUInt16Number

References CIccIO::GetLength(), IccOpenFileIO(), icUtf8ToAnsi(), icXmlAttrValue(), icXmlFindNode(), icXmlGetHexData(), icXmlParseTextString(), icXmlStrCmp, CIccIO::ReadLine(), and CIccUTF16String::Size().

+ Here is the call graph for this function:

◆ ToXml()

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

Implements CIccTagXml.

Definition at line 336 of file IccTagXml.cpp.

337{
338 std::string fix;
339 std::string buf;
340 char data[256]; // Adjust the size as needed
341 std::string datastr;
342
343 icXmlDumpTextData(xml, blanks, m_szText);
344
345 // Added support for <![CData[Insert Text here]]> for Unicode
346 if (m_uzUnicodeText[0]) {
347 if (m_nUnicodeLanguageCode == 0)
348 buf = "<Unicode>";
349 else {
351 icFixXml(fix, data);
352 buf = "<Unicode LanguageCode=\"" + fix + "\">";
353 }
354 xml += blanks + buf;
355
357 icFixXml(fix, datastr.c_str());
358 buf = "<![CDATA[" + fix + "]]></Unicode>\n";
359 xml += buf;
360 }
361
362 if (m_nScriptSize) {
363 buf = "<MacScript ScriptCode=\"" + std::to_string(m_nScriptCode) + "\">";
364 xml += blanks + buf;
365
366 std::stringstream ss;
367 for (int i = 0; i < m_nScriptSize; i++) {
368 ss << std::hex << std::uppercase << std::setw(2) << std::setfill('0')
369 << static_cast<int>(static_cast<unsigned char>(m_szScriptText[i]));
370 }
371 buf = ss.str();
372
373 xml += buf;
374 xml += "</MacScript>\n";
375 }
376
377 return true;
378}
static bool icXmlDumpTextData(std::string &xml, std::string blanks, const char *szText, bool bConvert=true)
const icChar * icGetSigStr(icChar *pBuf, icUInt32Number nSig)
Definition IccUtil.cpp:1056
const char * icUtf16ToUtf8(std::string &buf, const icUInt16Number *szSrc, int sizeSrc)
const char * icFixXml(std::string &buf, const char *szStr)
icUInt32Number m_nUnicodeLanguageCode

References icFixXml(), icGetSigStr(), icUtf16ToUtf8(), and icXmlDumpTextData().

+ Here is the call graph for this function:

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