NlohmannJSONWriter.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 #include <sstream>
27 
28 // Simox
29 #include <SimoxUtility/json.h>
30 
31 // Base Class
33 
35 {
37  virtual public WriterInterface<nlohmann::json>
38  {
39  public:
40  NlohmannJSONWriter() = default;
41 
43 
44  nlohmann::json writeList(const std::vector<nlohmann::json>& elements, const Path& p = Path()) override;
45  nlohmann::json writeDict(const std::map<std::string, nlohmann::json>& elements, const std::optional<nlohmann::json>& extends = std::nullopt, const Path& p = Path()) override;
46 
47  nlohmann::json writeNDArray(const std::vector<int>& shape, const std::string& typeAsString, const unsigned char* data, const Path& p = Path()) override;
48 
49  nlohmann::json writeInt(const int i, const Path& p = Path()) override;
50  nlohmann::json writeLong(const long i, const Path& p = Path()) override;
51  nlohmann::json writeFloat(const float i, const Path& p = Path()) override;
52  nlohmann::json writeDouble(const double i, const Path& p = Path()) override;
53  nlohmann::json writeString(const std::string& i, const Path& p = Path()) override;
54  nlohmann::json writeBool(const bool i, const Path& p = Path()) override;
55  };
56 }
armarx::aron::data::writer::NlohmannJSONWriter::writeInt
nlohmann::json writeInt(const int i, const Path &p=Path()) override
Definition: NlohmannJSONWriter.cpp:81
armarx::aron::data::writer::NlohmannJSONWriter::getDescriptor
data::Descriptor getDescriptor(ReturnTypeConst &input) final
Definition: NlohmannJSONWriter.cpp:45
armarx::aron::data::writer::NlohmannJSONWriter
Definition: NlohmannJSONWriter.h:36
armarx::aron::data::writer::NlohmannJSONWriter::writeString
nlohmann::json writeString(const std::string &i, const Path &p=Path()) override
Definition: NlohmannJSONWriter.cpp:113
armarx::aron::data::writer::NlohmannJSONWriter::writeFloat
nlohmann::json writeFloat(const float i, const Path &p=Path()) override
Definition: NlohmannJSONWriter.cpp:97
armarx::aron::data::Descriptor
Descriptor
Definition: Descriptor.h:193
armarx::aron::data::writer::NlohmannJSONWriter::writeNDArray
nlohmann::json writeNDArray(const std::vector< int > &shape, const std::string &typeAsString, const unsigned char *data, const Path &p=Path()) override
Definition: NlohmannJSONWriter.cpp:67
armarx::aron::data::writer::NlohmannJSONWriter::NlohmannJSONWriter
NlohmannJSONWriter()=default
armarx::aron::data::writer::NlohmannJSONWriter::writeBool
nlohmann::json writeBool(const bool i, const Path &p=Path()) override
Definition: NlohmannJSONWriter.cpp:121
armarx::aron::data::writer::NlohmannJSONWriter::writeDouble
nlohmann::json writeDouble(const double i, const Path &p=Path()) override
Definition: NlohmannJSONWriter.cpp:105
armarx::aron::Path
The Path class.
Definition: Path.h:36
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
armarx::aron::input
ReaderT::InputType & input
Definition: rw.h:19
armarx::aron::data::writer::NlohmannJSONWriter::writeDict
nlohmann::json writeDict(const std::map< std::string, nlohmann::json > &elements, const std::optional< nlohmann::json > &extends=std::nullopt, const Path &p=Path()) override
Definition: NlohmannJSONWriter.cpp:58
armarx::aron::data::writer
Definition: NlohmannJSONWriter.cpp:33
armarx::aron::data::writer::NlohmannJSONWriter::writeLong
nlohmann::json writeLong(const long i, const Path &p=Path()) override
Definition: NlohmannJSONWriter.cpp:89
armarx::aron::data::WriterInterface< nlohmann::json >::ReturnTypeConst
typename std::add_const< ReturnType >::type ReturnTypeConst
Definition: Writer.h:42
armarx::armem::server::ltm::detail::mixin::Path
std::filesystem::path Path
Definition: DiskStorageMixin.h:17
Writer.h
armarx::aron::data::writer::NlohmannJSONWriter::writeList
nlohmann::json writeList(const std::vector< nlohmann::json > &elements, const Path &p=Path()) override
Definition: NlohmannJSONWriter.cpp:50
armarx::aron::data::WriterInterface
Definition: Writer.h:38