-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjson-parser.h
More file actions
48 lines (33 loc) · 1.26 KB
/
json-parser.h
File metadata and controls
48 lines (33 loc) · 1.26 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
#pragma once
#include "json-value.h"
#include "token.h"
#include <iosfwd>
#include <memory>
#include <vector>
#include <boost/variant.hpp>
#include <boost/coroutine/asymmetric_coroutine.hpp>
namespace pyjamas
{
struct JsonValue;
struct Parser
{
using InChannel = boost::coroutines::asymmetric_coroutine< Token >;
using InChannelWriter = InChannel::push_type;
using InChannelReader = InChannel::pull_type;
using OutChannel = boost::coroutines::asymmetric_coroutine< JsonValue >;
using OutChannelWriter = OutChannel::push_type;
using OutChannelReader = OutChannel::pull_type;
Parser( OutChannelWriter writer );
auto channel_writer() -> InChannelWriter;
private:
OutChannelWriter writer;
};
// -------------------------------------------------------------------------
//
auto parse_json( std::istream& input ) -> boost::optional<JsonValue>;
auto parse_json( const char* string ) -> boost::optional<JsonValue>;
// -------------------------------------------------------------------------
// implementation details
auto get_tokens( std::istream& input ) -> std::vector< Token >;
auto get_tokens( const char* string ) -> std::vector< Token >;
}