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

Class: CIccTagText() More...

#include <IccTagBasic.h>

+ Inheritance diagram for CIccTagText:
+ Collaboration diagram for CIccTagText:

Public Member Functions

icUInt32Number Capacity () const
 
 CIccTagText ()
 Name: CIccTagText::CIccTagText.
 
 CIccTagText (const CIccTagText &ITT)
 Name: CIccTagText::CIccTagText.
 
virtual void Describe (std::string &sDescription, int nVerboseness)
 Name: CIccTagText::Describe.
 
icCharGetBuffer (icUInt32Number nSize)
 Name: CIccTagText::GetBuffer.
 
virtual const icCharGetClassName () const
 
const icCharGetText () const
 
virtual icTagTypeSignature GetType () const
 Function: GetType()
 
virtual CIccTagNewCopy () const
 Function: NewCopy(sDescription) Each derived tag will implement it's own NewCopy() function.
 
CIccTagTextoperator= (const CIccTagText &TextTag)
 Name: CIccTagText::operator=.
 
const icCharoperator= (const icChar *szText)
 Name: *CIccTagTextoperator=.
 
virtual bool Read (icUInt32Number size, CIccIO *pIO)
 Name: CIccTagText::Read.
 
void Release ()
 Name: CIccTagText::Release.
 
void SetText (const icChar *szText)
 Name: CIccTagText::SetText.
 
virtual icValidateStatus Validate (std::string sigPath, std::string &sReport, const CIccProfile *pProfile=NULL) const
 Name: CIccTagText::Validate.
 
virtual bool Write (CIccIO *pIO)
 Name: CIccTagText::Write.
 
virtual ~CIccTagText ()
 Name: CIccTagText::~CIccTagText.
 
- Public Member Functions inherited from CIccTag
 CIccTag ()
 Name: CIccTag::CIccTag.
 
virtual void DetachIO ()
 Function: ReadAll() - Read All sub data for tag from file.
 
virtual IIccExtensionTagGetExtension ()
 
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.
 

Protected Attributes

icUInt32Number m_nBufSize
 
icCharm_szText
 

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
 

Detailed Description

Class: CIccTagText()

Purpose: The textType ICC tag

Definition at line 283 of file IccTagBasic.h.

Constructor & Destructor Documentation

◆ CIccTagText() [1/2]

CIccTagText::CIccTagText ( )

Name: CIccTagText::CIccTagText.

Purpose: Constructor

Definition at line 363 of file IccTagBasic.cpp.

364{
365 m_szText = (icChar*)malloc(1);
366 m_szText[0] = '\0';
367 m_nBufSize = 1;
368}
char icChar
Definition IccDefs.h:109
icUInt32Number m_nBufSize
icChar * m_szText

◆ CIccTagText() [2/2]

CIccTagText::CIccTagText ( const CIccTagText & ITT)

Name: CIccTagText::CIccTagText.

Purpose: Copy Constructor

Args: ITT = The CIccTagText object to be copied

Definition at line 380 of file IccTagBasic.cpp.

381{
382 m_szText = (icChar*)malloc(1);
383 m_szText[0] = '\0';
384 m_nBufSize = 1;
385 SetText(ITT.m_szText);
386}
void SetText(const icChar *szText)
Name: CIccTagText::SetText.

References m_szText.

◆ ~CIccTagText()

CIccTagText::~CIccTagText ( )
virtual

Name: CIccTagText::~CIccTagText.

Purpose: Destructor

Definition at line 419 of file IccTagBasic.cpp.

420{
421 free(m_szText);
422}

Member Function Documentation

◆ Capacity()

icUInt32Number CIccTagText::Capacity ( ) const
inline

Definition at line 306 of file IccTagBasic.h.

306{ return m_nBufSize; }

◆ Describe()

void CIccTagText::Describe ( std::string & sDescription,
int nVerboseness )
virtual

Name: CIccTagText::Describe.

Purpose: Dump data associated with the tag to a string

