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

Class: CIccTagZipUtf8Text() More...

#include <IccTagBasic.h>

+ Inheritance diagram for CIccTagZipUtf8Text:
+ Collaboration diagram for CIccTagZipUtf8Text:

Public Member Functions

icUCharAllocBuffer (icUInt32Number nSize)
 Name: CIccTagZipUtf8Text::AllocBuffer.
 
icUInt32Number BufferSize () const
 
 CIccTagZipUtf8Text ()
 Name: CIccTagZipUtf8Text::CIccTagZipUtf8Text.
 
 CIccTagZipUtf8Text (const CIccTagZipUtf8Text &ITT)
 Name: CIccTagZipUtf8Text::CIccTagZipUtf8Text.
 
virtual void Describe (std::string &sDescription, int nVerboseness)
 Name: CIccTagZipUtf8Text::Describe.
 
icUCharGetBuffer () const
 
virtual const icCharGetClassName () const
 
virtual bool GetText (std::string &str) const
 Name: CIccTagZipUtf8Text::GetText.
 
virtual icTagTypeSignature GetType () const
 Function: GetType()
 
virtual CIccTagNewCopy () const
 Function: NewCopy(sDescription) Each derived tag will implement it's own NewCopy() function.
 
CIccTagZipUtf8Textoperator= (const CIccTagZipUtf8Text &TextTag)
 Name: CIccTagZipUtf8Text::operator=.
 
virtual bool Read (icUInt32Number size, CIccIO *pIO)
 Name: CIccTagZipUtf8Text::Read.
 
bool SetText (const icChar *szText)
 
virtual bool SetText (const icUChar *szText)
 Name: CIccTagZipUtf8Text::SetText.
 
bool SetText (const icUChar16 *szText)
 Name: CIccTagZipUtf8Text::SetText.
 
virtual icValidateStatus Validate (std::string sigPath, std::string &sReport, const CIccProfile *pProfile=NULL) const
 Name: CIccTagZipUtf8Text::Validate.
 
virtual bool Write (CIccIO *pIO)
 Name: CIccTagZipUtf8Text::Write.
 
virtual ~CIccTagZipUtf8Text ()
 Name: CIccTagZipUtf8Text::~CIccTagZipUtf8Text.
 
- 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
 
icUCharm_pZipBuf
 

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: CIccTagZipUtf8Text()

Purpose: The zipUtf8TextType ICC tag maintains compressed text data. Calls to GetText will uncompress, and SetText will compress. These functions may fail if macro ICC_USE_ZLIB is not defined.

Definition at line 366 of file IccTagBasic.h.

Constructor & Destructor Documentation

◆ CIccTagZipUtf8Text() [1/2]

CIccTagZipUtf8Text::CIccTagZipUtf8Text ( )

Name: CIccTagZipUtf8Text::CIccTagZipUtf8Text.

Purpose: Constructor

Definition at line 1050 of file IccTagBasic.cpp.

1051{
1052 m_pZipBuf = NULL;
1053 m_nBufSize = 0;
1054}
icUInt32Number m_nBufSize

◆ ~CIccTagZipUtf8Text()

CIccTagZipUtf8Text::~CIccTagZipUtf8Text ( )
virtual

Name: CIccTagZipUtf8Text::~CIccTagZipUtf8Text.

Purpose: Destructor

Definition at line 1107 of file IccTagBasic.cpp.

1108{
1109 if (m_pZipBuf)
1110 free(m_pZipBuf);
1111}

◆ CIccTagZipUtf8Text() [2/2]

CIccTagZipUtf8Text::CIccTagZipUtf8Text ( const CIccTagZipUtf8Text & ITT)

Name: CIccTagZipUtf8Text::CIccTagZipUtf8Text.

Purpose: Copy Constructor

Args: ITT = The CIccTagText object to be copied

Definition at line 1066 of file IccTagBasic.cpp.

1067{
1068 m_pZipBuf = NULL;
1069 m_nBufSize = 0;
1070 AllocBuffer(ITT.BufferSize());
1071 if (m_pZipBuf) {
1072 memcpy(m_pZipBuf, ITT.GetBuffer(), m_nBufSize);
1073 }
1074}
icUInt32Number BufferSize() const
icUChar * GetBuffer() const
icUChar * AllocBuffer(icUInt32Number nSize)
Name: CIccTagZipUtf8Text::AllocBuffer.

References BufferSize(), and GetBuffer().

+ Here is the call graph for this function:

Member Function Documentation

◆ AllocBuffer()

icUChar * CIccTagZipUtf8Text::AllocBuffer ( icUInt32Number nSize)

Name: CIccTagZipUtf8Text::AllocBuffer.

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 1410 of file IccTagBasic.cpp.

