webkit
2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
Source
ThirdParty
libwebrtc
Source
third_party
jsoncpp
source
src
lib_json
json_tool.h
Go to the documentation of this file.
1
// Copyright 2007-2010 Baptiste Lepilleur
2
// Distributed under MIT license, or public domain if desired and
3
// recognized in your jurisdiction.
4
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
5
6
#ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED
7
# define LIB_JSONCPP_JSON_TOOL_H_INCLUDED
8
9
/* This header provides common string manipulation support, such as UTF-8,
10
* portable conversion from/to string...
11
*
12
* It is an internal header that must not be exposed.
13
*/
14
15
namespace
Json
{
16
18
static
inline
std::string
19
codePointToUTF8(
unsigned
int
cp)
20
{
21
std::string
result
;
22
23
// based on description from http://en.wikipedia.org/wiki/UTF-8
24
25
if
(cp <= 0x7f)
26
{
27
result.resize(1);
28
result[0] =
static_cast<
char
>
(cp);
29
}
30
else
if
(cp <= 0x7FF)
31
{
32
result.resize(2);
33
result[1] =
static_cast<
char
>
(0x80 | (0x3f & cp));
34
result[0] =
static_cast<
char
>
(0xC0 | (0x1f & (cp >> 6)));
35
}
36
else
if
(cp <= 0xFFFF)
37
{
38
result.resize(3);
39
result[2] =
static_cast<
char
>
(0x80 | (0x3f & cp));
40
result[1] = 0x80 |
static_cast<
char
>
((0x3f & (cp >> 6)));
41
result[0] = 0xE0 |
static_cast<
char
>
((0xf & (cp >> 12)));
42
}
43
else
if
(cp <= 0x10FFFF)
44
{
45
result.resize(4);
46
result[3] =
static_cast<
char
>
(0x80 | (0x3f & cp));
47
result[2] =
static_cast<
char
>
(0x80 | (0x3f & (cp >> 6)));
48
result[1] =
static_cast<
char
>
(0x80 | (0x3f & (cp >> 12)));
49
result[0] =
static_cast<
char
>
(0xF0 | (0x7 & (cp >> 18)));
50
}
51
52
return
result
;
53
}
54
55
57
static
inline
bool
58
isControlCharacter(
char
ch)
59
{
60
return
ch > 0 && ch <= 0x1F;
61
}
62
63
64
enum
{
66
uintToStringBufferSize
= 3*
sizeof
(
LargestUInt
)+1
67
};
68
69
// Defines a char buffer for use with uintToString().
70
typedef
char
UIntToStringBuffer
[
uintToStringBufferSize
];
71
72
78
static
inline
void
79
uintToString(
LargestUInt
value
,
80
char
*¤t )
81
{
82
*--current = 0;
83
do
84
{
85
*--current = char(value % 10) +
'0'
;
86
value /= 10;
87
}
88
while
( value != 0 );
89
}
90
91
}
// namespace Json {
92
93
#endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED
Json::LargestUInt
UInt64 LargestUInt
Definition:
config.h:92
value
EGLAttrib * value
Definition:
eglext.h:120
Json
JSON (JavaScript Object Notation).
Definition:
value.h:26
string
GLsizei const GLchar *const * string
Definition:
gl2.h:479
result
result
Definition:
target-blank-opener-post-window.php:5
Json::uintToStringBufferSize
Constant that specify the size of the buffer that must be passed to uintToString. ...
Definition:
json_tool.h:66
Json::UIntToStringBuffer
char UIntToStringBuffer[uintToStringBufferSize]
Definition:
json_tool.h:70
Generated by
1.8.13