Switchboard SDK
Loading...
Searching...
No Matches
switchboard::SBAnyVector Class Referencefinal

Vector of SBAny values, used for representing lists or arrays of values. More...

#include <SBAny.hpp>

Public Types

using iterator = std::vector<SBAny>::iterator
using const_iterator = std::vector<SBAny>::const_iterator

Public Member Functions

 SBAnyVector ()
 Default constructor for SBAnyVector, initializes an empty vector.
 SBAnyVector (const SBAnyVector &init)
 Copy constructor for SBAnyVector.
SBAnyVectoroperator= (const SBAnyVector &other)
 Assignment operator for SBAnyVector.
template<typename Iterator>
 SBAnyVector (Iterator first, Iterator last)
 Constructor for SBAnyVector from a range of iterators.
template<typename T>
 SBAnyVector (const std::vector< T > &vec)
 Constructor for SBAnyVector from a std::vector of arbitrary type T.
 SBAnyVector (std::initializer_list< SBAny > init)
 Constructor for SBAnyVector from an initializer list of SBAny values.
 ~SBAnyVector ()
 Destructor for SBAnyVector, cleans up any resources used by the vector.
void reserve (size_t newCapacity)
 Reserves space in the vector for a specified number of elements.
size_t size () const
 Gets the number of elements in the vector.
void emplace_back (const SBAny &value)
 Adds a new SBAny value to the end of the vector.
void push_back (const SBAny &value)
 Adds a new SBAny value to the end of the vector.
SBAnyoperator[] (size_t index)
 Accesses an element in the vector by index.
const SBAnyoperator[] (size_t index) const
 Accesses an element in the vector by index (const version).
iterator begin ()
iterator end ()
const_iterator begin () const
const_iterator end () const

Detailed Description

Vector of SBAny values, used for representing lists or arrays of values.

Constructor & Destructor Documentation

◆ SBAnyVector() [1/4]

switchboard::SBAnyVector::SBAnyVector ( const SBAnyVector & init)

Copy constructor for SBAnyVector.

Parameters
initThe SBAnyVector to copy from.

◆ SBAnyVector() [2/4]

template<typename Iterator>
switchboard::SBAnyVector::SBAnyVector ( Iterator first,
Iterator last )

Constructor for SBAnyVector from a range of iterators.

Parameters
firstThe beginning iterator of the range.
lastThe ending iterator of the range.

◆ SBAnyVector() [3/4]

template<typename T>
switchboard::SBAnyVector::SBAnyVector ( const std::vector< T > & vec)
inlineexplicit

Constructor for SBAnyVector from a std::vector of arbitrary type T.

This constructor converts each element of the input vector to an SBAny and stores it in the SBAnyVector.

Template Parameters
TThe type of elements in the input vector.
Parameters
vecThe input std::vector to convert.

◆ SBAnyVector() [4/4]

switchboard::SBAnyVector::SBAnyVector ( std::initializer_list< SBAny > init)
explicit

Constructor for SBAnyVector from an initializer list of SBAny values.

Parameters
initThe initializer list of SBAny values.

Member Function Documentation

◆ emplace_back()

void switchboard::SBAnyVector::emplace_back ( const SBAny & value)

Adds a new SBAny value to the end of the vector.

This method constructs the SBAny value in place, avoiding unnecessary copies.

Parameters
valueThe SBAny value to add.

◆ operator=()

SBAnyVector & switchboard::SBAnyVector::operator= ( const SBAnyVector & other)

Assignment operator for SBAnyVector.

Parameters
otherThe SBAnyVector to assign from.
Returns
Reference to the assigned SBAnyVector.

◆ operator[]() [1/2]

SBAny & switchboard::SBAnyVector::operator[] ( size_t index)

Accesses an element in the vector by index.

Parameters
indexThe index of the element to access.
Returns
Reference to the SBAny element at the specified index.

◆ operator[]() [2/2]

const SBAny & switchboard::SBAnyVector::operator[] ( size_t index) const

Accesses an element in the vector by index (const version).

Parameters
indexThe index of the element to access.
Returns
Const reference to the SBAny element at the specified index.

◆ push_back()

void switchboard::SBAnyVector::push_back ( const SBAny & value)

Adds a new SBAny value to the end of the vector.

This method is similar to emplace_back, but may involve an additional copy operation.

Parameters
valueThe SBAny value to add.

◆ reserve()

void switchboard::SBAnyVector::reserve ( size_t newCapacity)

Reserves space in the vector for a specified number of elements.

Parameters
newCapacityThe number of elements to reserve space for.

◆ size()

size_t switchboard::SBAnyVector::size ( ) const
nodiscard

Gets the number of elements in the vector.

Returns
The size of the vector.

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