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 54 of file ALib.Strings.Vector.H.
#include <ALib.Strings.Vector.H>
Public Type Index: | |
using | AllocatorType = TAllocator |
The allocator type that TAllocator specifies. | |
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 alib::strings::util::TStringVector< TChar, TAllocator >::AllocatorType = TAllocator |
The allocator type that TAllocator specifies.
Definition at line 59 of file ALib.Strings.Vector.H.
|
protected |
The vector type that TAllocator specifies.
Definition at line 63 of file ALib.Strings.Vector.H.
|
inline |
Constructor.
pAllocator | The allocator to use. |
Definition at line 70 of file ALib.Strings.Vector.H.
|
inline |
Adds a string to the end of the list of strings.
src | Source string to be copied. |
Definition at line 92 of file ALib.Strings.Vector.H.
|
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 81 of file ALib.Strings.Vector.H.
|
inlinenoexcept |
Returns the size of this vector as integer.
Definition at line 86 of file ALib.Strings.Vector.H.
|
inline |
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 102 of file ALib.Strings.Vector.H.