7 #ifndef _STACKSTRING_CLASS_HEADER_
8 #define _STACKSTRING_CLASS_HEADER_
13 #define stack_string_baseData_OUT_OF_RANGE_ASSERT tFalse
28 template<
typename DATASTORE>
62 m_szCurrentCapacity = 0;
63 m_pGrownSize =
nullptr;
69 if (m_pGrownSize !=
nullptr)
71 delete [] m_pGrownSize;
72 m_pGrownSize =
nullptr;
73 m_szCurrentCapacity = 0;
80 if (m_pGrownSize !=
nullptr)
82 return m_szCurrentCapacity;
100 if (szNewCapacity <= GetCapacity(szFixCapacity))
102 if (szNewCapacity <= szFixCapacity)
106 cStringUtil::Copy(pFixDataArray, m_pGrownSize, szNewCapacity, szFixCapacity + 1);
107 delete[] m_pGrownSize;
108 m_pGrownSize =
nullptr;
112 pFixDataArray[szNewCapacity] =
'\0';
117 m_pGrownSize[szNewCapacity] =
'\0';
122 size_type szNewCapacityAlloc = szNewCapacity + (szNewCapacity * 2) / 3;
124 if (
nullptr == pNewStore)
133 delete [] m_pGrownSize;
139 m_pGrownSize = pNewStore;
140 m_szCurrentCapacity = szNewCapacityAlloc;
147 if (m_pGrownSize !=
nullptr)
151 return pFixDataArray;
157 if (m_pGrownSize !=
nullptr)
161 return pFixDataArray;
181 return szFixCapacity;
187 return szFixCapacity;
195 if (szNewCapacity <= GetCapacity(szFixCapacity))
197 pFixDataArray[szNewCapacity] =
'\0';
208 return pFixDataArray;
214 return pFixDataArray;
219 template<tSize TSIZE,
typename datastoreT>
302 template <tSize TSIZE,
typename datastoreType = assert_out_of_range>
355 template <tSize T2,
typename dT2>
362 template <tSize T2,
typename dT2>
390 template <tSize T2,
typename dT2>
404 template <tSize T2,
typename dT2>
496 if (szCurrentLength + szCount >
capacity())
498 resize(szCurrentLength + szCount);
500 if ((szCurrentLength + szCount) >
capacity())
507 for (;nIdx < szCurrentLength + szCount && nIdx < szMax;
528 template <tSize T2,
typename dT2>
535 if (nLength < szToAppendLength)
537 szToAppendLength = nLength;
540 if (nPos >= szToAppendLength)
545 if (szCurrentLength + szToAppendLength >
capacity())
547 resize(szCurrentLength + szToAppendLength);
549 if (szCurrentLength + szToAppendLength >
capacity())
568 template <tSize T2,
typename dT2>
571 return append(strValue, 0, nLength);
582 template <tSize T2,
typename dT2>
599 template <tSize T2,
typename dT2>
618 return assign(pChar, 0, nLength);
671 if (nPos >= szLengthToAppend)
678 szLengthToAppend -= nPos;
682 if (nLength < szLengthToAppend)
684 szLengthToAppend = nLength;
709 return cdata()[nIdx];
737 template <tSize T2,
typename dT2>
751 else if (szInsertPos > szLengthMyLength)
753 szInsertPos = szLengthMyLength;
761 else if (szFromPos >= szLengthToInsert)
767 if (szLength < szLengthToInsert && szLength !=
InvalidPos)
769 szLengthToInsert = szLength;
772 if (szLengthMyLength + szLengthToInsert >
capacity())
774 resize(szLengthMyLength + szLengthToInsert);
776 if (szLengthMyLength + szLengthToInsert >
capacity())
782 const tChar* pFromChar = &strValue[szFromPos];
816 template <tSize T2,
typename dT2>
825 if (nStartPos > szCurrentLength)
829 if (szFindLength == 0)
834 aToken[0] = strValue[0];
837 while (szCurrentBeginPos + szFindLength <= szCurrentLength)
842 szCurrentBeginPos = szFirstOf;
845 return szCurrentBeginPos;
878 if (nPos >= szCurrentLength)
884 nLength = szCurrentLength - nPos;
897 template <tSize T2,
typename dT2>
901 strSwapValue.
assign(*
this);
903 strValue.
assign(strSwapValue);
934 template <tSize T2,
typename dT2>
950 template <tSize T2,
typename dT2>
#define A_UTILS_ASSERT
This macro is used for platform independent assertion expressions.
char tChar
The tChar defines the type for platform character set (platform and compiler dependent type).
void tVoid
The tVoid is always the definition for the void (non-type).
size_t tSize
type definition for a array size values, map size values etc.
constexpr tSize g_npos
npos size declaration
static const tSize InvalidPos
used to identicate out of range, invalidpos or default length
static tSize RFindFirstOfToken(const tChar *strString, const tChar *strTokenList, tSize szStartPos=InvalidPos, tSize nLength=InvalidPos)
This function searches the string for the last occurrence of a token (character) that is also contain...
static tChar * Delete(tChar *strString, tSize nPos, tSize nLength=InvalidPos)
This function deletes characters from a string.
static tSize GetLength(const tChar *pcStr)
Returns the length of the string.
static tChar * Copy(tChar *pstrDestination, const tChar *pstrSource, tSize nCount=InvalidPos, tSize nDestinationBufferSize=InvalidPos)
Copies a null terminated string to another string buffer.
static tSize FindFirstOfToken(const tChar *strString, const tChar *strTokenList, tSize szStartPos=0, tSize nLength=InvalidPos)
This function searches the string for the first occurrence of a token (character) that is also contai...
static tSize FindFirstNotOfToken(const tChar *strString, const tChar *strTokenList, tSize szStartPos=0, tSize nLength=InvalidPos)
This function searches the string for the first occurrence of a token (character) that is not also co...
static tChar * PushFront(tChar *strDest, tSize szDestSize, const tChar *strSource, tSize nCount)
This function adds the content of one string to the beginning of another string.
static tBool IsEqual(const tChar *str1, const tChar *str2, tSize nPos, tSize nLength)
This function checks if the two strings are equal (case sensitive)
static tChar * Repeat(tChar *strDest, tSize szDestSize, tSize nCount, tChar cCharacter)
Fill a string with a repetitive character sequence.
_myType & append(const stack_string_base< T2, dT2 > &strValue, size_type nPos, size_type nLength)
Appends a copy of a substring of strValue.
static const tSize InvalidPos
used to identicate out of range, invalidpos or default length
void swap(stack_string_base< T2, dT2 > &strValue)
Swap string values.
stack_string_base & operator=(const stack_string_base< T2, dT2 > &strValue)
String assignement.
const value_type * cdata() const
Get C string.
_myBase::value_type value_type
definition value type
size_type rfind(tChar cValue, size_type nStartPos=InvalidPos) const
Searches the string for the last occurrence of a character.
stack_string_base & operator=(_myType &&strValue)
Assignment operator.
_myType & assign(const value_type *strValue, tSize nPos, tSize nLength)
Assigns a new value to the string, replacing its current contents.
_myType & assign(const stack_string_base< T2, dT2 > &strValue)
Assigns a new value to the string, replacing its current contents.
size_type find_first_not_of(const stack_string_base< T2, dT2 > &strValue, size_type nStartPos=0) const
Searches the string for the first character that does not match any of the characters in strValue.
stack_string_base< TSIZE, datastoreType > _myType
definition my type
_myType & assign(const value_type *pChar, tSize nLength=InvalidPos)
Assigns a new value to the string, replacing its current contents.
_myType & insert(tSize szInsertPos, const stack_string_base< T2, dT2 > &strValue, tSize szFromPos, tSize szLength)
Insert into string.
const_iterator cbegin() const
Return const_iterator to beginning.
_myType & assign(size_type nCount, value_type cCharacter)
Assigns a new value to the string, replacing its current contents.
std::reverse_iterator< const_iterator > const_reverse_iterator
short typedefinition for string reverse const_iterators
_myType & append(const stack_string_base< T2, dT2 > &strValue, size_type nLength=InvalidPos)
Appends a copy of of the first nLength characters of strValue.
size_type find_first_of(const stack_string_base< T2, dT2 > &strValue, size_type nStartPos=0) const
Searches the string for the first character that matches any of the characters in strValue.
reverse_iterator rend()
Return reverse iterator to reverse end.
value_type * data()
Get string data.
_myType & assign(const stack_string_base< T2, dT2 > &strValue, tSize nPos, tSize nLength)
Assigns a new value to the string, replacing its current contents.
_myType & append(size_type szCount, value_type c)
Appends szCount consecutive copies of character c.
const_reverse_iterator crbegin() const
Return reverse const_iterator to reverse beginning.
~stack_string_base()
Destructor.
simple_pointer_iterator< const value_type > const_iterator
short typedefinition for string const_iterators
size_type find(const stack_string_base< T2, dT2 > &strValue, size_type nStartPos=0) const
Searches the string for the first occurrence of strValue.
value_type & operator[](size_type nIdx)
Get character of string.
std::reverse_iterator< iterator > reverse_iterator
short typedefinition for string reverse iterators
const_iterator cend() const
Return const_iterator to end.
_myBase::size_type size_type
definition size type
stack_string_base(stack_string_base< T2, dT2 > &&strValue)
Constructor.
tVoid resize(size_type szNewSize)
Resize string.
_myType & erase(size_type nPos, size_type szLength=InvalidPos)
Erases the portion of the string value that begins at the character position nPos and spans szLength ...
const value_type * c_str() const
Get C string.
const value_type & operator[](size_type nIdx) const
Get character of string.
const_reverse_iterator crend() const
Return reverse const_iterator to reverse end.
size_type length() const
Return length of string.
stack_string_base(const _myType &strValue)
Constructor.
iterator end()
Return iterator to end.
reverse_iterator rbegin()
Return reverse iterator to reverse beginning.
size_type capacity() const
Return size of allocated storage.
simple_pointer_iterator< value_type > iterator
short typedefinition for string iterators
stack_string_base(_myType &&strValue)
Constructor.
iterator begin()
Return iterator to beginning.
_myType substr(size_type nPos, size_type nLength=InvalidPos) const
Returns a newly constructed string object with its value initialized to a copy of a substring of this...
stack_string_data< TSIZE, datastoreType > _myBase
definition my base
stack_string_base & operator=(const _myType &strValue)
String assignement.
stack_string_base()
Constructor.
tVoid clear()
Clear string content.
stack_string_base & operator=(stack_string_base< T2, dT2 > &&strValue)
Assignment operator.
stack_string_base(const stack_string_base< T2, dT2 > &strValue)
Constructor.
const value_type * cdata() const
Get C string.
datastoreHandler::size_type size_type
short typedefinition for size_type
stack_string_data & operator=(const stack_string_data &oStackData)
String assignment.
stack_string_data(const stack_string_data &oStackData)
Constructor.
stack_string_data(stack_string_data &&oStackData)
Constructor.
value_type * data()
Get string data.
value_type m_oData[TSIZE+1]
Internally used data.
stack_string_data & operator=(stack_string_data &&oStackData)
String assignment.
datastoreHandler::value_type value_type
short typedefinition for value_type
size_type max_size() const
Return maximum size of string.
datastoreHandler m_oDataHandler
Internally used instance.
tVoid resize(size_type szNewSize)
Resize string.
size_type capacity() const
Return size of allocated storage.
stack_string_data()
Constructor.
virtual ~stack_string_data()
Destructor.
stack_string_data_handler< datastoreT > datastoreHandler
definition of datastoreHandler
ADTF A_UTIL Namespace - Within adtf this is used as adtf::util or adtf_util.
#define stack_string_baseData_OUT_OF_RANGE_ASSERT
OUT_OF_RANGE_ASSERT.
static string option for stack_string
grow in heap option for stack_string
value_type * GetData(value_type *pFixDataArray)
Get string data.
tVoid Resize(value_type *pFixDataArray, const size_type &szFixCapacity, const size_type &szNewCapacity)
Resize string.
tChar value_type
definition value_type
size_type GetMaxSize(const size_type &szFixCapacity) const
Return the maximum string size.
size_type GetCapacity(const size_type &szFixCapacity) const
Return size of allocated storage.
tSize size_type
definition size_type
const value_type * GetCData(const value_type *pFixDataArray) const
Get string data.
value_type * GetData(value_type *pFixDataArray)
Get string data.
tVoid Resize(value_type *pFixDataArray, const size_type &szFixCapacity, const size_type &szNewCapacity)
Resize string.
tChar value_type
definition of value type
size_type GetMaxSize(const size_type &) const
Return maximum size of string.
value_type * m_pGrownSize
string pointer
size_type GetCapacity(const size_type &szFixCapacity) const
Return size of allocated storage.
stack_string_data_handler()
Constructor.
tVoid Deinit()
Deinitalize string.
tSize size_type
definition of size type
const value_type * GetCData(const value_type *pFixDataArray) const
Get string data.
tVoid Init()
Initalize string.
~stack_string_data_handler()
Destructor.
size_type m_szCurrentCapacity
current capacity
Stacked String Data Handler.