IccMAX 2.1.27
Color Profile Tools
Loading...
Searching...
No Matches
CIccXmlArrayType< T, Tsig > Class Template Reference

#include <IccUtilXml.h>

Public Member Functions

 CIccXmlArrayType ()
 
 ~CIccXmlArrayType ()
 
T * GetBuf ()
 
icUInt32Number GetSize ()
 
bool ParseArray (xmlNode *pNode)
 
bool ParseTextArray (const char *szText)
 
bool ParseTextArray (xmlNode *pNode)
 
bool ParseTextArrayNum (const char *szText, icUInt32Number num, std::string &parseStr)
 
bool SetSize (icUInt32Number nSize)
 

Static Public Member Functions

static bool DumpArray (std::string &xml, std::string blanks, T *buf, icUInt32Number nBufSize, icConvertType nType, icUInt8Number nColumns)
 
static bool ParseArray (T *buf, icUInt32Number nBufSize, xmlNode *pNode)
 
static icUInt32Number ParseText (T *buf, icUInt32Number nBufSize, const char *szText)
 
static icUInt32Number ParseTextCount (const char *szText)
 
static icUInt32Number ParseTextCountNum (const char *szText, icUInt32Number num, std::string &parseStr)
 

Protected Attributes

icUInt32Number m_nSize
 
T * m_pBuf
 

Detailed Description

template<class T, icTagTypeSignature Tsig>
class CIccXmlArrayType< T, Tsig >

Constructor & Destructor Documentation

◆ CIccXmlArrayType()

template<class T , icTagTypeSignature Tsig>
CIccXmlArrayType< T, Tsig >::CIccXmlArrayType ( )
741{
742 m_pBuf = NULL;
743 m_nSize = 0;
744}
T * m_pBuf
Definition IccUtilXml.h:170
icUInt32Number m_nSize
Definition IccUtilXml.h:169

References CIccXmlArrayType< T, Tsig >::m_nSize, and CIccXmlArrayType< T, Tsig >::m_pBuf.

◆ ~CIccXmlArrayType()

template<class T , icTagTypeSignature Tsig>
CIccXmlArrayType< T, Tsig >::~CIccXmlArrayType ( )
748{
749 if (m_pBuf) {
750 free(m_pBuf);
751 }
752}

References CIccXmlArrayType< T, Tsig >::m_pBuf.

Member Function Documentation

◆ DumpArray()