Args: sDescription - string to concatenate tag dump to

Reimplemented from CIccTag.

Definition at line 516 of file IccTagBasic.cpp.

517{
518 sDescription += "Text Length = ";
519 if (m_szText && *m_szText) {
520 char buf[40];
521 sprintf(buf, "%zu bytes\n", strlen(m_szText));
522 sDescription += buf;
523 } else
524 sDescription += "0 (NULL)";
525
526 if (nVerboseness > 25) {
527 sDescription += "\"";
528 if (m_szText && *m_szText) {
529 if ((nVerboseness > 50) || (strlen(m_szText) < BRIEF_STRING_SIZE)) {
530 // output entire string if short or doing verbose
531 sDescription += m_szText;
532 }
533 else {
534 // copy just first part of string to keep nVerboseness under control
535 char buf[BRIEF_STRING_SIZE + 1];
536 strncpy(buf, m_szText, BRIEF_STRING_SIZE);
537 buf[BRIEF_STRING_SIZE] = '\0'; // ensure NULL termination
538 sDescription += buf;
539 sDescription += "\n... <!truncated!>";
540 }
541 }
542 sDescription += "\"\n";
543 }
544}
#define BRIEF_STRING_SIZE

References BRIEF_STRING_SIZE.

◆ GetBuffer()

icChar * CIccTagText::GetBuffer ( icUInt32Number nSize)

Name: CIccTagText::GetBuffer.

Purpose: This function allocates room and returns pointer to data buffer to put string into

Args: nSize = Requested size of data buffer.

Return: The character buffer array

Definition at line 600 of file IccTagBasic.cpp.

601{
602 if (m_nBufSize < nSize) {
603 m_szText = (icChar*)icRealloc(m_szText, nSize+1);
604
605 if (m_szText) {
606 m_szText[nSize] = '\0';
607 m_nBufSize = nSize;
608 }
609 else
610 m_nBufSize = 0;
611 }
612
613 return m_szText;
614}
void * icRealloc(void *ptr, size_t size)
Name: icRealloc.
Definition IccUtil.cpp:111

References icRealloc().

+ Here is the call graph for this function:

◆ GetClassName()

virtual const icChar * CIccTagText::GetClassName ( ) const
inlinevirtual

Reimplemented from CIccTag.

Reimplemented in CIccTagXmlText.

Definition at line 293 of file IccTagBasic.h.

293{ return "CIccTagText"; }

◆ GetText()

const icChar * CIccTagText::GetText ( ) const
inline

Definition at line 300 of file IccTagBasic.h.

300{ return m_szText; }

Referenced by CIccProfileIdDesc::CIccProfileIdDesc(), and icGetTagText().

+ Here is the caller graph for this function:

◆ GetType()

virtual icTagTypeSignature CIccTagText::GetType ( ) const
inlinevirtual

Function: GetType()

Purpose: Get Tag Type. Each derived tag will implement it's own GetType() function.

Reimplemented from CIccTag.

Definition at line 292 of file IccTagBasic.h.

292{ return icSigTextType; }
@ icSigTextType

References icSigTextType.

◆ NewCopy()

virtual CIccTag * CIccTagText::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 CIccTag.

Reimplemented in CIccTagXmlText.

Definition at line 289 of file IccTagBasic.h.

289{return new CIccTagText(*this);}
CIccTagText()
Name: CIccTagText::CIccTagText.

◆ operator=() [1/2]

CIccTagText & CIccTagText::operator= ( const CIccTagText & TextTag)

Name: CIccTagText::operator=.

Purpose: Copy Operator

Args: TextTag = The CIccTagText object to be copied

Definition at line 398 of file IccTagBasic.cpp.

399{
400 if (&TextTag == this)
401 return *this;
402
403 m_szText = (icChar*)malloc(1);
404 m_szText[0] = '\0';
405 m_nBufSize = 1;
406 SetText(TextTag.m_szText);
407
408 return *this;
409}

