Devel Lib
Devel::IO::CJsonArray Class Reference

A thread-safe array class for Json objects. More...

#include <JsonArray.h>

Inheritance diagram for Devel::IO::CJsonArray:
Collaboration diagram for Devel::IO::CJsonArray:

Public Member Functions

 CJsonArray ()=default
 Default constructor for CJsonArray. More...
 
 CJsonArray (std::vector< CJsonObject > &i_oOther)
 Explicit constructor for CJsonArray from a standard vector of CJsonObject. More...
 
 CJsonArray (Threading::CMutexVector< CJsonObject > &i_oOther)
 Explicit constructor for CJsonArray from a CMutexVector of CJsonObject. More...
 
 CJsonArray (const CJsonArray &i_oOther)
 Copy constructor for CJsonArray. More...
 
 CJsonArray (CJsonArray &&i_oOther) noexcept
 Move constructor for CJsonArray. More...
 
 ~CJsonArray () override=default
 Default destructor for CJsonArray.
 
void allocate (const size_t i_nSize)
 Allocates space for n elements. More...
 
const Threading::CMutexVector< CJsonObject > & data () const
 Returns a constant reference to the underlying CMutexVector. More...
 
CJsonArrayoperator= (const CJsonArray &i_oOther)
 Overload of assignment operator. More...
 
CJsonArrayoperator= (CJsonArray &&i_oOther) noexcept
 Overload of move assignment operator. More...
 
- Public Member Functions inherited from Devel::Threading::CMutexVector< CJsonObject >
 CMutexVector ()=default
 Default constructor for CMutexVector.
 
 CMutexVector (std::vector< CJsonObject > &i_oVector)
 Copy constructor that takes a non-const reference to a vector.
 
 CMutexVector (std::vector< CJsonObject > &&i_oVector)
 Move constructor that takes an rvalue reference to a vector.
 
 CMutexVector (const CMutexVector< CJsonObject > &i_oVector)
 Copy constructor that takes a const reference to another CMutexVector.
 
 CMutexVector (CMutexVector< CJsonObject > &&i_oVector) noexcept
 
virtual ~CMutexVector ()=default
 Destructor for CMutexVector.
 
bool removeAll (FnMatch i_fnMatch)
 Removes all elements from the vector that match the given condition. More...
 
bool removeOne (FnMatch i_fnMatch)
 Removes the first element from the vector that matches the given condition. More...
 
bool remove (FnMatch i_fnMatch)
 Removes the first element from the vector that matches the given condition. More...
 
bool remove (const CJsonObject &i_oValue)
 Removes the first occurrence of the specified value from the vector. More...
 
CJsonObject find (FnMatch i_fnMatch) const
 Finds the first element in the vector that matches the given condition. More...
 
CJsonObject get (FnMatch i_fnMatch) const
 Alias for find(FnMatch). More...
 
std::vector< CJsonObject > findAll (FnMatch i_fnMatch) const
 Finds all elements in the vector that match the given condition. More...
 
std::vector< CJsonObject > getAll (FnMatch i_fnMatch) const
 Alias for findAll(FnMatch). More...
 
size_t findIndex (FnMatch i_fnMatch) const
 Finds the index of the first element in the vector that matches the given condition. More...
 
size_t indexOf (FnMatch i_fnMatch) const
 Alias for findIndex(FnMatch). More...
 
std::vector< size_t > findIndexAll (FnMatch i_fnMatch) const
 Finds all indexes of the elements in the vector that match the given condition. More...
 
std::vector< size_t > indexOfAll (FnMatch i_fnMatch) const
 Alias for findIndexAll(FnMatch). More...
 
CJsonObject take (FnMatch i_fnMatch) const
 Takes the first element from the vector that matches the given condition and removes it from the vector. More...
 
std::vector< CJsonObject > takeAll (FnMatch i_fnMatch) const
 Takes all elements from the vector that match the given condition and removes them from the vector. More...
 
const CMutexmutex () const
 Returns a reference to the underlying mutex of the CMutexVector. More...
 
const std::vector< CJsonObject > & rawVector () const
 Returns a reference to the underlying vector. More...
 
auto begin () const
 Returns an iterator to the beginning of the vector. More...
 
auto end () const
 Returns an iterator to the end of the vector. More...
 
auto cbegin () const
 Returns a const iterator to the beginning of the vector. More...
 
auto cend () const
 Returns a const iterator to the end of the vector. More...
 
size_t size () const
 Returns the size of the vector. More...
 
bool isEmpty () const
 Checks if the vector is empty. More...
 
CJsonObject & first ()
 Returns a reference to the first element in the vector. More...
 
CJsonObject & last ()
 Returns a reference to the last element in the vector. More...
 
CJsonObject & at (const size_t i_nIndex)
 Returns a reference to the element at the specified index. More...
 
std::vector< CJsonObject > toStdVector () const
 Converts the CMutexVector to a standard vector. More...
 
bool contains (const CJsonObject &i_oValue) const
 Checks if the vector contains the specified value. More...
 
void resize (const size_t i_nSize)
 Resizes the vector to the specified size. More...
 