1411{
1412 if (m_nBufSize != nSize) {
1413 if (!nSize) {
1414 if (m_pZipBuf)
1415 free(m_pZipBuf);
1416
1417 m_nBufSize = nSize;
1418 return NULL;
1419 }
1420
1421 if (!m_nBufSize)
1422 m_pZipBuf = (icUChar*)malloc(nSize);
1423 else
1425
1426 m_nBufSize = nSize;
1427
1428 }
1429
1430 return m_pZipBuf;
1431}
unsigned char icUChar
Definition IccDefs.h:110
void * icRealloc(void *ptr, size_t size)
Name: icRealloc.
Definition IccUtil.cpp:111

References icRealloc().

+ Here is the call graph for this function:

◆ BufferSize()

icUInt32Number CIccTagZipUtf8Text::BufferSize ( ) const
inline

Definition at line 396 of file IccTagBasic.h.

396{ return m_nBufSize; }

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

+ Here is the caller graph for this function:

◆ Describe()

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

Name: CIccTagZipUtf8Text::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 1198 of file IccTagBasic.cpp.

1199{
1200 std::string str;
1201#ifdef ICC_USE_ZLIB
1202 if (!GetText(str)) {
1203 sDescription += "Error! - Unable to decompress text data.\n";
1204 }
1205 else if (m_nBufSize > 4 && !memcmp(m_pZipBuf, icFaultyXmlZipData, 4)) {
1206 sDescription += "Warning! - Correcting for improperly encoded ";
1207 sDescription += CIccTagCreator::GetTagTypeSigName(GetType());
1208 sDescription += " tag.\n\n";
1209 }
1210
1211 sDescription += "ZLib Compressed String=\"";
1212 sDescription += str;
1213 sDescription += "\"\n";
1214#else
1215 char size[30];
1216 sprintf(size, "%d", m_nBufSize);
1217 sDescription += "BEGIN_COMPESSED_DATA[\"";
1218 sDescription += size;
1219 sDescription += "]\n";
1220 if (m_nBufSize) {
1222 sDescription += str;
1223 sDescription += "\n";
1224 }
1225 sDescription += "END_COMPRESSED_DATA\n";
1226#endif
1227}
static unsigned char icFaultyXmlZipData[4]
void icMemDump(std::string &sDump, void *pBuf, icUInt32Number nNum)
Definition IccUtil.cpp:951
static const icChar * GetTagTypeSigName(icTagTypeSignature tagTypeSig)
Function: GetTagTypeSigName(tagTypeSig) Get display name of tagTypeSig.
virtual bool GetText(std::string &str) const
Name: CIccTagZipUtf8Text::GetText.
virtual icTagTypeSignature GetType() const
Function: GetType()

References CIccTagCreator::GetTagTypeSigName(), icFaultyXmlZipData, and icMemDump().

+ Here is the call graph for this function:

◆ GetBuffer()

icUChar * CIccTagZipUtf8Text::GetBuffer ( ) const
inline

Definition at line 395 of file IccTagBasic.h.

395{ return m_pZipBuf; }

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

+ Here is the caller graph for this function:

◆ GetClassName()

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

Reimplemented from CIccTag.

Reimplemented in CIccTagXmlZipUtf8Text, CIccTagXmlZipXml, and CIccTagZipXml.

Definition at line 376 of file IccTagBasic.h.

376{ return "CIccZipUtf8TagText"; }

◆ GetText()

bool CIccTagZipUtf8Text::GetText ( std::string & str) const
virtual

Name: CIccTagZipUtf8Text::GetText.

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

Args: text - string to put uncompressed text into

Definition at line 1239 of file IccTagBasic.cpp.

1240{
1241#ifndef ICC_USE_ZLIB
1242 str="";
1243 return false;
1244#else
1245 int zstat;
1246 z_stream zstr;
1247 memset(&zstr, 0, sizeof(zstr));
1248 unsigned char buf[32767] = { 0 };
1249
1250 zstat = inflateInit(&zstr);
1251
1252 if (zstat != Z_OK) {
1253 return false;
1254 }
1255
1256 zstat = inflateReset(&zstr);
1257
1258 if (zstat != Z_OK) {
1259 return false;
1260 }
1261
1262 if (m_nBufSize > 4 && !memcmp(m_pZipBuf, icFaultyXmlZipData, 4)) {
1263 //xrite creates invalid zipXMLType tags
1264 zstr.next_in = m_pZipBuf+4;
1265 zstr.avail_in = m_nBufSize-4;
1266 }
1267 else {
1268 zstr.next_in = m_pZipBuf;
1269 zstr.avail_in = m_nBufSize;
1270 }
1271
1272 do {
1273 unsigned int i, n;
1274
1275 zstr.next_out = buf;
1276 zstr.avail_out = sizeof(buf);
1277
1278 zstat = inflate(&zstr, Z_SYNC_FLUSH);
1279
1280 if (zstat != Z_OK && zstat != Z_STREAM_END) {
1281 inflateEnd(&zstr);
1282 return false;
1283 }
1284
1285 n = sizeof(buf) - zstr.avail_out;
1286
1287 for (i = 0; i < n; i++) {
1288 str += buf[i];
1289 }
1290 } while (zstat != Z_STREAM_END);
1291
1292 inflateEnd(&zstr);
1293
1294 return true;
1295#endif
1296}

