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 
37  {
39  }
40 
41  void VariantReader::readList(const data::VariantPtr& input, std::vector<data::VariantPtr>& elements, Path& p)
42  {
45  elements = o->getElements();
46  p = o->getPath();
47  }
48 
49  void VariantReader::readDict(const data::VariantPtr& input, std::map<std::string, data::VariantPtr>& elements, Path& p)
50  {
53  elements = o->getElements();
54  p = o->getPath();
55  }
56 
57  void VariantReader::readNDArray(const data::VariantPtr& input, std::vector<int>& shape, std::string& typeAsString, std::vector<unsigned char>& data, Path& p)
58  {
61  shape = o->getShape();
62  typeAsString = o->getType();
63  data = o->getDataAsVector();
64  p = o->getPath();
65  }
66 
67  void VariantReader::readInt(const data::VariantPtr& input, int& i, Path& p)
68  {
71  i = o->getValue();
72  p = o->getPath();
73  }
74 
75  void VariantReader::readLong(const data::VariantPtr& input, long& i, Path& p)
76  {
79  i = o->getValue();
80  p = o->getPath();
81  }
82 
83  void VariantReader::readFloat(const data::VariantPtr& input, float& i, Path& p)
84  {
87  i = o->getValue();
88  p = o->getPath();
89  }
90 
91  void VariantReader::readDouble(const data::VariantPtr& input, double& i, Path& p)
92  {
95  i = o->getValue();
96  p = o->getPath();
97  }
98 
99  void VariantReader::readString(const data::VariantPtr& input, std::string& i, Path& p)
100  {
103  i = o->getValue();
104  p = o->getPath();
105  }
106 
107  void VariantReader::readBool(const data::VariantPtr& input, bool& i, Path& p)
108  {
111  i = o->getValue();
112  p = o->getPath();
113  }
114 }
armarx::aron::data::reader::VariantReader::readNDArray
void readNDArray(InputType &input, std::vector< int > &shape, std::string &typeAsString, std::vector< unsigned char > &data, Path &p) final
armarx::aron::data::reader::VariantReader::getDescriptor
data::Descriptor getDescriptor(InputType &input) final
Definition: VariantReader.cpp:36
armarx::aron::data::ConstVariantVisitor::GetDescriptor
static data::Descriptor GetDescriptor(Input &n)
Definition: VariantVisitor.cpp:35
armarx::aron::data::ReaderInterface< const data::VariantPtr >::InputType
const data::VariantPtr InputType
Definition: Reader.h:39
ARMARX_CHECK_NOT_NULL
#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...
Definition: ExpressionException.h:206
armarx::aron::data::Descriptor
Descriptor
Definition: Descriptor.h:193
armarx::aron::data::reader::VariantReader::readList
void readList(InputType &input, std::vector< InputTypeNonConst > &elements, Path &p) final
armarx::aron::data::detail::SpecializedVariantBase< data::dto::List, List >::DynamicCastAndCheck
static PointerType DynamicCastAndCheck(const VariantPtr &n)
Definition: SpecializedVariant.h:135
armarx::aron::data::reader::VariantReader::readFloat
void readFloat(InputType &input, float &i, Path &p) final
armarx::aron::Path
The Path class.
Definition: Path.h:36
armarx::aron::data::VariantPtr
std::shared_ptr< Variant > VariantPtr
Definition: forward_declarations.h:11
VariantReader.h
armarx::aron::data::reader::VariantReader::readDouble
void readDouble(InputType &input, double &i, Path &p) final
armarx::aron::data::reader
Definition: NlohmannJSONReader.cpp:34
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
armarx::aron::input
ReaderT::InputType & input
Definition: rw.h:19
All.h
armarx::aron::data::reader::VariantReader::readDict
void readDict(InputType &input, std::map< std::string, InputTypeNonConst > &elements, Path &p) final
Exception.h
VariantVisitor.h
armarx::aron::data::reader::VariantReader::readString
void readString(InputType &input, std::string &s, Path &p) final
armarx::aron::data::reader::VariantReader::readBool
void readBool(InputType &input, bool &i, Path &p) final
armarx::armem::server::ltm::detail::mixin::Path
std::filesystem::path Path
Definition: DiskStorageMixin.h:17
armarx::aron::data::reader::VariantReader::readInt
void readInt(InputType &input, int &i, Path &p) final
armarx::aron::Path::getPath
std::vector< std::string > getPath() const
Definition: Path.cpp:85
armarx::aron::data::reader::VariantReader::readLong
void readLong(InputType &input, long &i, Path &p) final