CFx SDK Documentation
2020SP3
|
Go to the documentation of this file.
25 #ifndef __ODCHARCONVERTER_H__
26 #define __ODCHARCONVERTER_H__
38 template <
class CharType>
inline bool isDigit(CharType ch)
40 return (ch >=
'0' && ch <=
'9');
43 template <
class CharType>
inline bool isHexDigit(CharType ch)
45 return (ch >=
'0' && ch <=
'9') ||
46 (ch >=
'a' && ch <=
'f') ||
47 (ch >=
'A' && ch <=
'F');
50 template <
class CharType>
inline bool checkDigits(
const CharType* ptr,
int numDigits,
bool hex =
true)
52 for (
int i = 0; i < numDigits; i++)
62 template <
class CharType>
inline char isCIForMIF(
const CharType* ptr)
66 CharType ch2 = *++ptr;
69 if ((ch2 ==
'U' || ch2 ==
'u') &&
checkDigits(ptr, 4))
72 if ((ch2 ==
'M' || ch2 ==
'm') && (*ptr >=
'1' && *ptr <=
'5') &&
checkDigits(++ptr, 4))
79 template <
class CharType>
inline bool isCIF(
const CharType* ptr)
83 return (ptr[0] ==
'\\' && ( ptr[1] ==
'U' || ptr[1] ==
'u' ) && ptr[2] ==
'+' &&
87 template <
class CharType>
inline bool isMIF(
const CharType* ptr)
91 return (ptr[0] ==
'\\' && ( ptr[1] ==
'M' || ptr[1] ==
'm' ) && ptr[2] ==
'+' &&
92 checkDigits(&ptr[4], 4) && ptr[3] >=
'1' && ptr[3] <=
'5');
95 template <
class CharType>
inline unsigned int hexValue(
const CharType c)
97 if (c >=
'0' && c <=
'9')
return(c -
'0');
98 if (c >=
'A' && c <=
'F')
return(c -
'A' + 10);
99 if (c >=
'a' && c <=
'f')
return(c -
'a' + 10);
129 for(
int i = 0; i < 4; i++ )
131 CharType byteVal = (CharType)(val & 0x0f);
132 dstBuf[7 - i] = CharType((byteVal <= 9) ? (
'0' + byteVal) : (
'A' - 10 + byteVal));
145 for(
int i = 0; i < 4; i++ )
147 CharType byteVal = (CharType)(val & 0x0f);
148 dstBuf[6 - i] = CharType((byteVal <= 9) ? (
'0' + byteVal) : (
'A' - 10 + byteVal));
169 if ( !isMIF<CharType>(srcBuf) )
183 if ( !isCIF<CharType>(srcBuf) )
229 #endif // __ODCHARCONVERTER_H__
unsigned int hexValue(const CharType c)
bool isMIF(const CharType *ptr)
int getMIFIndex(OdCodePageId id)
OdCodePageId checkTheSameCP(OdCodePageId cp)
int getCIFString(OdUInt16 val, CharType *dstBuf, int size)
int getMIFString(OdChar val, OdCodePageId cp, CharType *dstBuf, int size)
bool isHexDigit(CharType ch)
bool isMIFCodepage(OdCodePageId id)
OdCodePageId getMIFCodepage(CharType cp)
bool isCIF(const CharType *ptr)
bool isDigit(CharType ch)
bool checkDigits(const CharType *ptr, int numDigits, bool hex=true)
char isCIForMIF(const CharType *ptr)
bool parseCIFString(CharType *srcBuf, OdChar &val)
bool parseMIFString(CharType *srcBuf, OdChar &val, OdCodePageId &cp)
bool isMBCBCodepage(OdCodePageId id)