References m_szText.

◆ operator=() [2/2]

const icChar * CIccTagText::operator= ( const icChar * szText)

Name: *CIccTagTextoperator=.

Purpose: Define assignment operator to associate text with tag.

Args: szText - zero terminated string to put in the tag

Return: A pointer to the string assigned to the tag.

Definition at line 581 of file IccTagBasic.cpp.

582{
583 SetText(szText);
584 return m_szText;
585}

◆ Read()

bool CIccTagText::Read ( icUInt32Number size,
CIccIO * pIO )
virtual

Name: CIccTagText::Read.

Purpose: Read in a text type tag into a data block

Args: size - # of bytes in tag, pIO - IO object to read tag from

Return: true = successful, false = failure

Reimplemented from CIccTag.

Definition at line 438 of file IccTagBasic.cpp.

439{
441
442 // Defensive: initialize so error paths all have valid m_szText
443 m_szText[0] = '\0';
444
445 if (size < (sizeof(icTagTypeSignature) + sizeof(icUInt32Number)) || !pIO)
446 return false;
447
448 if (!pIO->Read32(&sig))
449 return false;
450
451 if (!pIO->Read32(&m_nReserved))
452 return false;
453
454 icUInt32Number nSize = size - sizeof(icTagTypeSignature) - sizeof(icUInt32Number);
455
456 icChar *pBuf = GetBuffer(nSize);
457
458 if (nSize) {
459 if (pIO->Read8(pBuf, nSize) != (icInt32Number)nSize) {
460 return false;
461 }
462 }
463
464 Release();
465
466 return true;
467}
icArraySignature sig
icTagTypeSignature
unsigned int icUInt32Number
virtual icInt32Number Read8(void *pBuf8, icInt32Number nNum=1)
Definition IccIO.h:104
icInt32Number Read32(void *pBuf32, icInt32Number nNum=1)
Definition IccIO.cpp:143
icUInt32Number m_nReserved
icChar * GetBuffer(icUInt32Number nSize)
Name: CIccTagText::GetBuffer.
void Release()
Name: CIccTagText::Release.
long icInt32Number

References CIccIO::Read32(), CIccIO::Read8(), and sig.

+ Here is the call graph for this function:

◆ Release()

void CIccTagText::Release ( )

Name: CIccTagText::Release.

Purpose: This will resize the buffer to fit the zero terminated string in the buffer.

Definition at line 624 of file IccTagBasic.cpp.

625{
626 icUInt32Number nSize = (icUInt32Number)strlen(m_szText)+1;
627
628 if (nSize < m_nBufSize-1) {
629 m_szText=(icChar*)icRealloc(m_szText, nSize+1);
630 m_nBufSize = nSize+1;
631 }
632}

References icRealloc().

+ Here is the call graph for this function:

◆ SetText()

void CIccTagText::SetText ( const icChar * szText)

Name: CIccTagText::SetText.

Purpose: Allows text data associated with the tag to be set.

Args: szText - zero terminated string to put in tag

Definition at line 557 of file IccTagBasic.cpp.

558{
559 if (!szText)
560 SetText("");
561
562 icUInt32Number len=(icUInt32Number)strlen(szText) + 1;
563 icChar *szBuf = GetBuffer(len);
564
565 strcpy(szBuf, szText);
566 Release();
567}

◆ Validate()

icValidateStatus CIccTagText::Validate ( std::string sigPath,
std::string & sReport,
const CIccProfile * pProfile = NULL ) const
virtual

Name: CIccTagText::Validate.

Purpose: Check tag data validity.

Args: sig = signature of tag being validated, sReport = String to add report information to

Return: icValidateStatusOK if valid, or other error status.

Reimplemented from CIccTag.

Definition at line 649 of file IccTagBasic.cpp.

