Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
IccUtilXml.h
Go to the documentation of this file.
1/** @file
2 File: IccUtilXml.cpp
3
4 Contains: Implementation of Utilities used for ICC/XML processing
5
6 Version: V1
7
8 Copyright: (c) see ICC Software License
9*/
10
11/*
12 * The ICC Software License, Version 0.2
13 *
14 *
15 * Copyright (c) 2003-2012 The International Color Consortium. All rights
16 * reserved.
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
20 * are met:
21 *
22 * 1. Redistributions of source code must retain the above copyright
23 * notice, this list of conditions and the following disclaimer.
24 *
25 * 2. Redistributions in binary form must reproduce the above copyright
26 * notice, this list of conditions and the following disclaimer in
27 * the documentation and/or other materials provided with the
28 * distribution.
29 *
30 * 3. In the absence of prior written permission, the names "ICC" and "The
31 * International Color Consortium" must not be used to imply that the
32 * ICC organization endorses or promotes products derived from this
33 * software.
34 *
35 *
36 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39 * DISCLAIMED. IN NO EVENT SHALL THE INTERNATIONAL COLOR CONSORTIUM OR
40 * ITS CONTRIBUTING MEMBERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47 * SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This software consists of voluntary contributions made by many
51 * individuals on behalf of the The International Color Consortium.
52 *
53 *
54 * Membership in the ICC is encouraged when this software is used for
55 * commercial purposes.
56 *
57 *
58 * For more information on The International Color Consortium, please
59 * see <http://www.color.org/>.
60 *
61 *
62 */
63
64#ifndef _ICCUTILXML_H
65#define _ICCUTILXML_H
66
67#include "IccUtil.h"
68#include "IccTag.h"
69#include "IccXmlConfig.h"
70#include "libxml/parser.h"
71#include <vector>
72#include <string>
73
75{
76public:
78 CIccUTF16String(const icUInt16Number *uzStr);
79 CIccUTF16String(const char *szStr);
81 virtual ~CIccUTF16String();
82
83 void Clear();
84 size_t Size() { return m_len; }
85 bool Resize(size_t len);
86
88 CIccUTF16String& operator=(const char *szStr);
90
91 icUInt16Number operator[](size_t m_nIndex) { return m_str[m_nIndex]; }
92
93 const icUInt16Number *c_str() { return m_str; }
94
95 bool FromUtf8(const char *szStr, size_t sizeSrc=0);
96 const char *ToUtf8(std::string &buf);
97 const wchar_t *ToWString(std::wstring &buf);
98
99 static size_t WStrlen(const icUInt16Number *uzStr);
100
101protected:
102 static size_t AllocSize(size_t n) { return (((n+64)/64)*64); }
103 size_t m_alloc;
104 size_t m_len;
106};
107
108
109const char *icFixXml(char *szDest, const char *szStr);
110const char *icFixXml(std::string &buf, const char *szStr);
111const char *icAnsiToUtf8(std::string &buf, const char *szSrc);
112const char *icUtf8ToAnsi(std::string &buf, const char *szSrc);
113
114const char *icUtf16ToUtf8(std::string &buf, const icUInt16Number *szSrc, int sizeSrc=0);
115const unsigned short *icUtf8ToUtf16(CIccUTF16String &buf, const char *szSrc, int sizeSrc=0);
116
117bool icCLUTDataToXml(std::string &xml, CIccCLUT *pCLUT, icConvertType nType, std::string blanks,
118 bool bSaveGridPoints=false);
119bool icCLUTToXml(std::string &xml, CIccCLUT *pCLUT, icConvertType nType, std::string blanks,
120 bool bSaveGridPoints=false, const char *szExtraAttrs="", const char *szName="CLUT");
121icFloatNumber icXmlStrToFloat(const xmlChar *szStr);
122icSignature icXmlStrToSig(const char *szStr);
123const char *icXmlAttrValue(xmlAttr *attr, const char *szDefault="");
124const char *icXmlAttrValue(xmlNode *pNode, const char *szName, const char *szDefault="");
125
126icUInt32Number icXmlGetChildSigVal(xmlNode *pNode);
127
128icUInt32Number icXmlGetHexData(void *pBuf, const char *szText, icUInt32Number nBufSize);
129
130icUInt32Number icXmlGetHexDataSize(const char *szText);
131
132icUInt32Number icXmlDumpHexData(std::string &xml, std::string blanks, void *pBuf, icUInt32Number nBufSize);
133
134#define icXmlStrCmp(x, y) strcmp((const char *)(x), (const char*)(y))
135
136xmlAttr *icXmlFindAttr(xmlNode *pNode, const char *szAttrName);
137xmlNode *icXmlFindNode(xmlNode *pNode, const char *szNodeName);
138
139icUInt32Number icXmlNodeCount(xmlNode *pNode, const char *szNodeName);
140icUInt32Number icXmlNodeCount2(xmlNode *pNode, const char *szNodeName1, const char *szNodeName2);
141icUInt32Number icXmlNodeCount3(xmlNode *pNode, const char *szNodeName1, const char *szNodeName2, const char *szNodeName3);
142
143template <class T, icTagTypeSignature Tsig>
145{
146public:
149
150 static bool DumpArray(std::string &xml, std::string blanks, T *buf, icUInt32Number nBufSize,
151 icConvertType nType, icUInt8Number nColumns);
152 static bool ParseArray(T *buf, icUInt32Number nBufSize, xmlNode *pNode);
153
154 static icUInt32Number ParseTextCount(const char *szText);
155 static icUInt32Number ParseText(T *buf, icUInt32Number nBufSize, const char *szText);
156 static icUInt32Number ParseTextCountNum(const char *szText, icUInt32Number num, std::string &parseStr);
157
158 bool ParseArray(xmlNode *pNode);
159 bool ParseTextArray(const char *szText);
160 bool ParseTextArray(xmlNode *pNode);
161 bool ParseTextArrayNum(const char *szText, icUInt32Number num, std::string &parseStr);
162
163 bool SetSize(icUInt32Number nSize);
164
165 T *GetBuf() { return m_pBuf; }
167
168protected:
170 T *m_pBuf;
171};
172
173#define icSigFloatArrayType ((icTagTypeSignature)0x66637420) /* 'flt ' */
174
182
186icTagSignature icGetTagNameSig(const icChar *szTagName);
187icRenderingIntent icGetRenderingIntentValue (const icChar *szRenderingIntent);
197const std::string icGetDeviceAttrName(icUInt64Number devAttr);
198const std::string icGetHeaderFlagsName(icUInt32Number flags, bool bUsesMCS=false);
199const std::string icGetPadSpace(double value);
200
201
202
203
204#endif //_ICCUTILXML_H
float icFloatNumber
All floating point operations/variables in IccProfLib use the icFloatNumber data type.
Definition IccDefs.h:100
char icChar
Definition IccDefs.h:109
File: IccTag.h.
const icChar * szName
File: IccUtil.h.
icMeasurementGeometry icGeNamedtMeasurementGeometryValue(const icChar *str)
const char * icUtf8ToAnsi(std::string &buf, const char *szSrc)
CIccXmlArrayType< icUInt32Number, icSigUInt32ArrayType > CIccUInt32Array
Definition IccUtilXml.h:177
const std::string icGetDeviceAttrName(icUInt64Number devAttr)
icUInt32Number icXmlNodeCount3(xmlNode *pNode, const char *szNodeName1, const char *szNodeName2, const char *szNodeName3)
icColorantEncoding icGetColorantValue(const icChar *str)
CIccXmlArrayType< icUInt16Number, icSigUInt16ArrayType > CIccUInt16Array
Definition IccUtilXml.h:176
icUInt32Number icXmlNodeCount(xmlNode *pNode, const char *szNodeName)
icUInt32Number icXmlGetHexDataSize(const char *szText)
CIccXmlArrayType< icUInt64Number, icSigUInt64ArrayType > CIccUInt64Array
Definition IccUtilXml.h:178
icDateTimeNumber icGetDateTimeValue(const icChar *str)
xmlAttr * icXmlFindAttr(xmlNode *pNode, const char *szAttrName)
icUInt32Number icXmlNodeCount2(xmlNode *pNode, const char *szNodeName1, const char *szNodeName2)
xmlNode * icXmlFindNode(xmlNode *pNode, const char *szNodeName)
const icChar * icGetTagSigName(icTagSignature tagSig)
icUInt32Number icXmlGetHexData(void *pBuf, const char *szText, icUInt32Number nBufSize)
icTagTypeSignature icGetTypeNameTagSig(const icChar *szTagType)
const char * icXmlAttrValue(xmlAttr *attr, const char *szDefault="")
icUInt32Number icXmlGetChildSigVal(xmlNode *pNode)
bool icCLUTToXml(std::string &xml, CIccCLUT *pCLUT, icConvertType nType, std::string blanks, bool bSaveGridPoints=false, const char *szExtraAttrs="", const char *szName="CLUT")
CIccXmlArrayType< icFloatNumber,((icTagTypeSignature) 0x66637420) > CIccFloatArray
Definition IccUtilXml.h:179
icMeasurementFlare icGetNamedMeasurementFlareValue(const icChar *str)
const icChar * icGetStandardObserverName(icStandardObserver str)
const icChar * icGetTagSigTypeName(icTagTypeSignature tagTypeSig)
const char * icUtf16ToUtf8(std::string &buf, const icUInt16Number *szSrc, int sizeSrc=0)
icUInt32Number icXmlDumpHexData(std::string &xml, std::string blanks, void *pBuf, icUInt32Number nBufSize)
icUInt64Number icGetDeviceAttrValue(xmlNode *pNode)
const std::string icGetPadSpace(double value)
icIlluminant icGetIlluminantValue(const icChar *str)
icMeasurementUnitSig icGetMeasurementValue(const icChar *str)
icStandardObserver icGetNamedStandardObserverValue(const icChar *str)
const std::string icGetHeaderFlagsName(icUInt32Number flags, bool bUsesMCS=false)
CIccXmlArrayType< icFloat32Number, icSigFloat32ArrayType > CIccFloat32Array
Definition IccUtilXml.h:180
icRenderingIntent icGetRenderingIntentValue(const icChar *szRenderingIntent)
CIccXmlArrayType< icUInt8Number, icSigUInt8ArrayType > CIccUInt8Array
Definition IccUtilXml.h:175
bool icCLUTDataToXml(std::string &xml, CIccCLUT *pCLUT, icConvertType nType, std::string blanks, bool bSaveGridPoints=false)
icTagSignature icGetTagNameSig(const icChar *szTagName)
icFloatNumber icXmlStrToFloat(const xmlChar *szStr)
const char * icFixXml(char *szDest, const char *szStr)
const unsigned short * icUtf8ToUtf16(CIccUTF16String &buf, const char *szSrc, int sizeSrc=0)
icSignature icXmlStrToSig(const char *szStr)
CIccXmlArrayType< icFloat64Number, icSigFloat64ArrayType > CIccFloat64Array
Definition IccUtilXml.h:181
const char * icAnsiToUtf8(std::string &buf, const char *szSrc)
File: IccXmlConfig.cpp.
icConvertType
icTagTypeSignature
unsigned int icUInt32Number
Class: CIccCLUT.
Definition IccTagLut.h:326
static size_t AllocSize(size_t n)
Definition IccUtilXml.h:102
const char * ToUtf8(std::string &buf)
static size_t WStrlen(const icUInt16Number *uzStr)
bool FromUtf8(const char *szStr, size_t sizeSrc=0)
icUInt16Number * m_str
Definition IccUtilXml.h:105
virtual ~CIccUTF16String()
icUInt16Number operator[](size_t m_nIndex)
Definition IccUtilXml.h:91
const icUInt16Number * c_str()
Definition IccUtilXml.h:93
CIccUTF16String & operator=(const CIccUTF16String &wstr)
size_t Size()
Definition IccUtilXml.h:84
bool Resize(size_t len)
const wchar_t * ToWString(std::wstring &buf)
bool ParseTextArray(const char *szText)
bool SetSize(icUInt32Number nSize)
static bool ParseArray(T *buf, icUInt32Number nBufSize, xmlNode *pNode)
bool ParseTextArrayNum(const char *szText, icUInt32Number num, std::string &parseStr)
static icUInt32Number ParseText(T *buf, icUInt32Number nBufSize, const char *szText)
static bool DumpArray(std::string &xml, std::string blanks, T *buf, icUInt32Number nBufSize, icConvertType nType, icUInt8Number nColumns)
static icUInt32Number ParseTextCountNum(const char *szText, icUInt32Number num, std::string &parseStr)
static icUInt32Number ParseTextCount(const char *szText)
icUInt32Number GetSize()
Definition IccUtilXml.h:166
icUInt32Number m_nSize
unsigned char icUInt8Number
Number definitions.
unsigned short icUInt16Number
icIlluminant
Pre-defined illuminants, used in measurement and viewing conditions type.
icMeasurementFlare
Other enums.
icColorantEncoding
Colorant and Phosphor Encodings used in chromaticity type.
icUInt32Number icSignature
icMeasurementUnitSig
Measurement Unit Signatures used in ResponseCurveSet16Type.
icUInt32Number icUInt64Number[2]
icMeasurementGeometry
Measurement Geometry, used in the measurmentType tag.
icTagSignature
public tags and sizes
icRenderingIntent
Rendering Intents, used in the profile header.
icStandardObserver
Standard Observer, used in the measurmentType tag.
The base date time number.