NlohmannJSONReader.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 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 #pragma once
22 
23 // STD/STL
24 #include <memory>
25 #include <stack>
26 
27 // Simox
28 #include <SimoxUtility/json.h>
29 
30 // BaseClass
32 
34 {
35  class NlohmannJSONReader : public ReaderInterface<const nlohmann::json>
36  {
37  public:
38  // constructors
39  NlohmannJSONReader() = default;
40 
42 
44  std::string& name,
45  std::vector<std::string>& templates,
46  std::vector<std::string>& templateInstantiations,
47  std::map<std::string, InputTypeNonConst>& memberTypes,
48  type::Maybe& maybe,
49  Path& p = *std::unique_ptr<Path>(new Path())) override;
50  void readList(InputType& input,
51  InputTypeNonConst& acceptedType,
52  type::Maybe& maybe,
53  Path& p = *std::unique_ptr<Path>(new Path())) override;
54  void readDict(InputType& input,
55  InputTypeNonConst& acceptedType,
56  type::Maybe& maybe,
57  Path& p = *std::unique_ptr<Path>(new Path())) override;
59  std::vector<InputTypeNonConst>& acceptedTypes,
60  type::Maybe& maybe,
61  Path& p = *std::unique_ptr<Path>(new Path())) override;
62  void readPair(InputType& input,
63  InputTypeNonConst& acceptedType1,
64  InputTypeNonConst& acceptedType2,
65  type::Maybe& maybe,
66  Path& p = *std::unique_ptr<Path>(new Path())) override;
67 
69  int& ndim,
71  std::string& defaultValue,
72  type::Maybe& maybe,
73  Path& p = *std::unique_ptr<Path>(new Path())) override;
75  int& rows,
76  int& cols,
78  std::string& defaultValue,
79  type::Maybe& maybe,
80  Path& p = *std::unique_ptr<Path>(new Path())) override;
83  std::string& defaultValue,
84  type::Maybe& maybe,
85  Path& p = *std::unique_ptr<Path>(new Path())) override;
87  type::pointcloud::VoxelType& type,
88  std::string& defaultValue,
89  type::Maybe& maybe,
90  Path& p = *std::unique_ptr<Path>(new Path())) override;
92  type::image::PixelType& type,
93  std::string& defaultValue,
94  type::Maybe& maybe,
95  Path& p = *std::unique_ptr<Path>(new Path())) override;
96 
98  std::string& name,
99  std::map<std::string, int>& acceptedValues,
100  std::string& defaultValue,
101  type::Maybe& maybe,
102  Path& p = *std::unique_ptr<Path>(new Path())) override;
103 
104  void readInt(InputType& input,
105  std::optional<int>& defaultValue,
106  type::Maybe& maybe,
107  Path& p = *std::unique_ptr<Path>(new Path())) override;
108  void readLong(InputType& input,
109  std::optional<long>& defaultValue,
110  type::Maybe& maybe,
111  Path& p = *std::unique_ptr<Path>(new Path())) override;
112  void readFloat(InputType& input,
113  std::optional<float>& defaultValue,
114  type::Maybe& maybe,
115  Path& p = *std::unique_ptr<Path>(new Path())) override;
116  void readDouble(InputType& input,
117  std::optional<double>& defaultValue,
118  type::Maybe& maybe,
119  Path& p = *std::unique_ptr<Path>(new Path())) override;
120  void readString(InputType& input,
121  std::optional<std::string>& defaultValue,
122  type::Maybe& maybe,
123  Path& p = *std::unique_ptr<Path>(new Path())) override;
124  void readBool(InputType& input,
125  std::optional<bool>& defaultValue,
126  type::Maybe& maybe,
127  Path& p = *std::unique_ptr<Path>(new Path())) override;
128 
129  void readAnyObject(InputType& input, type::Maybe& maybe, Path& p) override;
130  };
131 } // namespace armarx::aron::type::reader
armarx::aron::type::ReaderInterface::InputTypeNonConst
typename std::remove_const< InputType >::type InputTypeNonConst
Definition: Reader.h:42
armarx::aron::type::reader
Definition: NlohmannJSONReader.cpp:34
armarx::aron::type::reader::NlohmannJSONReader::readPointCloud
void readPointCloud(InputType &input, type::pointcloud::VoxelType &type, std::string &defaultValue, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
Definition: NlohmannJSONReader.cpp:201
armarx::aron::type::reader::NlohmannJSONReader::readMatrix
void readMatrix(InputType &input, int &rows, int &cols, type::matrix::ElementType &type, std::string &defaultValue, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
Definition: NlohmannJSONReader.cpp:164
armarx::aron::type::reader::NlohmannJSONReader::readDouble
void readDouble(InputType &input, std::optional< double > &defaultValue, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
armarx::aron::type::reader::NlohmannJSONReader::readPair
void readPair(InputType &input, InputTypeNonConst &acceptedType1, InputTypeNonConst &acceptedType2, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
Definition: NlohmannJSONReader.cpp:130
armarx::aron::type::reader::NlohmannJSONReader::readIntEnum
void readIntEnum(InputType &input, std::string &name, std::map< std::string, int > &acceptedValues, std::string &defaultValue, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
Definition: NlohmannJSONReader.cpp:233
armarx::aron::type::reader::NlohmannJSONReader::readLong
void readLong(InputType &input, std::optional< long > &defaultValue, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
armarx::aron::type::ReaderInterface::InputType
I InputType
Definition: Reader.h:41
armarx::aron::type::reader::NlohmannJSONReader::readTuple
void readTuple(InputType &input, std::vector< InputTypeNonConst > &acceptedTypes, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
Definition: NlohmannJSONReader.cpp:117
armarx::aron::type::reader::NlohmannJSONReader::readAnyObject
void readAnyObject(InputType &input, type::Maybe &maybe, Path &p) override
Definition: NlohmannJSONReader.cpp:366
armarx::aron::type::reader::NlohmannJSONReader::readBool
void readBool(InputType &input, std::optional< bool > &defaultValue, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
armarx::aron::type::reader::NlohmannJSONReader::readList
void readList(InputType &input, InputTypeNonConst &acceptedType, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
armarx::aron::Path
The Path class.
Definition: Path.h:36
armarx::aron::input
ReaderT::InputType & input
Definition: rw.h:19
armarx::aron::type::reader::NlohmannJSONReader::readQuaternion
void readQuaternion(InputType &input, type::quaternion::ElementType &type, std::string &defaultValue, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
Definition: NlohmannJSONReader.cpp:185
Reader.h
armarx::aron::type::reader::NlohmannJSONReader::readInt
void readInt(InputType &input, std::optional< int > &defaultValue, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
armarx::ElementTypes::ElementType
ElementType
Definition: AbstractObjectSerializer.h:32
armarx::aron::type::reader::NlohmannJSONReader::readFloat
void readFloat(InputType &input, std::optional< float > &defaultValue, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
armarx::aron::type::reader::NlohmannJSONReader::NlohmannJSONReader
NlohmannJSONReader()=default
armarx::aron::type::reader::NlohmannJSONReader::readNDArray
void readNDArray(InputType &input, int &ndim, type::ndarray::ElementType &type, std::string &defaultValue, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
armarx::aron::type::reader::NlohmannJSONReader
Definition: NlohmannJSONReader.h:35
armarx::aron::type::reader::NlohmannJSONReader::getDescriptor
type::Descriptor getDescriptor(InputType &input) final
Definition: NlohmannJSONReader.cpp:59
armarx::aron::type::reader::NlohmannJSONReader::readDict
void readDict(InputType &input, InputTypeNonConst &acceptedType, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
armarx::armem::server::ltm::detail::mixin::Path
std::filesystem::path Path
Definition: DiskStorageMixin.h:17
armarx::aron::type::reader::NlohmannJSONReader::readObject
void readObject(InputType &input, std::string &name, std::vector< std::string > &templates, std::vector< std::string > &templateInstantiations, std::map< std::string, InputTypeNonConst > &memberTypes, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
Definition: NlohmannJSONReader.cpp:65
armarx::aron::type::reader::NlohmannJSONReader::readImage
void readImage(InputType &input, type::image::PixelType &type, std::string &defaultValue, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
Definition: NlohmannJSONReader.cpp:217
armarx::aron::type::reader::NlohmannJSONReader::readString
void readString(InputType &input, std::optional< std::string > &defaultValue, type::Maybe &maybe, Path &p= *std::unique_ptr< Path >(new Path())) override
armarx::aron::type::Descriptor
Descriptor
Definition: Descriptor.h:76
armarx::aron::type::ReaderInterface
The ReaderInterface class.
Definition: Reader.h:38