References icFaultyXmlZipData.

Referenced by icGetTagText().

+ Here is the caller graph for this function:

◆ GetType()

virtual icTagTypeSignature CIccTagZipUtf8Text::GetType ( ) const
inlinevirtual

Function: GetType()

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

Reimplemented from CIccTag.

Reimplemented in CIccTagZipXml.

Definition at line 375 of file IccTagBasic.h.

375{ return icSigZipUtf8TextType; }
@ icSigZipUtf8TextType

References icSigZipUtf8TextType.

◆ NewCopy()

virtual CIccTag * CIccTagZipUtf8Text::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 CIccTagXmlZipUtf8Text, CIccTagXmlZipXml, and CIccTagZipXml.

Definition at line 373 of file IccTagBasic.h.

373{return new CIccTagZipUtf8Text(*this);}
CIccTagZipUtf8Text()
Name: CIccTagZipUtf8Text::CIccTagZipUtf8Text.

◆ operator=()

CIccTagZipUtf8Text & CIccTagZipUtf8Text::operator= ( const CIccTagZipUtf8Text & ITT)

Name: CIccTagZipUtf8Text::operator=.

Purpose: Copy Operator

Args: TextTag = The CIccTagText object to be copied

Definition at line 1086 of file IccTagBasic.cpp.

1087{
1088 if (&ITT == this)
1089 return *this;
1090
1091 AllocBuffer(ITT.BufferSize());
1092 if (m_pZipBuf) {
1093 memcpy(m_pZipBuf, ITT.GetBuffer(), m_nBufSize);
1094 }
1095
1096 return *this;
1097}

References BufferSize(), and GetBuffer().

Referenced by CIccTagZipXml::operator=().

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

◆ Read()

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

Name: CIccTagZipUtf8Text::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 1127 of file IccTagBasic.cpp.

1128{
1130
1131 if (size<sizeof(icTagTypeSignature) || !pIO) {
1132 AllocBuffer(0);
1133 return false;
1134 }
1135
1136 if (!pIO->Read32(&sig))
1137 return false;
1138
1139 if (!pIO->Read32(&m_nReserved))
1140 return false;
1141
1142 icUInt32Number nSize = size - sizeof(icTagTypeSignature) - sizeof(icUInt32Number);
1143
1144 icUChar *pBuf = AllocBuffer(nSize);
1145
1146 if (m_nBufSize && pBuf) {
1147 if (pIO->Read8(pBuf, m_nBufSize) != (icInt32Number)m_nBufSize) {
1148 return false;
1149 }
1150 }
1151
1152 return true;
1153}
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
long icInt32Number

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

+ Here is the call graph for this function:

◆ SetText() [1/3]

bool CIccTagZipUtf8Text::SetText ( const icChar * szText)
inline

Definition at line 384 of file IccTagBasic.h.

384{ return SetText((icUChar*)szText); }
bool SetText(const icUChar16 *szText)
Name: CIccTagZipUtf8Text::SetText.

References SetText().

Referenced by SetText().

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

◆ SetText() [2/3]

bool CIccTagZipUtf8Text::SetText ( const icUChar * szText)
virtual

Name: CIccTagZipUtf8Text::SetText.

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

Args: szText - zero terminated string to put in tag

Definition at line 1309 of file IccTagBasic.cpp.

1310{
1311#ifndef ICC_USE_ZLIB
1312 return false;
1313#else
1314 icUInt32Number nSize = (icUInt32Number)strlen((const char*)szText) + 1;
1315 icUtf8Vector compress;
1316 int i;
1317
1318 int zstat;
1319 z_stream zstr;
1320 unsigned char buf[32767];
1321 memset(&zstr, 0, sizeof(zstr));
1322
1323 zstat = deflateInit(&zstr, Z_DEFAULT_COMPRESSION);
1324
1325 if (zstat != Z_OK) {
1326 return false;
1327 }
1328
1329 zstat = deflateReset(&zstr);
1330 zstr.next_in = (Bytef*)szText;
1331 zstr.avail_in = nSize;
1332
1333 if (zstat != Z_OK) {
1334 return false;
1335 }
1336
1337
1338 do {
1339 int n;
1340 zstr.next_out = buf;
1341 zstr.avail_out = sizeof(buf);
1342
1343 zstat = deflate(&zstr, Z_FINISH);
1344
1345 if (zstat != Z_OK && zstat != Z_STREAM_END) {
1346 deflateEnd(&zstr);
1347 return false;
1348 }
1349
1350 n = sizeof(buf) - zstr.avail_out;
1351
1352 for (i = 0; i < n; i++) {
1353 compress.push_back(buf[i]);
1354 }
1355 } while (zstat != Z_STREAM_END);
1356
1357 deflateEnd(&zstr);
1358
1359 icUChar *pBuf = AllocBuffer((icUInt32Number)compress.size());
1360
1361 if (pBuf) {
1362 for (i = 0; i < (int)m_nBufSize; i++) {
1363 pBuf[i] = compress[i];
1364}
1365 }
1366
1367 return true;
1368#endif
1369}

