JsonArray.h
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @author Simon Ottenhaus (simon dot ottenhaus at kit dot edu)
17 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
18 * GNU General Public License
19 */
20 
21 #pragma once
22 
23 #include "JsonData.h"
24 #include "JsonValue.h"
25 
26 #include <memory>
27 #include <vector>
28 
29 namespace armarx
30 {
31  class JsonArray;
32  using JsonArrayPtr = std::shared_ptr<JsonArray>;
33 
34  class JsonArray : public JsonData
35  {
36  friend class JPathNavigator;
37 
38  public:
39  JsonArray();
40  JsonArray(const std::vector<JsonValue>& values);
41  void writeJson(const JsonWriterPtr& writer) override;
42  void add(const JsonDataPtr& value);
43  void add(const JsonValue& value);
44  void add(const JsonArray& value);
45  void set(uint index, const JsonDataPtr& value);
46  void set(uint index, const JsonValue& value);
47  void remove(uint index);
48  uint size();
49  void clear();
50  JsonArrayPtr toSharedPtr() const;
51  JsonDataPtr clone() override;
52 
53  private:
54  std::vector<JsonDataPtr> elements;
55  };
56 }
57 
JsonData.h
armarx::JsonArray::JsonArray
JsonArray()
Definition: JsonArray.cpp:27
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::JsonArrayPtr
std::shared_ptr< JsonArray > JsonArrayPtr
Definition: JsonArray.h:32
ProsthesisInterface.values
values
Definition: ProsthesisInterface.py:190
armarx::JsonArray
Definition: JsonArray.h:34
armarx::JsonWriterPtr
std::shared_ptr< JsonWriter > JsonWriterPtr
Definition: JsonWriter.h:30
armarx::JsonArray::size
uint size()
Definition: JsonArray.cpp:88
armarx::JPathNavigator
Definition: JPathNavigator.h:35
armarx::JsonArray::toSharedPtr
JsonArrayPtr toSharedPtr() const
Definition: JsonArray.cpp:98
armarx::JsonValue
Definition: JsonValue.h:34
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
armarx::JsonArray::writeJson
void writeJson(const JsonWriterPtr &writer) override
Definition: JsonArray.cpp:39
JsonValue.h
armarx::JsonData
Definition: JsonData.h:33
armarx::JsonArray::add
void add(const JsonDataPtr &value)
Definition: JsonArray.cpp:52
armarx::JsonArray::remove
void remove(uint index)
Definition: JsonArray.cpp:78
armarx::JsonDataPtr
std::shared_ptr< JsonData > JsonDataPtr
Definition: JsonData.h:31
armarx::JsonArray::clear
void clear()
Definition: JsonArray.cpp:93
armarx::JsonArray::clone
JsonDataPtr clone() override
Definition: JsonArray.cpp:104
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::JsonArray::set
void set(uint index, const JsonDataPtr &value)
Definition: JsonArray.cpp:67