Devel Lib
JsonArray.h
1 #pragma once
2 
3 #include "Threading/MutexVector/MutexVector.h"
4 #include "IO/JsonObject/JsonObject.h"
5 
8 namespace Devel::IO {
41  class CJsonArray : public Threading::CMutexVector<CJsonObject> {
42  public:
45  CJsonArray() = default;
46 
50  explicit CJsonArray(std::vector<CJsonObject> &i_oOther) {
52  }
53 
59  }
60 
64  CJsonArray(const CJsonArray &i_oOther) : CMutexVector(i_oOther) { this->operator=(i_oOther); }
65 
69  CJsonArray(CJsonArray &&i_oOther) noexcept { this->operator=(std::move(i_oOther)); }
70 
72  ~CJsonArray() override = default;
73 
74  public:
78  void allocate(const size_t i_nSize) { Threading::CMutexVector<CJsonObject>::reserve(i_nSize); }
79 
80  public:
83  inline const Threading::CMutexVector<CJsonObject> &data() const { return *this; }
84 
85  public:
90  inline CJsonArray &operator=(const CJsonArray &i_oOther) {
92  return *this;
93  }
94 
99  inline CJsonArray &operator=(CJsonArray &&i_oOther) noexcept {
101  return *this;
102  }
103  };
104 }
A thread-safe array class for Json objects.
Definition: JsonArray.h:41
const Threading::CMutexVector< CJsonObject > & data() const
Returns a constant reference to the underlying CMutexVector.
Definition: JsonArray.h:83
CJsonArray(Threading::CMutexVector< CJsonObject > &i_oOther)
Explicit constructor for CJsonArray from a CMutexVector of CJsonObject.
Definition: JsonArray.h:57
CJsonArray(CJsonArray &&i_oOther) noexcept
Move constructor for CJsonArray.
Definition: JsonArray.h:69
void allocate(const size_t i_nSize)
Allocates space for n elements.
Definition: JsonArray.h:78
~CJsonArray() override=default
Default destructor for CJsonArray.
CJsonArray & operator=(const CJsonArray &i_oOther)
Overload of assignment operator.
Definition: JsonArray.h:90
CJsonArray(std::vector< CJsonObject > &i_oOther)
Explicit constructor for CJsonArray from a standard vector of CJsonObject.
Definition: JsonArray.h:50
CJsonArray()=default
Default constructor for CJsonArray.
CJsonArray & operator=(CJsonArray &&i_oOther) noexcept
Overload of move assignment operator.
Definition: JsonArray.h:99
CJsonArray(const CJsonArray &i_oOther)
Copy constructor for CJsonArray.
Definition: JsonArray.h:64
Definition: MutexVector.h:65
CMutexVector()=default
Default constructor for CMutexVector.
CMutexVector & operator=(const std::vector< T > &i_tOther)
Assignment operator that copies a std::vector<T> to the CMutexVector.
Definition: MutexVector.h:454
void reserve(const size_t i_nSize)
Reserves memory for the specified number of elements.
Definition: MutexVector.h:367
The namespace encapsulating I/O related classes and functions in the Devel framework.