CPPMyth
Library to interoperate with MythTV server
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 <cppmyth_config.h>
26
#include "wsresponse.h"
27
#include "sajson.h"
28
#include "os/os.h"
29
#include "cppdef.h"
30
31
#include <string>
32
37
namespace
NSROOT
38
{
39
namespace
JSON
40
{
41
class
Node
42
{
43
public
:
44
Node
();
45
Node
(
const
sajson::value
& value);
46
~
Node
() { }
47
48
bool
IsNull()
const
;
49
bool
IsObject()
const
;
50
bool
IsArray()
const
;
51
bool
IsString()
const
;
52
bool
IsDouble()
const
;
53
bool
IsInt()
const
;
54
bool
IsTrue()
const
;
55
bool
IsFalse()
const
;
56
57
std::string GetStringValue()
const
;
58
size_t
GetStringSize()
const
;
59
double
GetDoubleValue()
const
;
60
int64_t GetBigIntValue()
const
;
61
int32_t GetIntValue()
const
;
62
63
size_t
Size()
const
;
64
Node
GetArrayElement(
size_t
index)
const
;
65
std::string GetObjectKey(
size_t
index)
const
;
66
Node
GetObjectValue(
size_t
index)
const
;
67
Node
GetObjectValue(
const
char
*key)
const
;
68
69
private
:
70
sajson::value
m_value;
71
};
72
73
class
Document
74
{
75
public
:
76
Document
(
NSROOT::WSResponse
& resp);
77
~
Document
()
78
{
79
SAFE_DELETE(m_document);
80
}
81
82
bool
IsValid()
const
83
{
84
return
m_isValid;
85
}
86
87
Node
GetRoot()
const
;
88
89
private
:
90
bool
m_isValid;
91
sajson::document
*m_document;
92
};
93
}
94
}
95
96
#endif
/* JSONPARSER_H */
NSROOT::JSON::Node
Definition:
jsonparser.h:41
sajson::document
Definition:
sajson.h:401
sajson::value
Definition:
sajson.h:287
NSROOT::JSON::Document
Definition:
jsonparser.h:73
NSROOT::WSResponse
Definition:
wsresponse.h:40
NSROOT
Definition:
compressor.h:30
cppmyth
src
private
jsonparser.h
Generated on Thu Jan 9 2020 15:17:59 for CPPMyth by
1.8.13