VAE - Virtual Audio Engine 1
Small Data Driven Audio Engine
tklb::String< STORAGE > Class Template Reference

#include <TString.hpp>

Inheritance diagram for tklb::String< STORAGE >:
Collaboration diagram for tklb::String< STORAGE >:

Public Member Functions

 String ()
 
 String (const char *str)
 
 String (const String *str)
 
 String (const String &str)
 
Stringoperator= (const char *str)
 
Stringoperator= (const String &str)
 
const char * c_str () const
 
const char & operator[] (const Size index) const
 
char & operator[] (const Size index)
 
Size size () const
 
bool empty () const
 
char * data ()
 
void set (const String &str)
 
void set (const char *str)
 
void append (const String &str)
 
void append (const char *str)
 
void prepend (const String &str)
 
void prepend (const char *str)
 
void resize (Size size)
 
void reserve (Size size)
 

Private Types

using Size = typename STORAGE::Size
 

Private Attributes

STORAGE mData
 

Detailed Description

template<class STORAGE = HeapBuffer<char>>
class tklb::String< STORAGE >

Definition at line 72 of file TString.hpp.

Member Typedef Documentation

◆ Size

template<class STORAGE = HeapBuffer<char>>
using tklb::String< STORAGE >::Size = typename STORAGE::Size
private

Definition at line 74 of file TString.hpp.

Constructor & Destructor Documentation

◆ String() [1/4]

template<class STORAGE = HeapBuffer<char>>
tklb::String< STORAGE >::String ( )
inline

Definition at line 76 of file TString.hpp.

76{ }

◆ String() [2/4]

template<class STORAGE = HeapBuffer<char>>
tklb::String< STORAGE >::String ( const char *  str)
inline

Definition at line 77 of file TString.hpp.

77{ set(str); }
void set(const String &str)
Definition: TString.hpp:91
Here is the call graph for this function:

◆ String() [3/4]

template<class STORAGE = HeapBuffer<char>>
tklb::String< STORAGE >::String ( const String< STORAGE > *  str)
inline

Definition at line 78 of file TString.hpp.

78{ set(*str); };
Here is the call graph for this function:

◆ String() [4/4]

template<class STORAGE = HeapBuffer<char>>
tklb::String< STORAGE >::String ( const String< STORAGE > &  str)
inline

Definition at line 79 of file TString.hpp.

79{ set(str); };
Here is the call graph for this function:

Member Function Documentation

◆ append() [1/2]

template<class STORAGE = HeapBuffer<char>>
void tklb::String< STORAGE >::append ( const char *  str)
inline

Definition at line 110 of file TString.hpp.

110 {
111 String s = str;
112 append(s);
113 }
void append(const String &str)
Definition: TString.hpp:102
HeapBuffer< char > String
Definition: string.cpp:4
Here is the call graph for this function:

◆ append() [2/2]

template<class STORAGE = HeapBuffer<char>>
void tklb::String< STORAGE >::append ( const String< STORAGE > &  str)
inline

Definition at line 102 of file TString.hpp.

102 {
103 const Size start = mData.size() - 1; // crop off own terminator
104 mData.resize(start + str.size()); // keeps the old data
105 for (Size i = 0; i < str.size(); i++) {
106 mData[start + i] = str[i];
107 }
108 }
typename STORAGE::Size Size
Definition: TString.hpp:74
STORAGE mData
Definition: TString.hpp:73
Here is the call graph for this function:
Here is the caller graph for this function:

◆ c_str()

template<class STORAGE = HeapBuffer<char>>
const char * tklb::String< STORAGE >::c_str ( ) const
inline

Definition at line 83 of file TString.hpp.

83{ return mData.data(); }
Here is the caller graph for this function:

◆ data()

template<class STORAGE = HeapBuffer<char>>
char * tklb::String< STORAGE >::data ( )
inline

Definition at line 89 of file TString.hpp.

89{ return mData.data(); }
Here is the caller graph for this function:

