CPPMyth
Library to interoperate with MythTV server
Loading...
Searching...
No Matches
jsonparser.h
1
/*
2
* Copyright (C) 2014 Jean-Luc Barriere
3
*
4
* This Program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2, or (at your option)
7
* any later version.
8
*
9
* This Program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; see the file COPYING. If not, write to
16
* the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
17
* MA 02110-1301 USA
18
* http://www.gnu.org/copyleft/gpl.html
19
*
20
*/
21
22
#ifndef JSONPARSER_H
23
#define JSONPARSER_H
24
25
#include "local_config.h"
26
#include "wsresponse.h"
27
#include "sajson.h"
28
29
#include <string>
30
#include <cstdint>
31
36
namespace
NSROOT
37
{
38
namespace
JSON
39
{
40
class
Node
41
{
42
public
:
43
Node();
44
Node(
const
sajson::value
& value);
45
~Node() { }
46
47
bool
IsNull()
const
;
48
bool
IsObject()
const
;
49
bool
IsArray()
const
;
50
bool
IsString()
const
;
51
bool
IsDouble()
const
;
52
bool
IsInt()
const
;
53
bool
IsTrue()
const
;
54
bool
IsFalse()
const
;
55
56
std::string GetStringValue()
const
;
57
size_t
GetStringSize()
const
;
58
double
GetDoubleValue()
const
;
59
int64_t GetBigIntValue()
const
;
60
int32_t GetIntValue()
const
;
61
62
size_t
Size()
const
;
63
Node GetArrayElement(
size_t
index)
const
;
64
std::string GetObjectKey(
size_t
index)
const
;
65
Node GetObjectValue(
size_t
index)
const
;
66
Node GetObjectValue(
const
char
*key)
const
;
67
68
private
:
69
sajson::value
m_value;
70
};
71
72
class
Document
73
{
74
public
:
75
explicit
Document(NSROOT::WSResponse& resp);
76
Document(
const
std::string& content);
77
78
~Document()
79
{
80
if
(m_document)
81
delete
m_document;
82
m_document =
nullptr
;
83
}
84
85
bool
IsValid()
const
86
{
87
return
m_isValid;
88
}
89
90
Node
GetRoot()
const
;
91
92
private
:
93
explicit
Document(
const
Document&);
94
Document& operator=(
const
Document&);
95
96
bool
m_isValid;
97
sajson::document
*m_document;
98
};
99
}
100
}
101
102
#endif
/* JSONPARSER_H */
NSROOT::JSON::Node
Definition
jsonparser.h:41
sajson::document
Definition
sajson.h:405
sajson::value
Definition
sajson.h:287
NSROOT::JSON
This namespace contains all operations to handle JSON content.
cppmyth
src
private
jsonparser.h
Generated on
for CPPMyth by
1.15.0