@@ -47,21 +47,42 @@ class TStringBase {
4747 // / @brief The class destructor.
4848 ~TStringBase ();
4949
50+ // / @brief Will set a new string.
51+ // / @param ptr Pointer to the buffer.
52+ // / @param size Size of the buffer.
5053 void set (const T *ptr, size_t size);
54+
55+ // / @brief Will clear the string buffer.
5156 void clear ();
57+
58+ // / @brief Will reset the string buffer, not internal storage will be released.
5259 void reset ();
60+
61+ // / @brief Returns the size of the string buffer.
62+ // / @return The size of the string buffer.
5363 size_t size () const ;
54- void resize (size_t size);
64+
65+ // / @brief Will return true, if the string is empty.
66+ // / @return true for empty.
67+ bool isEmpty () const ;
68+
69+ // / @brief Will return the whole capacity of the string.
70+ // / @return The capacity of the string
5571 size_t capacity () const ;
72+
73+ // / @brief Will return the string pointer.
74+ // / @return The string pointer.
5675 const T *c_str () const ;
57- void append (const T *ptr, size_t size);
5876
5977 // / @brief Helper method to copy data into the string.
6078 // / @param base [inout] The string data to copy in.
6179 // / @param pPtr [in] The data source.
6280 static void copyFrom (TStringBase<T> &base, const T *pPtr, size_t size);
6381
82+ // / @brief Compare operator.
6483 bool operator == (const TStringBase<T> &rhs) const ;
84+
85+ // / @brief Not equal operator.
6586 bool operator != (const TStringBase<T> &rhs) const ;
6687
6788private:
@@ -104,25 +125,8 @@ inline size_t TStringBase<T>::size() const {
104125}
105126
106127template <class T >
107- inline void TStringBase<T>::resize(size_t size) {
108- if (size <= mCapacity ) {
109- return ;
110- }
111-
112- if (mStringBuffer == nullptr ) {
113- mStringBuffer = new T[size];
114- mCapacity = size;
115- if (mSize > 0 ) {
116- memcpy (mStringBuffer , mBuffer , size ());
117- }
118- } else {
119- T *ptr = new T[size];
120- mCapacity = size;
121- if (mSize > 0 ) {
122- memcpy (ptr, mBuffer , size ());
123- }
124- mStringBuffer = ptr
125- }
128+ inline bool TStringBase<T>::isEmpty() const {
129+ return mSize == 0 ;
126130}
127131
128132template <class T >
@@ -139,18 +143,6 @@ inline const T *TStringBase<T>::c_str() const {
139143 return mBuffer ;
140144}
141145
142- template <class T >
143- inline void TStringBase<T>::append(const T* ptr, size_t size) {
144- if (ptr == nullptr ) {
145- return ;
146- }
147-
148- size_t newLen = mSize + size;
149- if (newLen > mCapacity ) {
150-
151- }
152- }
153-
154146template <class T >
155147inline void TStringBase<T>::clear() {
156148 if (mStringBuffer != nullptr ) {
0 commit comments