void reserve (const size_t i_nSize)
 Reserves memory for the specified number of elements. More...
 
void push_back (const CJsonObject &i_oValue)
 Appends a new element to the end of the vector. More...
 
void push_back (CJsonObject &&i_oValue)
 Moves a new element to the end of the vector. More...
 
void push_back (const std::vector< CJsonObject > &i_atValue)
 Appends a vector of elements to the end of the vector. More...
 
void push_back (std::vector< CJsonObject > &&i_atValue)
 Moves a vector of elements to the end of the vector. More...
 
void push_back (const CMutexVector< CJsonObject > &i_atValue)
 Appends another CMutexVector to the end of the vector. More...
 
void push_back (CMutexVector< CJsonObject > &&i_atValue)
 Moves another CMutexVector to the end of the vector. More...
 
bool removeAt (const size_t i_nIndex)
 Removes the element at the specified index from the vector. More...
 
void clear ()
 Removes all elements from the vector.
 
CMutexVectoroperator= (const std::vector< CJsonObject > &i_tOther)
 Assignment operator that copies a std::vector<T> to the CMutexVector. More...
 
CMutexVectoroperator= (std::vector< CJsonObject > &&i_tOther)
 Assignment operator that moves a std::vector<T> to the CMutexVector. More...
 
virtual CMutexVectoroperator= (const CMutexVector< CJsonObject > &i_tOther)
 Assignment operator that copies another CMutexVector to the CMutexVector. More...
 
virtual CMutexVectoroperator= (CMutexVector< CJsonObject > &&i_tOther) noexcept
 Assignment operator that moves another CMutexVector to the CMutexVector. More...
 
CJsonObject & operator[] (const size_t i_nIndex)
 Access operator that returns a reference to the element at the specified index. More...
 
const CJsonObject & operator[] (const size_t i_nIndex) const
 Const access operator that returns a const reference to the element at the specified index. More...
 

Additional Inherited Members

- Public Types inherited from Devel::Threading::CMutexVector< CJsonObject >
typedef std::function< bool(const CJsonObject &)> FnMatch
 

Detailed Description

A thread-safe array class for Json objects.

This class encapsulates a thread-safe vector of Json objects by extending the CMutexVector class from the Threading namespace.

@inherits Threading::CMutexVector<CJsonObject>

Constructor & Destructor Documentation

◆ CJsonArray() [1/5]

Devel::IO::CJsonArray::CJsonArray ( )
default

Default constructor for CJsonArray.

Initializes an empty CJsonArray.

◆ CJsonArray() [2/5]

Devel::IO::CJsonArray::CJsonArray ( std::vector< CJsonObject > &  i_oOther)
inlineexplicit

Explicit constructor for CJsonArray from a standard vector of CJsonObject.

Parameters
i_oOther- The standard vector to initialize the CJsonArray.

Initializes a CJsonArray from a standard vector of CJsonObject.

◆ CJsonArray() [3/5]

Devel::IO::CJsonArray::CJsonArray ( Threading::CMutexVector< CJsonObject > &  i_oOther)
inlineexplicit

Explicit constructor for CJsonArray from a CMutexVector of CJsonObject.

Parameters
i_oOther- The CMutexVector to initialize the CJsonArray.

Initializes a CJsonArray from a CMutexVector of CJsonObject.

◆ CJsonArray() [4/5]

Devel::IO::CJsonArray::CJsonArray ( const CJsonArray i_oOther)
inline

Copy constructor for CJsonArray.

Parameters
i_oOther- The CJsonArray to copy.

Initializes a CJsonArray by copying another CJsonArray.

◆ CJsonArray() [5/5]

Devel::IO::CJsonArray::CJsonArray ( CJsonArray &&  i_oOther)
inlinenoexcept

Move constructor for CJsonArray.

Parameters
i_oOther- The CJsonArray to move.

Initializes a CJsonArray by moving another CJsonArray. The source CJsonArray is left in a valid but unspecified state after the move.

Member Function Documentation

◆ allocate()

void Devel::IO::CJsonArray::allocate ( const size_t  i_nSize)
inline

Allocates space for n elements.

Parameters
i_nSize- The number of elements to allocate space for.

Preallocates memory for a specified number of elements.

◆ data()

const Threading::CMutexVector<CJsonObject>& Devel::IO::CJsonArray::data ( ) const
inline

Returns a constant reference to the underlying CMutexVector.

Returns
The underlying CMutexVector.

◆ operator=() [1/2]

CJsonArray& Devel::IO::CJsonArray::operator= ( CJsonArray &&  i_oOther)
inlinenoexcept

Overload of move assignment operator.

Parameters
i_oOther- The CJsonArray to move.
Returns
A reference to this CJsonArray.

Moves the values of another CJsonArray to this CJsonArray. The source CJsonArray is left in a valid but unspecified state after the move.

◆ operator=() [2/2]

CJsonArray& Devel::IO::CJsonArray::operator= ( const CJsonArray i_oOther)
inline

Overload of assignment operator.

Parameters
i_oOther- The CJsonArray to copy.
Returns
A reference to this CJsonArray.

Assigns the values of another CJsonArray to this CJsonArray.


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