template<class T , icTagTypeSignature Tsig>
bool CIccXmlArrayType< T, Tsig >::DumpArray ( std::string &  xml,
std::string  blanks,
T *  buf,
icUInt32Number  nBufSize,
icConvertType  nType,
icUInt8Number  nColumns 
)
static
822{
823 char str[200];
824
825 if (!nColumns) nColumns = 1;
827
828 for (i=0; i<nBufSize; i++) {
829 if (!(i%nColumns)) {
830 xml += blanks;
831 }
832 else {
833 xml += " ";
834 }
835
836 switch (Tsig) {
838 switch (nType) {
839 case icConvert8Bit:
840 default:
841 sprintf(str, "%u", (icUInt8Number)buf[i]);
842 break;
843
844 case icConvert16Bit:
845 sprintf(str, "%u", (icUInt16Number)((icFloatNumber)buf[i] * 65535.0 / 255.0 + 0.5));
846 break;
847
848 case icConvertFloat:
849 sprintf(str, icXmlFloatFmt, (icFloatNumber)buf[i] / 255.0);
850 break;
851 }
852 break;
853
855 switch (nType) {
856 case icConvert8Bit:
857 sprintf(str, "%u", (icUInt16Number)((icFloatNumber)buf[i] * 255.0 / 65535.0 + 0.5));
858 break;
859
860 case icConvert16Bit:
861 default:
862 sprintf(str, "%u", (icUInt16Number)buf[i]);
863 break;
864
865 case icConvertFloat:
866 sprintf(str, icXmlFloatFmt, (icFloatNumber)buf[i] / 65535.0);
867 break;
868 }
869 break;
870
872 sprintf(str, "%u", (icUInt32Number)buf[i]);
873 break;
874
876 // unused
877 break;
878
882 switch (nType) {
883 case icConvert8Bit:
884 sprintf(str, "%u", (icUInt8Number)(buf[i] * 255.0 + 0.5));
885 break;
886
887 case icConvert16Bit:
888 sprintf(str, "%u", (icUInt16Number)(buf[i] * 65535.0 + 0.5));
889 break;
890
891 case icConvertFloat:
892 default:
893 sprintf(str, icXmlFloatFmt, (icFloatNumber)buf[i]);
894 }
895 break;
896 }
897 xml += str;
898 if (i%nColumns == nColumns-1) {
899 xml += "\n";
900 }
901 }
902
903 if (i%nColumns) {
904 xml += "\n";
905 }
906
907 return true;
908}
unsigned char icUInt8Number
Definition icProfileHeader.h:250
unsigned short icUInt16Number
Definition icProfileHeader.h:256
unsigned long icUInt32Number
Definition icProfileHeader.h:262
@ icSigUInt8ArrayType
Definition icProfileHeader.h:572
@ icSigUInt16ArrayType
Definition icProfileHeader.h:569
@ icSigFloat64ArrayType
Definition icProfileHeader.h:542
@ icSigUInt64ArrayType
Definition icProfileHeader.h:571
@ icSigFloat32ArrayType
Definition icProfileHeader.h:541
@ icSigUInt32ArrayType
Definition icProfileHeader.h:570
float icFloatNumber
Definition IccDefs.h:101
@ icConvert8Bit
Definition IccXmlConfig.h:68
@ icConvertFloat
Definition IccXmlConfig.h:70
@ icConvert16Bit
Definition IccXmlConfig.h:69
#define icXmlFloatFmt
Definition IccXmlConfig.h:75
#define icSigFloatArrayType
Definition IccUtilXml.h:173

References icConvert16Bit, icConvert8Bit, icConvertFloat, icSigFloat32ArrayType, icSigFloat64ArrayType, icSigUInt16ArrayType, icSigUInt32ArrayType, icSigUInt64ArrayType, and icSigUInt8ArrayType.

Referenced by CIccFormulaCurveSegmentXml::ToXml(), CIccSampledCurveSegmentXml::ToXml(), CIccSinglSampledeCurveXml::ToXml(), CIccXmlToneMapFunc::ToXml(), CIccTagXmlSparseMatrixArray::ToXml(), and CIccTagXmlGamutBoundaryDesc::ToXml().

+ Here is the caller graph for this function:

◆ GetBuf()

◆ GetSize()

◆ ParseArray() [1/2]

