Ethereum  PoC-8
The C++ Implementation of Ethereum
JsonUtils.h
Go to the documentation of this file.
1 /*
2  This file is part of cpp-ethereum.
3 
4  cpp-ethereum is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  cpp-ethereum is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
16 */
17 
18 #pragma once
19 
20 #include <libdevcore/Exceptions.h>
21 #include "JsonSpiritHeaders.h"
22 #include <set>
23 #include <string>
24 
25 namespace dev
26 {
27 // Throws UnknownField() if _obj contains field names not listed in _allowedFields.
28 void validateFieldNames(json_spirit::mObject const& _obj, std::set<std::string> const& _allowedFields);
29 
30 // Converts json value type to string
31 std::string jsonTypeAsString(json_spirit::Value_type _type);
32 
34 {
35  Required,
36  Optional
37 };
38 using JsonTypeSet = std::set<json_spirit::Value_type>;
39 using JsonFieldOptions = std::pair<JsonTypeSet, JsonFieldPresence>;
42 
48 void requireJsonFields(json_spirit::mObject const& _o, std::string const& _configName,
49  std::map<std::string, JsonFieldOptions> const& _validationMap);
50 }
dev::JsonFieldOptions
std::pair< JsonTypeSet, JsonFieldPresence > JsonFieldOptions
Definition: JsonUtils.h:39
dev::requireJsonFields
void requireJsonFields(json_spirit::mObject const &_o, std::string const &_configName, std::map< std::string, JsonFieldOptions > const &_validationMap)
Definition: JsonUtils.cpp:59
dev::jsonTypeAsString
std::string jsonTypeAsString(json_spirit::Value_type _type)
Definition: JsonUtils.cpp:36
JsonSpiritHeaders.h
dev::JsonFieldPresence::Optional
@ Optional
Exceptions.h
dev::JsonTypeSet
std::set< json_spirit::Value_type > JsonTypeSet
Definition: JsonUtils.h:38
dev::JsonFieldPresence::Required
@ Required
dev::validateFieldNames
void validateFieldNames(json_spirit::mObject const &_obj, std::set< std::string > const &_allowedFields)
Definition: JsonUtils.cpp:25
dev::JsonFieldPresence
JsonFieldPresence
Definition: JsonUtils.h:34
dev
Definition: Address.cpp:21