◆ empty()

template<class STORAGE = HeapBuffer<char>>
bool tklb::String< STORAGE >::empty ( ) const
inline

Definition at line 87 of file TString.hpp.

87{ return mData.empty(); }

◆ operator=() [1/2]

template<class STORAGE = HeapBuffer<char>>
String & tklb::String< STORAGE >::operator= ( const char *  str)
inline

Definition at line 80 of file TString.hpp.

80{ set(str); return *this; }
Here is the call graph for this function:

◆ operator=() [2/2]

template<class STORAGE = HeapBuffer<char>>
String & tklb::String< STORAGE >::operator= ( const String< STORAGE > &  str)
inline

Definition at line 81 of file TString.hpp.

81{ set(str); return *this; };
Here is the call graph for this function:

◆ operator[]() [1/2]

template<class STORAGE = HeapBuffer<char>>
char & tklb::String< STORAGE >::operator[] ( const Size  index)
inline

Definition at line 85 of file TString.hpp.

85{ return mData[index]; }

◆ operator[]() [2/2]

template<class STORAGE = HeapBuffer<char>>
const char & tklb::String< STORAGE >::operator[] ( const Size  index) const
inline

Definition at line 84 of file TString.hpp.

84{ return mData[index]; }

◆ prepend() [1/2]

template<class STORAGE = HeapBuffer<char>>
void tklb::String< STORAGE >::prepend ( const char *  str)
inline

Definition at line 126 of file TString.hpp.

126 {
127 String s = str;
128 prepend(s);
129 }
void prepend(const String &str)
Definition: TString.hpp:115
Here is the call graph for this function:

◆ prepend() [2/2]

template<class STORAGE = HeapBuffer<char>>
void tklb::String< STORAGE >::prepend ( const String< STORAGE > &  str)
inline

Definition at line 115 of file TString.hpp.

115 {
116 const Size oldSize = mData.size();
117 mData.resize(oldSize + str.size() - 1);
118 for (Size i = 0; i < oldSize; i++) {
119 mData[mData.size() - i] = mData[oldSize - i];
120 }
121 for (Size i = 0; i < str.size() - 1; i++) { // crop off other terminator
122 mData[i] = str[i];
123 }
124 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reserve()

template<class STORAGE = HeapBuffer<char>>
void tklb::String< STORAGE >::reserve ( Size  size)
inline

Definition at line 133 of file TString.hpp.

133{ mData.reserve(size); }
Size size() const
Definition: TString.hpp:86
Here is the call graph for this function:
Here is the caller graph for this function:

◆ resize()

template<class STORAGE = HeapBuffer<char>>
void tklb::String< STORAGE >::resize ( Size  size)
inline

Definition at line 131 of file TString.hpp.

131{ mData.resize(size); }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set() [1/2]

template<class STORAGE = HeapBuffer<char>>
void tklb::String< STORAGE >::set ( const char *  str)
inline

Definition at line 95 of file TString.hpp.

95 {
96 if (str == nullptr) { return; }
97 const Size size = Size(strlen(str)) + 1; // keep the terminator
98 mData.resize(size);
99 mData.set(str, size);
100 }
Here is the call graph for this function:

◆ set() [2/2]

template<class STORAGE = HeapBuffer<char>>
void tklb::String< STORAGE >::set ( const String< STORAGE > &  str)
inline

Definition at line 91 of file TString.hpp.

91 {
92 mData.set(str.c_str(), str.size());
93 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ size()

template<class STORAGE = HeapBuffer<char>>
Size tklb::String< STORAGE >::size ( ) const
inline

Definition at line 86 of file TString.hpp.

86{ return mData.size(); }
Here is the caller graph for this function:

Member Data Documentation

◆ mData

template<class STORAGE = HeapBuffer<char>>
STORAGE tklb::String< STORAGE >::mData
private

Definition at line 73 of file TString.hpp.


The documentation for this class was generated from the following file: