28 #ifndef __ODANSISTRING_H__
29 #define __ODANSISTRING_H__
43 #define odaIsValidString(lpch) (true)
88 {
return (
char*)(
this+1); }
100 struct OdEmptyStringDataA
102 OdStringDataA kStrData;
123 OdAnsiString(
const OdAnsiString&
source);
128 OdAnsiString(
char ch,
int length);
130 OdAnsiString(
const char*
source);
140 {
return getData()->codepage; }
145 int getLength()
const
146 {
return getData()->nDataLength; }
152 {
return getData()->nDataLength == 0; }
163 char getAt(
int charIndex)
const
166 ODA_ASSERT(charIndex < getData()->nDataLength);
167 return m_pchData[charIndex];
177 char operator[](
int charIndex)
const
180 ODA_ASSERT(charIndex < getData()->nDataLength);
181 return m_pchData[charIndex];
191 void setAt(
int charIndex,
char ch);
196 const char* c_str()
const
197 {
return m_pchData; }
202 operator const char*()
const
203 {
return m_pchData; }
205 OdAnsiString& operator=(
const OdAnsiString&
source);
207 OdAnsiString& operator=(
char ch);
209 OdAnsiString& operator=(
const char*
source);
219 OdAnsiString& operator+=(
const OdAnsiString&
string);
227 OdAnsiString& operator+=(
char ch);
235 OdAnsiString& operator+=(
const char*
string);
242 friend FIRSTDLL_EXPORT OdAnsiString operator+(
const OdAnsiString& string1,
const OdAnsiString& string2);
243 friend FIRSTDLL_EXPORT OdAnsiString operator+(
const OdAnsiString&
string,
char ch);
244 friend FIRSTDLL_EXPORT OdAnsiString operator+(
char ch,
const OdAnsiString&
string);
246 friend FIRSTDLL_EXPORT OdAnsiString operator+(
const OdAnsiString& string1,
const char* string2);
247 friend FIRSTDLL_EXPORT OdAnsiString operator+(
const char* string1,
const OdAnsiString& string2);
264 int compare(
const char* otherString)
const
282 int iCompare(
const char* otherString)
const
293 OdAnsiString mid(
int startIndex,
int length)
const;
300 OdAnsiString mid(
int startIndex)
const;
306 OdAnsiString left(
int length)
const;
312 OdAnsiString right(
int length)
const;
325 OdAnsiString spanIncluding(
const char* charSet)
const;
338 OdAnsiString spanExcluding(
const char* charSet)
const;
346 OdAnsiString& makeUpper();
354 OdAnsiString& makeLower();
362 OdAnsiString& makeReverse();
373 OdAnsiString& trimRight();
383 OdAnsiString& trimLeft();
397 OdAnsiString& trimRight(
char whiteChar);
409 OdAnsiString& trimRight(
const char* whiteChars);
421 OdAnsiString& trimLeft(
char whiteChar);
433 OdAnsiString& trimLeft(
const char* whiteChars);
444 int replace(
char oldChar,
char newChar);
455 int replace(
const char* oldString,
const char* newString);
465 int remove(
char chRemove);
479 int insert(
int insertIndex,
char insertChar);
493 int insert(
int insertIndex,
const char* insertString);
503 int deleteChars(
int deleteIndex,
int count = 1);
514 int find(
char searchChar)
const;
524 int reverseFind(
char searchChar)
const;
537 int find(
char searchChar,
int startIndex)
const;
547 int findOneOf(
const char* charSet)
const;
557 int find(
const char* searchString)
const;
568 int find(
const char* searchString,
int startIndex)
const;
577 OdAnsiString&
format(
const char* formatString, ...);
587 OdAnsiString& formatV(
const char* formatString, va_list argList);
598 char* getBuffer(
int minBufLength);
606 void releaseBuffer(
int newLength = -1);
617 char* getBufferSetLength(
int length);
640 int getAllocLength()
const
641 {
return getData()->nAllocLength; }
654 OdStringDataA* getData()
const
655 {
ODA_ASSERT(m_pchData !=
NULL);
return ((OdStringDataA*)m_pchData)-1; }
672 void allocCopy(OdAnsiString& destString,
int copyLength,
int copyIndex,
int extraLength)
const;
678 void allocBuffer(
int length);
689 void assignCopy(
int sourceLength,
const char*
source);
702 void concatCopy(
int sourceLength1,
const char* source1,
int sourceLength2,
const char* source2);
713 void concatInPlace(
int sourceLength,
const char*
source);
722 void copyBeforeWrite();
731 void allocBeforeWrite(
int newLength);
748 static void ODA_PASCAL release(OdStringDataA* pStringData);
756 static int ODA_PASCAL safeStrlen(
const char*
string)
757 {
return (
string ==
NULL) ? (int)0 : (
int)
odStrLenA(
string); }
763 static void freeData(OdStringDataA* pStringData);
768 {
return s1.compare(s2) == 0; }
771 {
return s1.compare(s2) == 0; }
774 {
return s2.compare(s1) == 0; }
777 {
return s1.compare(s2) != 0; }
780 {
return s1.compare(s2) != 0; }
783 {
return s2.compare(s1) != 0; }
786 {
return s1.compare(s2) < 0; }
789 {
return s1.compare(s2) < 0; }
792 {
return s2.compare(s1) > 0; }
795 {
return s1.compare(s2) > 0; }
798 {
return s1.compare(s2) > 0; }
801 {
return s2.compare(s1) < 0; }
804 {
return s1.compare(s2) <= 0; }
807 {
return s1.compare(s2) <= 0; }
810 {
return s2.compare(s1) >= 0; }
813 {
return s1.compare(s2) >= 0; }
816 {
return s1.compare(s2) >= 0; }
819 {
return s2.compare(s1) <= 0; }
827 #endif // __ODANSISTRING_H__