template<class T , icTagTypeSignature Tsig>
bool CIccXmlArrayType< T, Tsig >::ParseArray ( T *  buf,
icUInt32Number  nBufSize,
xmlNode *  pNode 
)
static
1035{
1037 if (Tsig==icSigFloatArrayType) {
1038 n = icXmlNodeCount(pNode, "f");
1039
1040 if (!n) {
1041 if (pNode->type!=XML_TEXT_NODE || !pNode->content)
1042 return false;
1043
1044 n = ParseTextCount((const char*)pNode->content);
1045 if (!n || n>nSize)
1046 return false;
1047
1048 ParseText(pBuf, n, (const char*)pNode->content);
1049 }
1050 else {
1051 if (n>nSize)
1052 return false;
1053
1055 for (i=0; i<nSize && pNode; pNode = pNode->next) {
1056 if (pNode->type == XML_ELEMENT_NODE &&
1057 !icXmlStrCmp(pNode->name, "f") &&
1058 pNode->children &&
1059 pNode->children->content) {
1060 float f;
1061 sscanf((const char *)(pNode->children->content), "%f", &f);
1062 pBuf[i] = (T)f;
1063 i++;
1064 }
1065 }
1066 }
1067 }
1068 else {
1069 n = icXmlNodeCount(pNode, "n");
1070
1071 if (!n) {
1072 if (pNode->type!=XML_TEXT_NODE || !pNode->content)
1073 return false;
1074
1075 n = ParseTextCount((const char *)pNode->content);
1076 if (!n || n>nSize)
1077 return false;
1078
1079 n = ParseText(pBuf, n, (const char *)pNode->content);
1080 }
1081 else {
1082 if (n>nSize)
1083 return false;
1084
1086 for (i=0; i<nSize && pNode; pNode = pNode->next) {
1087 if (pNode->type == XML_ELEMENT_NODE &&
1088 !icXmlStrCmp(pNode->name, "n") &&
1089 pNode->children &&
1090 pNode->children->content) {
1091 pBuf[i] = (T)atol((const char *)(pNode->children->content));
1092 i++;
1093 }
1094 }
1095 }
1096 }
1097 return nSize==n;
1098}
icUInt32Number icXmlNodeCount(xmlNode *pNode, const char *szNodeName)
Definition IccUtilXml.cpp:703
#define icXmlStrCmp(x, y)
Definition IccUtilXml.h:134
static icUInt32Number ParseText(T *buf, icUInt32Number nBufSize, const char *szText)
Definition IccUtilXml.cpp:989
static icUInt32Number ParseTextCount(const char *szText)
Definition IccUtilXml.cpp:961

References icXmlNodeCount(), CIccXmlArrayType< T, Tsig >::ParseText(), and CIccXmlArrayType< T, Tsig >::ParseTextCount().

Referenced by CIccMpeXmlMatrix::ParseXml(), CIccMpeXmlEmissionMatrix::ParseXml(), CIccMpeXmlInvEmissionMatrix::ParseXml(), CIccMpeXmlEmissionCLUT::ParseXml(), CIccMpeXmlReflectanceCLUT::ParseXml(), CIccMpeXmlEmissionObserver::ParseXml(), CIccMpeXmlReflectanceObserver::ParseXml(), and CIccTagXmlColorantOrder::ParseXml().

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

◆ ParseArray() [2/2]

template<class T , icTagTypeSignature Tsig>
bool CIccXmlArrayType< T, Tsig >::ParseArray ( xmlNode *  pNode)
756{
757 char scanType[2] = {0};
758 scanType[0] = (Tsig == icSigFloatArrayType ? 'f' : 'n');
759 scanType[1] = 0;
760
761 icUInt32Number n = icXmlNodeCount(pNode, scanType);
762
763 if (n) {
764 if (!SetSize(n))
765 return false;
766 return ParseArray(m_pBuf, m_nSize, pNode);
767 }
768
769 for ( ;pNode && pNode->type!= XML_TEXT_NODE; pNode=pNode->next);
770
771 if (!pNode || !pNode->content)
772 return false;
773
774 n = ParseTextCount((const char*)pNode->content);
775
776 if (!n || !SetSize(n))
777 return false;
778
779 return ParseArray(m_pBuf, m_nSize, pNode);
780}
bool SetSize(icUInt32Number nSize)
Definition IccUtilXml.cpp:1102
static bool ParseArray(T *buf, icUInt32Number nBufSize, xmlNode *pNode)
Definition IccUtilXml.cpp:1034

References icXmlNodeCount(), CIccXmlArrayType< T, Tsig >::m_nSize, CIccXmlArrayType< T, Tsig >::m_pBuf, CIccXmlArrayType< T, Tsig >::ParseTextCount(), and CIccXmlArrayType< T, Tsig >::SetSize().

Referenced by icCLutFromXml(), CIccTagXmlCurve::ParseXml(), CIccFormulaCurveSegmentXml::ParseXml(), CIccSampledCurveSegmentXml::ParseXml(), CIccSinglSampledeCurveXml::ParseXml(), CIccXmlToneMapFunc::ParseXml(), CIccTagXmlNamedColor2::ParseXml(), CIccTagXmlFixedNum< T, Tsig >::ParseXml(), CIccTagXmlParametricCurve::ParseXml(), and CIccTagXmlGamutBoundaryDesc::ParseXml().

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

