-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathjson_value_impl.cpp
More file actions
67 lines (48 loc) · 1.79 KB
/
json_value_impl.cpp
File metadata and controls
67 lines (48 loc) · 1.79 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
#include "json/impl/json_value_impl.hpp"
#include "json/impl/json_array_impl.hpp"
#include "json/impl/json_object_impl.hpp"
#include "exception/ih/exc_internal_error.hpp"
//------------------------------------------------------------------------------
namespace json
{
//------------------------------------------------------------------------------
JsonValueImpl::JsonValueImpl( JsonImpl && _jsonImpl )
: m_jsonImpl( std::move( _jsonImpl ) )
{
}
//------------------------------------------------------------------------------
std::string JsonValueImpl::asString() const
{
INTERNAL_CHECK_WARRING( m_jsonImpl.is_string() );
return m_jsonImpl.get< std::string >();
}
//------------------------------------------------------------------------------
int JsonValueImpl::asInt() const
{
INTERNAL_CHECK_WARRING( m_jsonImpl.is_number() );
return m_jsonImpl.get< int >();
}
//------------------------------------------------------------------------------
bool JsonValueImpl::asBool() const
{
INTERNAL_CHECK_WARRING( m_jsonImpl.is_boolean() );
return m_jsonImpl.get< bool >();
}
//------------------------------------------------------------------------------
JsonValueImpl::JsonObjectPtr JsonValueImpl::asObject() const
{
INTERNAL_CHECK_WARRING( m_jsonImpl.is_object() );
JsonImpl t( m_jsonImpl );
INTERNAL_CHECK_WARRING( t.is_object() );
return JsonObjectPtr{ new JsonObjectImpl{ std::move( t ) } };
}
//------------------------------------------------------------------------------
JsonValueImpl::JsonArrayPtr JsonValueImpl::asArray() const
{
INTERNAL_CHECK_WARRING( m_jsonImpl.is_array() );
JsonImpl t( m_jsonImpl );
INTERNAL_CHECK_WARRING( t.is_array() );
return JsonArrayPtr{ new JsonArrayImpl{ std::move( t ) } };
}
//------------------------------------------------------------------------------
}