-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjson-value.h
More file actions
51 lines (39 loc) · 1.42 KB
/
json-value.h
File metadata and controls
51 lines (39 loc) · 1.42 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
#pragma once
#include <iosfwd>
#include <vector>
#include <boost/variant.hpp>
namespace pyjamas
{
struct null {};
inline bool operator==( null, null ) { return true; }
inline bool operator!=( null, null ) { return false; }
std::ostream& operator<<( std::ostream& os, null );
struct boolean {
bool value;
};
inline bool operator==( boolean a, boolean b ) { return a.value == b.value; }
inline bool operator!=( boolean a, boolean b ) { return a.value != b.value; }
std::ostream& operator<<( std::ostream& os, const boolean& b );
struct JsonValue;
struct array {
using child_container = std::vector< JsonValue >;
child_container children;
};
bool operator==( const array&, const array& );
bool operator!=( const array&, const array& );
std::ostream& operator<<( std::ostream& os, const array& v );
struct JsonValue
{
using value_type = boost::variant< null, boolean, array >;
template< class T >
JsonValue( value_type v ): value{ std::move( v )}
{}
JsonValue( null n ): value{ n } {}
JsonValue( bool b ): value{ boolean{ b }} {}
JsonValue( boolean b ): value{ b } {}
JsonValue( array a ): value{ std::move( a )} {}
value_type value;
};
bool operator==( const JsonValue& a, const JsonValue& b );
std::ostream& operator<<( std::ostream& os, const JsonValue& v );
}