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 <sstream>
26 #include <stack>
27 
28 // Simox
29 #include <SimoxUtility/json.h>
30 
31 // Base Class
33 
35 {
36  class NlohmannJSONWriter : virtual public WriterInterface<nlohmann::json>
37  {
38  public:
39  NlohmannJSONWriter() = default;
40 
42 
43  nlohmann::json writeList(const std::vector<nlohmann::json>& elements,
44  const Path& p = Path()) override;
45  nlohmann::json writeDict(const std::map<std::string, nlohmann::json>& elements,
46  const std::optional<nlohmann::json>& extends = std::nullopt,
47  const Path& p = Path()) override;
48 
49  nlohmann::json writeNDArray(const std::vector<int>& shape,
50  const std::string& typeAsString,
51  const unsigned char* data,
52  const Path& p = Path()) override;
53 
54  nlohmann::json writeInt(const int i, const Path& p = Path()) override;
55  nlohmann::json writeLong(const long i, const Path& p = Path()) override;
56  nlohmann::json writeFloat(const float i, const Path& p = Path()) override;
57  nlohmann::json writeDouble(const double i, const Path& p = Path()) override;
58  nlohmann::json writeString(const std::string& i, const Path& p = Path()) override;
59  nlohmann::json writeBool(const bool i, const Path& p = Path()) override;
60  };
61 } // namespace armarx::aron::data::writer
armarx::aron::data::writer::NlohmannJSONWriter::writeInt
nlohmann::json writeInt(const int i, const Path &p=Path()) override
Definition: NlohmannJSONWriter.cpp:98
armarx::aron::data::writer::NlohmannJSONWriter::getDescriptor
data::Descriptor getDescriptor(ReturnTypeConst &input) final
Definition: NlohmannJSONWriter.cpp:50
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:134
armarx::aron::data::writer::NlohmannJSONWriter::writeFloat
nlohmann::json writeFloat(const float i, const Path &p=Path()) override
Definition: NlohmannJSONWriter.cpp:116
armarx::aron::data::Descriptor
Descriptor
Definition: Descriptor.h:179
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:77
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:143
armarx::aron::data::writer::NlohmannJSONWriter::writeDouble
nlohmann::json writeDouble(const double i, const Path &p=Path()) override
Definition: NlohmannJSONWriter.cpp:125
armarx::aron::Path
The Path class.
Definition: Path.h:35
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
armarx::aron::input
ReaderT::InputType & input
Definition: rw.h:12
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:65
armarx::aron::data::writer
Definition: NlohmannJSONWriter.cpp:34
armarx::aron::data::writer::NlohmannJSONWriter::writeLong
nlohmann::json writeLong(const long i, const Path &p=Path()) override
Definition: NlohmannJSONWriter.cpp:107
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:56
armarx::aron::data::WriterInterface
Definition: Writer.h:38