This is a simple type that publicly inherits container type std::vector
to store a list of ALib strings, using an ALib {lang;Allocator}.
The (current) design of this class could be named "open" or "weak". This is due to the fact that a) The interface of the std::vector
is public by inheritance, and b) Only a few additional interface methods have been added.
As a consequence, it is up to the user of the type to care about proper allocation and deallocation of string data: If a string is added using method Add, its content is copied to memory allocated with the allocator provided with construction. However, any other string may be added by using the interface of the std::vector
.
The typical use case is with class TMonoAllocator or TLocalAllocator provided with module ALib Monomem:
TAllocator | The allocator type, as prototyped with Allocator. |
Definition at line 48 of file strings/util/stringvector.hpp.
#include <stringvector.hpp>
Public Type Index: | |
using | AllocatorType = TAllocator |
The allocator type that TAllocator specifies. | |
using | CharType = TChar |
Type definition of the given template parameter TChar. | |
using | StringType = strings::TString<TChar> |
Type definition of the stored strings. | |
Public Method Index: | |
TStringVector (AllocatorType &pAllocator) | |
~TStringVector ()=default | |
Destructor. | |
integer | Add (const strings::TString< TChar > &src) |
AllocatorType & | GetAllocator () noexcept |
integer | Size () const noexcept |
String | TryGet (integer idx) |
Protected Type Index: | |
using | vectorBase |
The vector type that TAllocator specifies. | |
using AllocatorType = TAllocator |
The allocator type that TAllocator specifies.
Definition at line 60 of file strings/util/stringvector.hpp.
using CharType = TChar |
Type definition of the given template parameter TChar.
Definition at line 54 of file strings/util/stringvector.hpp.
using StringType = strings::TString<TChar> |
Type definition of the stored strings.
Definition at line 57 of file strings/util/stringvector.hpp.
|
protected |
The vector type that TAllocator specifies.
Definition at line 64 of file strings/util/stringvector.hpp.
|
inline |
Constructor.
pAllocator | The allocator to use. |
Definition at line 71 of file strings/util/stringvector.hpp.
|
inline |
Adds a string to the end of the list of strings.
src | Source string to be copied. |
Definition at line 93 of file strings/util/stringvector.hpp.
|
inlinenoexcept |
Returns the allocator provided with construction. If this was nulled, then this method can be used to set an external (or new) allocator using the assignment operator. Has to be set before the first insertion of data.
Definition at line 82 of file strings/util/stringvector.hpp.
|
inlinenoexcept |
Returns the size of this vector as integer.
Definition at line 87 of file strings/util/stringvector.hpp.
Receives the string at a valid idx. If the index is out of bounds, a nulled string is returned.
idx | The index to try. |
Definition at line 103 of file strings/util/stringvector.hpp.