650{
651 icValidateStatus rv = CIccTag::Validate(sigPath, sReport, pProfile);
652
653 CIccInfo Info;
654 std::string sSigPathName = Info.GetSigPathName(sigPath);
656
657 if (m_nBufSize) {
658 switch(sig) {
660 break;
662 if (m_nBufSize<7) {
663 sReport += icMsgValidateNonCompliant;
664 sReport += sSigPathName;
665 sReport += " - Tag must have at least seven text characters.\n";
667 }
668 break;
669 default:
670 sReport += icMsgValidateWarning;
671 sReport += sSigPathName;
672 sReport += " - Unknown Tag.\n";
674 }
675 int i;
676 for (i=0; m_szText[i] && i<(int)m_nBufSize; i++) {
677 if (m_szText[i]&0x80) {
678 sReport += icMsgValidateWarning;
679 sReport += sSigPathName;
680 sReport += " - Text does not contain just 7-bit data.\n";
682 }
683 }
684 }
685 else {
686 sReport += icMsgValidateWarning;
687 sReport += sSigPathName;
688 sReport += " - Empty Tag.\n";
690 }
691
692
693 return rv;
694}
icValidateStatus
Definition IccDefs.h:118
@ icValidateWarning
Definition IccDefs.h:120
@ icValidateNonCompliant
Definition IccDefs.h:121
icValidateStatus icMaxStatus(icValidateStatus s1, icValidateStatus s2)
Name: icMaxStatus.
Definition IccUtil.cpp:244
const char * icMsgValidateWarning
Definition IccUtil.cpp:90
const char * icMsgValidateNonCompliant
Definition IccUtil.cpp:91
icSignature icGetFirstSigPathSig(std::string sigPath)
Definition IccUtil.cpp:1201
Type: Class.
Definition IccUtil.h:303
std::string GetSigPathName(std::string sigPath)
Definition IccUtil.cpp:1614
virtual icValidateStatus Validate(std::string sigPath, std::string &sReport, const CIccProfile *pProfile=NULL) const
Function: Validate Each derived tag will implement it's own IsValid() function.
icUInt32Number icSignature
@ icSigCharTargetTag
@ icSigCopyrightTag

References CIccInfo::GetSigPathName(), icGetFirstSigPathSig(), icMaxStatus(), icMsgValidateNonCompliant, icMsgValidateWarning, icSigCharTargetTag, icSigCopyrightTag, icValidateNonCompliant, icValidateWarning, sig, and CIccTag::Validate().

+ Here is the call graph for this function:

◆ Write()

bool CIccTagText::Write ( CIccIO * pIO)
virtual

Name: CIccTagText::Write.

Purpose: Write a text type tag to a file

Args: pIO - The IO object to write tag to.

Return: true = succesful, false = failure

Reimplemented from CIccTag.

Definition at line 482 of file IccTagBasic.cpp.

483{
485
486 if (!pIO)
487 return false;
488
489 if (!pIO->Write32(&sig))
490 return false;
491
492 if (!pIO->Write32(&m_nReserved))
493 return false;
494
495 if (!m_szText)
496 return false;
497
498 icUInt32Number nSize = (icUInt32Number)strlen(m_szText)+1;
499
500 if (pIO->Write8(m_szText, nSize) != (icInt32Number)nSize)
501 return false;
502
503 return true;
504}
virtual icInt32Number Write8(void *pBuf8, icInt32Number nNum=1)
Definition IccIO.h:105
icInt32Number Write32(void *pBuf32, icInt32Number nNum=1)
Definition IccIO.cpp:152
virtual icTagTypeSignature GetType() const
Function: GetType()

References sig, CIccIO::Write32(), and CIccIO::Write8().

+ Here is the call graph for this function:

Member Data Documentation

◆ m_nBufSize

icUInt32Number CIccTagText::m_nBufSize
protected

Definition at line 311 of file IccTagBasic.h.

◆ m_szText

icChar* CIccTagText::m_szText
protected

Definition at line 310 of file IccTagBasic.h.

Referenced by CIccTagText(), and operator=().


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