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
The Path class.
Definition Path.h:36
typename std::add_const< ReturnType >::type ReturnTypeConst
Definition Writer.h:42
nlohmann::json writeLong(const long i, const Path &p=Path()) override
nlohmann::json writeInt(const int i, const Path &p=Path()) override
nlohmann::json writeNDArray(const std::vector< int > &shape, const std::string &typeAsString, const unsigned char *data, const Path &p=Path()) override
nlohmann::json writeString(const std::string &i, const Path &p=Path()) override
nlohmann::json writeList(const std::vector< nlohmann::json > &elements, const Path &p=Path()) override
nlohmann::json writeDict(const std::map< std::string, nlohmann::json > &elements, const std::optional< nlohmann::json > &extends=std::nullopt, const Path &p=Path()) override
nlohmann::json writeDouble(const double i, const Path &p=Path()) override
nlohmann::json writeBool(const bool i, const Path &p=Path()) override
data::Descriptor getDescriptor(ReturnTypeConst &input) final
nlohmann::json writeFloat(const float i, const Path &p=Path()) override
A convenience header to include all aron files (full include, not forward declared)