Open Lighting Architecture
0.9.1
Main Page
Modules
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
include
ola
web
JsonTypes.h
Go to the documentation of this file.
1
/*
2
* This library is free software; you can redistribute it and/or
3
* modify it under the terms of the GNU Lesser General Public
4
* License as published by the Free Software Foundation; either
5
* version 2.1 of the License, or (at your option) any later version.
6
*
7
* This library is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10
* Lesser General Public License for more details.
11
*
12
* You should have received a copy of the GNU Lesser General Public
13
* License along with this library; if not, write to the Free Software
14
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15
*
16
* JsonTypes.h
17
* Enums for the Json types.
18
* See http://www.json.org/
19
* Copyright (C) 2014 Simon Newton
20
*/
21
30
#ifndef INCLUDE_OLA_WEB_JSONTYPES_H_
31
#define INCLUDE_OLA_WEB_JSONTYPES_H_
32
33
#include <stdint.h>
34
#include <string>
35
36
namespace
ola {
37
namespace
web {
38
44
enum
JsonType
{
45
JSON_ARRAY
,
46
JSON_BOOLEAN
,
47
JSON_INTEGER
,
48
JSON_NULL
,
49
JSON_NUMBER
,
50
JSON_OBJECT
,
51
JSON_STRING
,
52
JSON_UNDEFINED
,
53
};
54
60
std::string
JsonTypeToString
(
JsonType
type);
61
68
JsonType
StringToJsonType(
const
std::string &type);
69
73
template
<
typename
T>
74
JsonType
TypeFromValue
(
const
T&);
75
79
template
<
typename
T>
80
std::string
GetTypename
(
const
T&t) {
81
return
TypeToString(
TypeFromValue
(t));
82
}
83
84
template
<>
85
inline
JsonType
TypeFromValue<std::string>(
const
std::string&) {
86
return
JSON_STRING
;
87
}
88
89
template
<>
90
inline
JsonType
TypeFromValue<bool>(
const
bool
&) {
return
JSON_BOOLEAN
; }
91
92
template
<>
93
inline
JsonType
TypeFromValue<uint32_t>(
const
uint32_t&) {
94
return
JSON_INTEGER
;
95
}
96
97
template
<>
98
inline
JsonType
TypeFromValue<int32_t>(
const
int32_t&) {
return
JSON_INTEGER
; }
99
100
template
<>
101
inline
JsonType
TypeFromValue<uint64_t>(
const
uint64_t&) {
102
return
JSON_INTEGER
;
103
}
104
105
template
<>
106
inline
JsonType
TypeFromValue<int64_t>(
const
int64_t&) {
return
JSON_INTEGER
; }
107
108
template
<>
109
inline
JsonType
TypeFromValue<double>(
const
double
&) {
return
JSON_NUMBER
; }
110
111
template
<
typename
T>
112
inline
JsonType
TypeFromValue
(
const
T&) {
return
JSON_UNDEFINED
; }
113
114
}
// namespace web
115
}
// namespace ola
116
#endif // INCLUDE_OLA_WEB_JSONTYPES_H_
Generated on Tue Jun 24 2014 03:57:51 for Open Lighting Architecture by
1.8.1.2