-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathjson_object_impl.cpp
More file actions
53 lines (38 loc) · 1.31 KB
/
json_object_impl.cpp
File metadata and controls
53 lines (38 loc) · 1.31 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
#include "json/impl/json_object_impl.hpp"
#include "json/impl/json_value_impl.hpp"
#include <string>
//------------------------------------------------------------------------------
namespace json
{
//------------------------------------------------------------------------------
JsonObjectImpl::JsonObjectPtr
JsonObjectImpl::createJson( std::istream & _stream )
{
JsonImpl json;
_stream >> json;
return JsonObjectPtr{ new JsonObjectImpl{ std::move( json ) } };
}
//------------------------------------------------------------------------------
JsonObjectImpl::JsonObjectImpl( JsonImpl && _jsonImpl )
: m_jsonImpl( std::move( _jsonImpl ) )
{
}
//------------------------------------------------------------------------------
JsonObjectImpl::JsonValuePtr
JsonObjectImpl::getAttributeValue( std::string_view _name ) const
{
if( m_jsonImpl.contains( _name ) )
{
JsonImpl json = m_jsonImpl.at( _name.data() );
return JsonValuePtr{ new JsonValueImpl{ std::move( json ) } };
}
return nullptr;
}
//------------------------------------------------------------------------------
JsonObjectImpl::JsonValuePtr JsonObjectImpl::asValue() const
{
JsonImpl copy = m_jsonImpl;
return JsonValuePtr{ new JsonValueImpl{ std::move( copy ) } };
}
//------------------------------------------------------------------------------
}