25#ifndef ODTRVISINFOSTRING
26#define ODTRVISINFOSTRING
43 int calcLen(
const char *pData)
const
48 while (pData[len] != 0)
52 int find(
const char *pStr,
char findChr,
int startIdx = 0)
const
55 while (pStr[idx] != 0)
57 if (pStr[idx] == findChr)
63 int find(
const char *pStr,
const char *pSubstr,
int startIdx = 0)
const
65 int idx = startIdx, substrIdx;
66 while (pStr[idx] != 0)
69 while (pSubstr[substrIdx] != 0)
71 if (pSubstr[substrIdx] != pStr[idx + substrIdx])
75 if (pSubstr[substrIdx] == 0)
81 void erase(InfoString *pBuffer)
83 if (pBuffer->m_pInfoString)
87 bool dereference(
const InfoString *pExclusive = NULL)
89 if (m_pBuffer != pExclusive)
91 if (m_pBuffer == NULL)
93 if (--m_pBuffer->m_nCounter == 0)
100 void doSetNewBuf(
const char *pData)
103 InfoString *newBuf = (InfoString*)
::odrxAlloc(
sizeof(InfoString));
104 int strLen = calcLen(pData);
107 newBuf->m_pInfoString = (
char*)
::odrxAlloc(strLen + 1);
108 for (
int nChar = 0; nChar < strLen; nChar++)
109 newBuf->m_pInfoString[nChar] = pData[nChar];
110 newBuf->m_pInfoString[strLen] = 0;
113 newBuf->m_pInfoString = NULL;
114 newBuf->m_nCounter = 1;
117 void doSetCopyBuf(InfoString *pBuf)
119 if (dereference(pBuf) && pBuf)
131 { doSetNewBuf(pStr); }
133 { doSetCopyBuf(is.m_pBuffer); }
138 void set(
const char *pStr) { doSetNewBuf(pStr); }
141 const char *
get()
const {
return (m_pBuffer) ? m_pBuffer->m_pInfoString : NULL; }
142 operator const char *()
const {
return get(); }
154 const char *pExtensions =
get();
155 if (!pExtension || !pExtensions)
157 int extLen = calcLen(pExtension);
158 if (!extLen || (find(pExtension,
' ') != -1))
160 int extsLen = calcLen(pExtensions);
163 int start = 0, cur, end;
166 cur = find(pExtensions, pExtension, start);
170 if (cur == 0 || pExtensions[cur - 1] ==
' ')
172 if (end == extsLen || pExtensions[end] ==
' ')
182 InfoString tmpBuf = { NULL, 2 }; (*(
const void**)&tmpBuf.m_pInfoString) = pExtensions;
ALLOCDLL_EXPORT void * odrxAlloc(size_t nBytes)
ALLOCDLL_EXPORT void odrxFree(void *pMemBlock)
bool checkExtension(const char *pExtension) const
OdTrVisInfoString(const OdTrVisInfoString &is)
void set(const OdTrVisInfoString &is)
static bool checkExtensionExternal(const char *pExtensions, const char *pExtension)
OdTrVisInfoString & operator=(const OdTrVisInfoString &is)
void set(const char *pStr)
OdTrVisInfoString(const char *pStr)