VariantReader.cpp
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 Fabian Peller (fabian dot peller at kit dot edu)
17* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
18* GNU General Public License
19*/
20
21// STD/STL
22#include <memory>
23#include <numeric>
24
25// Header
26#include "VariantReader.h"
27
28// ArmarX
32
34{
35
41
42 void
44 std::vector<data::VariantPtr>& elements,
45 Path& p)
46 {
48 auto o = data::List::DynamicCastAndCheck(input);
49 elements = o->getElements();
50 p = o->getPath();
51 }
52
53 void
55 std::map<std::string, data::VariantPtr>& elements,
56 Path& p)
57 {
59 auto o = data::Dict::DynamicCastAndCheck(input);
60 elements = o->getElements();
61 p = o->getPath();
62 }
63
64 void
66 std::vector<int>& shape,
67 std::string& typeAsString,
68 std::vector<unsigned char>& data,
69 Path& p)
70 {
73 shape = o->getShape();
74 typeAsString = o->getType();
75 data = o->getDataAsVector();
76 p = o->getPath();
77 }
78
79 void
80 VariantReader::readInt(const data::VariantPtr& input, int& i, Path& p)
81 {
83 auto o = data::Int::DynamicCastAndCheck(input);
84 i = o->getValue();
85 p = o->getPath();
86 }
87
88 void
89 VariantReader::readLong(const data::VariantPtr& input, long& i, Path& p)
90 {
92 auto o = data::Long::DynamicCastAndCheck(input);
93 i = o->getValue();
94 p = o->getPath();
95 }
96
97 void
98 VariantReader::readFloat(const data::VariantPtr& input, float& i, Path& p)
99 {
101 auto o = data::Float::DynamicCastAndCheck(input);
102 i = o->getValue();
103 p = o->getPath();
104 }
105
106 void
107 VariantReader::readDouble(const data::VariantPtr& input, double& i, Path& p)
108 {
110 auto o = data::Double::DynamicCastAndCheck(input);
111 i = o->getValue();
112 p = o->getPath();
113 }
114
115 void
116 VariantReader::readString(const data::VariantPtr& input, std::string& i, Path& p)
117 {
119 auto o = data::String::DynamicCastAndCheck(input);
120 i = o->getValue();
121 p = o->getPath();
122 }
123
124 void
125 VariantReader::readBool(const data::VariantPtr& input, bool& i, Path& p)
126 {
128 auto o = data::Bool::DynamicCastAndCheck(input);
129 i = o->getValue();
130 p = o->getPath();
131 }
132} // namespace armarx::aron::data::reader
The Path class.
Definition Path.h:36
std::vector< std::string > getPath() const
Definition Path.cpp:87
void readBool(InputType &input, bool &i, Path &p) final
void readDict(InputType &input, std::map< std::string, InputTypeNonConst > &elements, Path &p) final
void readLong(InputType &input, long &i, Path &p) final
void readList(InputType &input, std::vector< InputTypeNonConst > &elements, Path &p) final
void readInt(InputType &input, int &i, Path &p) final
void readString(InputType &input, std::string &s, Path &p) final
void readNDArray(InputType &input, std::vector< int > &shape, std::string &typeAsString, std::vector< unsigned char > &data, Path &p) final
void readDouble(InputType &input, double &i, Path &p) final
data::Descriptor getDescriptor(InputType &input) final
void readFloat(InputType &input, float &i, Path &p) final
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
A convenience header to include all aron files (full include, not forward declared)
std::shared_ptr< Variant > VariantPtr
static data::Descriptor GetDescriptor(Input &n)