16 #include "ndCoreStdafx.h"
17 #include "ndClassAlloc.h"
26 D_CORE_API
ndString (
const char*
const data);
27 D_CORE_API
ndString (
const char*
const data, ndInt32 maxSize);
29 D_CORE_API
ndString (ndUnsigned64 val);
32 char& operator[] (ndInt32 index);
33 char operator[] (ndInt32 index)
const;
36 bool operator== (
const ndString& src)
const;
37 bool operator!= (
const ndString& src)
const;
38 bool operator< (
const ndString& src)
const;
39 bool operator> (
const ndString& src)
const;
40 bool operator<= (
const ndString& src)
const;
41 bool operator>= (
const ndString& src)
const;
43 D_CORE_API
void operator+= (
const char*
const src);
44 void operator+= (
const ndString& src);
46 ndString operator+ (
const char*
const src)
const;
49 D_CORE_API ndInt32 Find (
char ch, ndInt32 from = 0)
const;
50 ndInt32 Find (
const ndString& subString, ndInt32 from = 0)
const;
51 D_CORE_API ndInt32 Find (
const char*
const subString, ndInt32 from = 0, ndInt32 lenght = 0x7ffffff)
const;
53 D_CORE_API
void Replace (ndInt32 start, ndInt32 size,
const char*
const str, ndInt32 strSize);
54 void Replace (ndInt32 start, ndInt32 size,
const ndString& str);
59 D_CORE_API
void ToUpper();
60 D_CORE_API
void ToLower();
61 D_CORE_API ndInt32 ToInteger()
const;
62 D_CORE_API ndFloat64 ToFloat()
const;
63 D_CORE_API ndUnsigned64 ToInteger64()
const;
66 ndInt32 Capacity()
const;
67 D_CORE_API
void Expand (ndInt32 size);
69 D_CORE_API
void LoadFile (FILE*
const file);
70 ndString SubString(ndInt32 start = 0, ndInt32 size = 0x7fffffff)
const;
72 const char* GetStr ()
const;
75 D_CORE_API ndInt32 CalculateSize (
const char*
const data)
const;
76 ndInt32 Compare (
const char*
const str0,
const char*
const str1)
const;
77 void CopyData (
char*
const dst,
const char*
const src, ndInt32 size)
const;
79 D_CORE_API ndInt32 Find (
const char*
const subString, ndInt32 stringSize, ndInt32 from, ndInt32 lenght)
const;
82 char* AllocMem(ndInt32 size);
83 void FreeMem (
char*
const ptr);
84 D_CORE_API
ndString (
const ndString& src,
const char*
const concatenate, ndInt32 maxSize);
94 inline char& ndString::operator[] (ndInt32 index)
97 ndAssert (index >= 0);
98 ndAssert (index < m_size);
99 return m_string[index];
102 inline char ndString::operator[] (ndInt32 index)
const
105 ndAssert (index >= 0);
106 ndAssert (index < m_size);
107 return m_string[index];
110 inline const char* ndString::GetStr ()
const
115 inline ndInt32 ndString::Size()
const
120 inline ndInt32 ndString::Find (
const char*
const subString, ndInt32 from, ndInt32 lenght)
const
122 return Find (subString, CalculateSize(subString), from, lenght);
125 inline ndInt32 ndString::Find (
const ndString& subStream, ndInt32 from)
const
127 ndAssert (subStream.m_string);
128 return Find (subStream.m_string, subStream.m_size, from, subStream.m_size);
131 inline void ndString::Replace (ndInt32 start, ndInt32 size,
const ndString& str)
133 Replace(start, size, str.m_string, str.m_size);
136 inline void ndString::operator+= (
const ndString& src)
138 *
this += src.m_string;
143 return ndString (*
this, src.m_string, src.m_size);
146 inline ndString ndString::operator+ (
const char*
const copy)
const
148 return ndString (*
this, copy, CalculateSize (copy));
151 inline ndInt32 ndString::Capacity()
const
156 inline void ndString::CopyData (
char*
const dst,
const char*
const src, ndInt32 size)
const
160 memcpy (dst, src,
size_t(size));
163 inline ndInt32 ndString::Compare (
const char*
const str0,
const char*
const str1)
const
167 return strcmp (str0, str1);
170 inline bool ndString::operator== (
const ndString& src)
const
172 return Compare (m_string, src.m_string) == 0;
175 inline bool ndString::operator!= (
const ndString& src)
const
177 return Compare (m_string, src.m_string) != 0;
181 inline bool ndString::operator< (
const ndString& src)
const
183 return Compare (m_string, src.m_string) < 0;
186 inline bool ndString::operator> (
const ndString& src)
const
188 return Compare (m_string, src.m_string) > 0;
191 inline bool ndString::operator<= (
const ndString& src)
const
193 return Compare (m_string, src.m_string) <= 0;
196 inline bool ndString::operator>= (
const ndString& src)
const
198 return Compare (m_string, src.m_string) >= 0;
201 inline ndString ndString::SubString(ndInt32 start, ndInt32 size)
const
204 return ndString (&m_string[start], size);