◆ ParseText()

template<class T , icTagTypeSignature Tsig>
icUInt32Number CIccXmlArrayType< T, Tsig >::ParseText ( T *  buf,
icUInt32Number  nBufSize,
const char *  szText 
)
static
990{
991 icUInt32Number n = 0, b = 0;
992 bool bInNum = false;
993 char num[256] = {0};
994
995 while (*szText && n<nSize) {
996 if (icIsNumChar(*szText)) {
997 if (!bInNum) {
998 bInNum = true;
999 b=0;
1000 }
1001 num[b] = *szText;
1002
1003 if (b+2<sizeof(num))
1004 b++;
1005 }
1006 else if (bInNum) {
1007 num[b] = 0;
1008 if (!strncmp(num, "nan", 3) || !strncmp(num, "-nan", 4)) {
1009 pBuf[n] = (T)nanf(num);
1010 }
1011 else {
1012 pBuf[n] = (T)atof(num);
1013 }
1014 n++;
1015 bInNum = false;
1016 }
1017 szText++;
1018 }
1019 if (bInNum) {
1020 num[b] = 0;
1021 if (!strncmp(num, "nan", 3) || !strncmp(num, "-nan", 4)) {
1022 pBuf[n] = (T)nanf(num);
1023 }
1024 else {
1025 pBuf[n] = (T)atof(num);
1026 }
1027 n++;
1028 }
1029
1030 return n;
1031}
static bool icIsNumChar(char c)
Definition IccUtilXml.cpp:912

References icIsNumChar().

Referenced by CIccXmlArrayType< T, Tsig >::ParseArray(), CIccXmlArrayType< T, Tsig >::ParseTextArray(), and CIccXmlArrayType< T, Tsig >::ParseTextArrayNum().

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

◆ ParseTextArray() [1/2]

template<class T , icTagTypeSignature Tsig>
bool CIccXmlArrayType< T, Tsig >::ParseTextArray ( const char *  szText)
784{
785 icUInt32Number n = ParseTextCount(szText);
786
787 if (n) {
788 if (!SetSize(n))
789 return false;
790
791 return ParseText(m_pBuf, m_nSize, szText)==m_nSize;
792 }
793
794 return false;
795}

References CIccXmlArrayType< T, Tsig >::m_nSize, CIccXmlArrayType< T, Tsig >::m_pBuf, CIccXmlArrayType< T, Tsig >::ParseText(), CIccXmlArrayType< T, Tsig >::ParseTextCount(), and CIccXmlArrayType< T, Tsig >::SetSize().

Referenced by CIccTagXmlSpectralViewingConditions::ParseXml().

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

◆ ParseTextArray() [2/2]

template<class T , icTagTypeSignature Tsig>
bool CIccXmlArrayType< T, Tsig >::ParseTextArray ( xmlNode *  pNode)
799{
800 if (pNode->children && pNode->children->type==XML_TEXT_NODE) {
801 return ParseTextArray((const char*)pNode->children->content);
802 }
803 return false;
804}
bool ParseTextArray(const char *szText)
Definition IccUtilXml.cpp:783

Referenced by CIccTagXmlSparseMatrixArray::ParseXml().

+ Here is the caller graph for this function:

◆ ParseTextArrayNum()

template<class T , icTagTypeSignature Tsig>
bool CIccXmlArrayType< T, Tsig >::ParseTextArrayNum ( const char *  szText,
icUInt32Number  num,
std::string &  parseStr 
)
808{
809 icUInt32Number n = ParseTextCountNum(szText, num, parseStr);
810 if (n) {
811 if (!SetSize(n))
812 return false;
813 return ParseText(m_pBuf, m_nSize, szText)==m_nSize;
814 }
815
816 return false;
817}
static icUInt32Number ParseTextCountNum(const char *szText, icUInt32Number num, std::string &parseStr)
Definition IccUtilXml.cpp:922

