nlib
nn::nlib::ReallocCstringVec Class Reference

The class for realloc-based implementations of C string vectors. More...

#include "nn/nlib/ReallocVec.h"

Public Member Functions

ReallocFunc GetRealloc () const noexcept
 Gets the specified realloc function. More...
 
bool push_back (const char *str) noexcept
 Adds a C string to the end. More...
 
bool push_back (const char *startchar_ptr, const char *endchar_ptr) noexcept
 Adds a (sub)string to the end. More...
 
bool pop_back () noexcept
 Deletes a string from the end of the vector. More...
 
char * operator[] (size_t idx) noexcept
 Gets the nth string, where n is specified by idx. More...
 
const char * operator[] (size_t idx) const noexcept
 The const decoration version of the above function.
 
char * front () noexcept
 Gets the first string. More...
 
const char * front () const noexcept
 The const decoration version of the above function.
 
char * back () noexcept
 Gets the last string. More...
 
const char * back () const noexcept
 The const decoration version of the above function.
 
size_t size () const noexcept
 Gets the size of the vector. More...
 
size_t capacity () const noexcept
 Gets the maximum number of elements that can be stored without expanding the vector. More...
 
bool empty () const noexcept
 Determines whether the vector is empty. More...
 
bool reserve (size_t n) noexcept
 Makes it possible to store as many as n elements without expanding the vector. More...
 
void clear () noexcept
 Empties the vector. More...
 
Constructor, Destructor, and Initialization
 ReallocCstringVec () noexcept
 Instantiates the object with default parameters (default constructor). Uses std::realloc.
 
 ReallocCstringVec (ReallocFunc func) noexcept
 Enables the user to specify the realloc function with the constructor. More...
 
 ReallocCstringVec (ReallocCstringVec &&rhs)=default
 Instantiates the object (move constructor).
 
ReallocCstringVecoperator= (ReallocCstringVec &&rhs)=default
 Move assignment operator.
 

Detailed Description

The class for realloc-based implementations of C string vectors.

Definition at line 282 of file ReallocVec.h.

Constructor & Destructor Documentation

◆ ReallocCstringVec()

nn::nlib::ReallocCstringVec::ReallocCstringVec ( ReallocFunc  func)
inlineexplicitnoexcept

Enables the user to specify the realloc function with the constructor.

Parameters
[in]funcThe realloc function.

Definition at line 288 of file ReallocVec.h.

Member Function Documentation

◆ back()

nn::nlib::ReallocCstringVec::back ( )
inlinenoexcept

Gets the last string.

Returns
The last string.

Definition at line 330 of file ReallocVec.h.

◆ capacity()

nn::nlib::ReallocCstringVec::capacity ( ) const
inlinenoexcept

Gets the maximum number of elements that can be stored without expanding the vector.

Returns
The number of elements.
Description
Note that memory is allocated when additions are made to the string itself.

Definition at line 333 of file ReallocVec.h.

◆ clear()

nn::nlib::ReallocCstringVec::clear ( )
inlinenoexcept

Empties the vector.

Description
Note that the region storing the strings is freed, but the memory for the vector itself remains allocated.

Definition at line 336 of file ReallocVec.h.

◆ empty()

nn::nlib::ReallocCstringVec::empty ( ) const
inlinenoexcept

Determines whether the vector is empty.

Returns
Returns true if empty.

Definition at line 334 of file ReallocVec.h.

◆ front()

nn::nlib::ReallocCstringVec::front ( )
inlinenoexcept

Gets the first string.

Returns
The first string.

Definition at line 328 of file ReallocVec.h.

◆ GetRealloc()

nn::nlib::ReallocCstringVec::GetRealloc ( ) const
inlinenoexcept

Gets the specified realloc function.

Returns
The realloc function.

Definition at line 308 of file ReallocVec.h.

◆ operator[]()

nn::nlib::ReallocCstringVec::operator[] ( size_t  idx)
inlinenoexcept

Gets the nth string, where n is specified by idx.

Parameters
[in]idxAn index.
Returns
The nth string (where n is set in idx).

Definition at line 326 of file ReallocVec.h.

◆ pop_back()

nn::nlib::ReallocCstringVec::pop_back ( )
inlinenoexcept

Deletes a string from the end of the vector.

Returns
Returns true when successful.
Description
The memory region for the deleted string is released.

Definition at line 320 of file ReallocVec.h.

◆ push_back() [1/2]

nn::nlib::ReallocCstringVec::push_back ( const char *  str)
inlinenoexcept

Adds a C string to the end.

Parameters
[in]strA C string.
Returns
Returns true when successful.
Description
The string is duplicated and added to a vector.

Definition at line 309 of file ReallocVec.h.

◆ push_back() [2/2]

nn::nlib::ReallocCstringVec::push_back ( const char *  startchar_ptr,
const char *  endchar_ptr 
)
inlinenoexcept

Adds a (sub)string to the end.

Parameters
[in]startchar_ptrThe pointer to the first character.
[in]endchar_ptrThe pointer to beyond the last character.
Returns
Returns true when successful.
Description
The string is duplicated, appended with the null character, and then added to a vector.

Definition at line 312 of file ReallocVec.h.

◆ reserve()

nn::nlib::ReallocCstringVec::reserve ( size_t  n)
inlinenoexcept

Makes it possible to store as many as n elements without expanding the vector.

Parameters
[in]nNumber of elements.
Returns
Returns true when successful.
Description
Note that memory is allocated when additions are made to the string itself.

Definition at line 335 of file ReallocVec.h.

◆ size()

nn::nlib::ReallocCstringVec::size ( ) const
inlinenoexcept

Gets the size of the vector.

Returns
The size of the vector.

Definition at line 332 of file ReallocVec.h.


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