◆ SetText() [3/3]

bool CIccTagZipUtf8Text::SetText ( const icUChar16 * szText)

Name: CIccTagZipUtf8Text::SetText.

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

Args: szText - zero terminated string to put in tag

Definition at line 1381 of file IccTagBasic.cpp.

1382{
1383 if (!szText)
1384 return SetText("");
1385
1386 icUtf8Vector text;
1387 icUInt32Number len;
1388 for (len=0; szText[len]; len++);
1389
1390 icConvertUTF16toUTF8(szText, &szText[len], text, lenientConversion);
1391
1392 return SetText((const icUChar*)&text[0]);
1393}
icUtfConversionResult icConvertUTF16toUTF8(const UTF16 **sourceStart, const UTF16 *sourceEnd, UTF8 **targetStart, UTF8 *targetEnd, icUtfConversionFlags flags)
@ lenientConversion

References icConvertUTF16toUTF8(), and lenientConversion.

+ Here is the call graph for this function:

◆ Validate()

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

Name: CIccTagZipUtf8Text::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 1448 of file IccTagBasic.cpp.

1449{
1450 icValidateStatus rv = CIccTag::Validate(sigPath, sReport, pProfile);
1451
1452 CIccInfo Info;
1453 std::string sSigPathName = Info.GetSigPathName(sigPath);
1454
1455 if (!m_nBufSize) {
1456 sReport += icMsgValidateWarning;
1457 sReport += sSigPathName;
1458 sReport += " - Empty Tag.\n";
1460 }
1461 else {
1462#ifdef ICC_USE_ZLIB
1463 std::string sText;
1464 if (!GetText(sText)) {
1465 sReport += icMsgValidateNonCompliant;
1466 sReport += sSigPathName;
1467 sReport += " - Unable to get text for tag (possibly corrupt compressed data).\n";
1469 }
1470 else if (m_nBufSize > 4 && !memcmp(m_pZipBuf, icFaultyXmlZipData, 4)) {
1471 sReport += icMsgValidateNonCompliant;
1472 sReport += sSigPathName;
1473 sReport += " - Improperly encoded ";
1475 sReport += " tag.\n";
1477 }
1478#else
1479 sReport += icMsgValidateWarning;
1480 sReport += sSigPathName;
1481 sReport += " - Zip compression not supported by CMM - unable to validate text compression.\n";
1483#endif
1484 }
1485
1486 return rv;
1487}
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
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.

References CIccInfo::GetSigPathName(), CIccTagCreator::GetTagTypeSigName(), icFaultyXmlZipData, icMaxStatus(), icMsgValidateNonCompliant, icMsgValidateWarning, icValidateNonCompliant, icValidateWarning, and CIccTag::Validate().

+ Here is the call graph for this function:

◆ Write()

bool CIccTagZipUtf8Text::Write ( CIccIO * pIO)
virtual

Name: CIccTagZipUtf8Text::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 1168 of file IccTagBasic.cpp.

1169{
1171
1172 if (!pIO)
1173 return false;
1174
1175 if (!pIO->Write32(&sig))
1176 return false;
1177
1178 if (!pIO->Write32(&m_nReserved))
1179 return false;
1180
1181 if (m_pZipBuf) {
1183 return false;
1184 }
1185 return true;
1186}
virtual icInt32Number Write8(void *pBuf8, icInt32Number nNum=1)
Definition IccIO.h:105
icInt32Number Write32(void *pBuf32, icInt32Number nNum=1)
Definition IccIO.cpp:152

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

+ Here is the call graph for this function:

Member Data Documentation

◆ m_nBufSize

icUInt32Number CIccTagZipUtf8Text::m_nBufSize
protected

Definition at line 401 of file IccTagBasic.h.

◆ m_pZipBuf

icUChar* CIccTagZipUtf8Text::m_pZipBuf
protected

Definition at line 400 of file IccTagBasic.h.


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