References CIccXmlArrayType< T, Tsig >::m_nSize, CIccXmlArrayType< T, Tsig >::m_pBuf, CIccXmlArrayType< T, Tsig >::ParseText(), CIccXmlArrayType< T, Tsig >::ParseTextCountNum(), and CIccXmlArrayType< T, Tsig >::SetSize().

Referenced by icCLutFromXml(), CIccTagXmlCurve::ParseXml(), CIccSampledCurveSegmentXml::ParseXml(), and CIccSinglSampledeCurveXml::ParseXml().

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

◆ ParseTextCount()

template<class T , icTagTypeSignature Tsig>
icUInt32Number CIccXmlArrayType< T, Tsig >::ParseTextCount ( const char *  szText)
static
962{
963 icUInt32Number n = 0;
964 bool bInNum = false;
965
966 while (*szText) {
967 if (icIsNumChar(*szText)) {
968 if (!bInNum) {
969 bInNum = true;
970 }
971 }
972 else if (bInNum && !strncmp(szText, "#QNAN", 5)) { //Handle 1.#QNAN000 (non a number)
973 szText+=4;
974 }
975 else if (bInNum) {
976 n++;
977 bInNum = false;
978 }
979 szText++;
980 }
981 if (bInNum) {
982 n++;
983 }
984
985 return n;
986}

References icIsNumChar().

Referenced by CIccXmlArrayType< T, Tsig >::ParseArray(), CIccXmlArrayType< T, Tsig >::ParseArray(), and CIccXmlArrayType< T, Tsig >::ParseTextArray().

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

◆ ParseTextCountNum()

template<class T , icTagTypeSignature Tsig>
icUInt32Number CIccXmlArrayType< T, Tsig >::ParseTextCountNum ( const char *  szText,
icUInt32Number  num,
std::string &  parseStr 
)
static
923{
924 icUInt32Number n = 0;
925 bool bInNum = false;
926 //icUInt32Number count = 1;
927
928 //while (*szText) {
929 for (icUInt32Number i=0; i<num; i++) {
930 if (icIsNumChar(*szText)) {
931 if (!bInNum) {
932 bInNum = true;
933 }
934 }
935 else if (bInNum && !strncmp(szText, "#QNAN", 5)) { //Handle 1.#QNAN000 (non a number)
936 i+=4;
937 szText+=4;
938 }
939 // an invalid character is encountered (not digit and not space)
940 else if (!isspace(*szText) && i <= num ){
941 char line[100];
942 sprintf(line, "Data '%c' in position %d is not a number. ", *szText, i);
943 parseStr += line;
944 return false;
945 }
946 else if (bInNum) { //char is a space
947 n++;
948 bInNum = false;
949 }
950 szText++;
951 //count++;
952 }
953 if (bInNum) {
954 n++;
955 }
956
957 return n;
958}

References icIsNumChar().

Referenced by CIccXmlArrayType< T, Tsig >::ParseTextArrayNum().

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

◆ SetSize()

template<class T , icTagTypeSignature Tsig>
bool CIccXmlArrayType< T, Tsig >::SetSize ( icUInt32Number  nSize)
1103{
1104 if (m_pBuf) {
1105 free(m_pBuf);
1106 }
1107 m_pBuf = (T*)malloc(nSize * sizeof(T));
1108 if (!m_pBuf) {
1109 m_nSize = 0;
1110 return false;
1111 }
1112 m_nSize = nSize;
1113
1114 return true;
1115}

References CIccXmlArrayType< T, Tsig >::m_nSize, and CIccXmlArrayType< T, Tsig >::m_pBuf.

Referenced by icXmlParseTextString(), CIccXmlArrayType< T, Tsig >::ParseArray(), CIccXmlArrayType< T, Tsig >::ParseTextArray(), CIccXmlArrayType< T, Tsig >::ParseTextArrayNum(), CIccTagXmlZipUtf8Text::ParseXml(), and CIccTagXmlZipXml::ParseXml().

+ Here is the caller graph for this function:

Field Documentation

◆ m_nSize

◆ m_pBuf


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