UniSet 2.32.1
ujson.h
1/*
2 * Copyright (c) 2015 Pavel Vainerman.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as
6 * published by the Free Software Foundation, version 2.1.
7 *
8 * This program 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 GNU
11 * Lesser General Lesser Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16// --------------------------------------------------------------------------
17#ifndef jsonHelpers_H_
18#define jsonHelpers_H_
19// --------------------------------------------------------------------------
20#ifndef DISABLE_REST_API
21#include <Poco/JSON/Object.h>
22// --------------------------------------------------------------------------
23namespace uniset
24{
25 namespace json
26 {
27 Poco::JSON::Object::Ptr make_object( const std::string& key, const Poco::Dynamic::Var& val );
28 Poco::JSON::Object::Ptr make_object( const std::string& key, const Poco::Dynamic::Var&& val );
29 Poco::JSON::Object::Ptr make_child( Poco::JSON::Object::Ptr& root, const std::string& key );
30 Poco::JSON::Array::Ptr make_child_array( Poco::JSON::Object::Ptr& root, const std::string& key );
31
32 namespace help
33 {
34
35 class item
36 {
37 public:
38
39 item( Poco::JSON::Object::Ptr& ptr );
40 item( const std::string& cmd, const std::string& description );
41
42 void param(const std::string& name, const std::string& description );
43 Poco::JSON::Object::Ptr get();
44
45 operator Poco::JSON::Object::Ptr();
46 operator Poco::Dynamic::Var();
47
48 private:
49 Poco::JSON::Object::Ptr root;
50 Poco::JSON::Array::Ptr params;
51 };
52
53 class object
54 {
55 public:
56 object( const std::string& name );
57 object( const std::string& name, Poco::JSON::Object::Ptr ptr );
58
59 void add( item& i );
60 void emplace( item&& i );
61
62 Poco::JSON::Object::Ptr get();
63
64 operator Poco::JSON::Object::Ptr();
65 operator Poco::Dynamic::Var();
66
67 private:
68 Poco::JSON::Object::Ptr root;
69 Poco::JSON::Array::Ptr cmdlist;
70 };
71
72 } // end of namespace help
73 } // end of namespace json
74 // --------------------------------------------------------------------------
75} // end of namespace uniset
76// --------------------------------------------------------------------------
77#endif // end of #ifndef DISABLE_REST_API
78// --------------------------------------------------------------------------
79#endif // end of _jsonHelpers_H_
Definition ujson.h:36
Definition ujson.h:54
Definition Calibration.h:27
KeyType key(const uniset::ObjectId id, const uniset::ObjectId node)
Definition UniSetTypes.cc:980