JPathNavigator.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T),
5  * Karlsruhe Institute of Technology (KIT), all rights reserved.
6  *
7  * ArmarX is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  *
11  * ArmarX is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * @author Simon Ottenhaus (simon dot ottenhaus at kit dot edu)
20  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21  * GNU General Public License
22  */
23 
24 #pragma once
25 
26 #include "JsonData.h"
27 #include "JsonArray.h"
28 #include "JsonObject.h"
29 #include "JsonValue.h"
30 
31 #include <memory>
32 
33 namespace armarx
34 {
36  {
37  private:
38  JPathNavigator(const JsonDataPtr& data, int index, const std::string& key);
39 
40  public:
42 
43  bool isArray() const;
44  bool isObject() const;
45  bool isValue() const;
46  bool isString() const;
47  bool isBool() const;
48  bool isNull() const;
49  bool isNumber() const;
50  bool isInt() const;
51  bool isValid() const;
52 
53  void checkValid() const;
54 
55  std::vector<JPathNavigator> select(const std::string& expr, bool limitToOne = false) const;
56  JPathNavigator selectSingleNode(const std::string& expr) const;
57  bool remove(const std::string& key);
58  void remove(uint index);
59 
60  JsonObjectPtr asObject() const;
61  JsonArrayPtr asArray() const;
62  JsonValuePtr asValue() const;
63 
64  std::string asString() const;
65  float asFloat() const;
66  int asInt() const;
67  bool asBool() const;
68 
69  JsonDataPtr getData() const;
70  int getIndex() const;
71  std::string getKey() const;
72 
73  private:
74 
76  int index;
77  std::string key;
78  void select(const std::vector<std::string>& parts, size_t partIndex, std::vector<JPathNavigator>& result, bool limitToOne = false) const;
79  };
80 }
81 
JsonData.h
armarx::JPathNavigator::isObject
bool isObject() const
Definition: JPathNavigator.cpp:48
armarx::JPathNavigator::isString
bool isString() const
Definition: JPathNavigator.cpp:58
armarx::JsonValuePtr
std::shared_ptr< JsonValue > JsonValuePtr
Definition: JsonValue.h:30
armarx::JPathNavigator::isValue
bool isValue() const
Definition: JPathNavigator.cpp:53
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::JPathNavigator::asBool
bool asBool() const
Definition: JPathNavigator.cpp:219
armarx::JPathNavigator::isNull
bool isNull() const
Definition: JPathNavigator.cpp:70
armarx::JPathNavigator::asString
std::string asString() const
Definition: JPathNavigator.cpp:203
armarx::JsonArrayPtr
std::shared_ptr< JsonArray > JsonArrayPtr
Definition: JsonArray.h:32
JsonObject.h
armarx::JPathNavigator
Definition: JPathNavigator.h:35
armarx::JPathNavigator::getKey
std::string getKey() const
Definition: JPathNavigator.cpp:236
JsonArray.h
armarx::JPathNavigator::remove
bool remove(const std::string &key)
Definition: JPathNavigator.cpp:160
armarx::JPathNavigator::select
std::vector< JPathNavigator > select(const std::string &expr, bool limitToOne=false) const
Definition: JPathNavigator.cpp:101
armarx::JPathNavigator::checkValid
void checkValid() const
Definition: JPathNavigator.cpp:93
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
JsonValue.h
armarx::JPathNavigator::isBool
bool isBool() const
Definition: JPathNavigator.cpp:64
armarx::JPathNavigator::asArray
JsonArrayPtr asArray() const
Definition: JPathNavigator.cpp:181
armarx::JPathNavigator::isArray
bool isArray() const
Definition: JPathNavigator.cpp:43
armarx::JPathNavigator::getIndex
int getIndex() const
Definition: JPathNavigator.cpp:230
armarx::JPathNavigator::isInt
bool isInt() const
Definition: JPathNavigator.cpp:82
armarx::JPathNavigator::getData
JsonDataPtr getData() const
Definition: JPathNavigator.cpp:224
armarx::JPathNavigator::selectSingleNode
JPathNavigator selectSingleNode(const std::string &expr) const
Definition: JPathNavigator.cpp:110
armarx::JsonDataPtr
std::shared_ptr< JsonData > JsonDataPtr
Definition: JsonData.h:31
armarx::JPathNavigator::asFloat
float asFloat() const
Definition: JPathNavigator.cpp:209
armarx::JPathNavigator::asValue
JsonValuePtr asValue() const
Definition: JPathNavigator.cpp:192
armarx::JPathNavigator::isNumber
bool isNumber() const
Definition: JPathNavigator.cpp:76
armarx::JPathNavigator::isValid
bool isValid() const
Definition: JPathNavigator.cpp:88
armarx::JPathNavigator::asInt
int asInt() const
Definition: JPathNavigator.cpp:214
armarx::JPathNavigator::asObject
JsonObjectPtr asObject() const
Definition: JPathNavigator.cpp:170
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::JsonObjectPtr
std::shared_ptr< JsonObject > JsonObjectPtr
Definition: JsonObject.h:34