-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjsd_fundamental.cpp
More file actions
68 lines (61 loc) · 1.75 KB
/
Copy pathjsd_fundamental.cpp
File metadata and controls
68 lines (61 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef JSD_FUNDAMENTAL_CPP_INCLUDED
#define JSD_FUNDAMENTAL_CPP_INCLUDED
#include "jsd_fundamental.hpp"
namespace JSON
{
void parse(bool& value, std::string const& name,
PropertyTree const& object, ParsingOptions const& options)
{
try
{
SJSON_GET_VALUE(bool, name, value, bool());
}
catch (boost::property_tree::ptree_bad_data& exc)
{
SJSON_DEFAULT_PROPERTY_ERROR_HANDLER(char(), char());
}
catch (boost::property_tree::ptree_bad_path& exc)
{
SJSON_DEFAULT_PATH_ERROR_HANDLER(char(), char());
}
}
void parse(char& value, std::string const& name,
PropertyTree const& object, ParsingOptions const& options)
{
try
{
std::string s;
SJSON_GET_VALUE(std::string, name, s, char());
if (!s.empty())
value = s[0];
}
catch (boost::property_tree::ptree_bad_data& exc)
{
SJSON_DEFAULT_PROPERTY_ERROR_HANDLER(char(), char());
}
catch (boost::property_tree::ptree_bad_path& exc)
{
SJSON_DEFAULT_PATH_ERROR_HANDLER(char(), char());
}
}
void parse(wchar_t& value, std::string const& name,
PropertyTree const& object, ParsingOptions const& options)
{
try
{
std::string s;
SJSON_GET_VALUE(std::string, name, s, wchar_t());
if (!s.empty())
value = s[0];
}
catch (boost::property_tree::ptree_bad_data& exc)
{
SJSON_DEFAULT_PROPERTY_ERROR_HANDLER(wchar_t(), wchar_t());
}
catch (boost::property_tree::ptree_bad_path& exc)
{
SJSON_DEFAULT_PATH_ERROR_HANDLER(wchar_t(), wchar_t());
}
}
}
#endif // JSD_FUNDAMENTAL_CPP_INCLUDED