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

 ReallocCstringVec () noexcept
 Uses std::realloc with the default constructor.
 
 ReallocCstringVec (ReallocFunc func) noexcept
 Enables the user to specify the realloc function with the constructor. More...
 
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...
 
char * front () noexcept
 Gets the first string. More...
 
char * back () noexcept
 Gets the last string. More...
 
void swap (ReallocCstringVec &rhs) noexcept
 Swaps vectors. More...
 
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...
 

Detailed Description

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

Definition at line 214 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 220 of file ReallocVec.h.

Member Function Documentation

§ back()

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

Gets the last string.

Returns
The last string.

Definition at line 249 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 253 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 254 of file ReallocVec.h.

§ front()

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

Gets the first string.

Returns
The first string.

Definition at line 247 of file ReallocVec.h.

§ GetRealloc()

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

Gets the specified realloc function.

Returns
The realloc function.

Definition at line 223 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 243 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 237 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 224 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 227 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 255 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 252 of file ReallocVec.h.

§ swap()

nn::nlib::ReallocCstringVec::swap ( ReallocCstringVec rhs)
inlinenoexcept

Swaps vectors.

Parameters
[in]rhsThe vector to swap.

Definition at line 251 of file ReallocVec.h.


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