Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
R
rapidjson
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
rapidjson
Commits
60b8c119
Commit
60b8c119
authored
Jun 25, 2014
by
Milo Yip
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/miloyip/rapidjson
parents
a7430a09
f1a2c28a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
14 deletions
+25
-14
allocators.h
include/rapidjson/allocators.h
+5
-0
document.h
include/rapidjson/document.h
+19
-13
filestream.h
include/rapidjson/filestream.h
+1
-1
No files found.
include/rapidjson/allocators.h
View file @
60b8c119
...
...
@@ -187,6 +187,11 @@ public:
static
void
Free
(
void
*
ptr
)
{
(
void
)
ptr
;
}
// Do nothing
private
:
//! Copy constructor is not permitted.
MemoryPoolAllocator
(
const
MemoryPoolAllocator
&
rhs
)
/* = delete */
;
//! Copy assignment operator is not permitted.
MemoryPoolAllocator
&
operator
=
(
const
MemoryPoolAllocator
&
rhs
)
/* = delete */
;
//! Creates a new chunk.
/*! \param capacity Capacity of the chunk in bytes.
*/
...
...
include/rapidjson/document.h
View file @
60b8c119
...
...
@@ -63,31 +63,31 @@ public:
GenericValue
(
Type
type
)
:
data_
()
{
static
const
unsigned
defaultFlags
[
7
]
=
{
kNullFlag
,
kFalseFlag
,
kTrueFlag
,
kObjectFlag
,
kArrayFlag
,
kConstStringFlag
,
kNumber
Flag
|
kIntFlag
|
kUintFlag
|
kInt64Flag
|
kUint64Flag
|
kDouble
Flag
kNumber
Any
Flag
};
RAPIDJSON_ASSERT
(
type
<=
kNumberType
);
flags_
=
defaultFlags
[
type
];
}
//! Constructor for boolean value.
GenericValue
(
bool
b
)
:
flags_
(
b
?
kTrueFlag
:
kFalseFlag
)
{}
explicit
GenericValue
(
bool
b
)
:
flags_
(
b
?
kTrueFlag
:
kFalseFlag
)
{}
//! Constructor for int value.
GenericValue
(
int
i
)
:
flags_
(
kNumberIntFlag
)
{
explicit
GenericValue
(
int
i
)
:
flags_
(
kNumberIntFlag
)
{
data_
.
n
.
i64
=
i
;
if
(
i
>=
0
)
flags_
|=
kUintFlag
|
kUint64Flag
;
}
//! Constructor for unsigned value.
GenericValue
(
unsigned
u
)
:
flags_
(
kNumberUintFlag
)
{
explicit
GenericValue
(
unsigned
u
)
:
flags_
(
kNumberUintFlag
)
{
data_
.
n
.
u64
=
u
;
if
(
!
(
u
&
0x80000000
))
flags_
|=
kIntFlag
|
kInt64Flag
;
}
//! Constructor for int64_t value.
GenericValue
(
int64_t
i64
)
:
flags_
(
kNumberInt64Flag
)
{
explicit
GenericValue
(
int64_t
i64
)
:
flags_
(
kNumberInt64Flag
)
{
data_
.
n
.
i64
=
i64
;
if
(
i64
>=
0
)
{
flags_
|=
kNumberUint64Flag
;
...
...
@@ -101,7 +101,7 @@ public:
}
//! Constructor for uint64_t value.
GenericValue
(
uint64_t
u64
)
:
flags_
(
kNumberUint64Flag
)
{
explicit
GenericValue
(
uint64_t
u64
)
:
flags_
(
kNumberUint64Flag
)
{
data_
.
n
.
u64
=
u64
;
if
(
!
(
u64
&
UINT64_C
(
0x8000000000000000
)))
flags_
|=
kInt64Flag
;
...
...
@@ -112,7 +112,7 @@ public:
}
//! Constructor for double value.
GenericValue
(
double
d
)
:
flags_
(
kNumberDoubleFlag
)
{
data_
.
n
.
d
=
d
;
}
explicit
GenericValue
(
double
d
)
:
flags_
(
kNumberDoubleFlag
)
{
data_
.
n
.
d
=
d
;
}
//! Constructor for constant string (i.e. do not make a copy of string)
GenericValue
(
const
Ch
*
s
,
SizeType
length
)
{
...
...
@@ -123,7 +123,7 @@ public:
}
//! Constructor for constant string (i.e. do not make a copy of string)
GenericValue
(
const
Ch
*
s
)
{
SetStringRaw
(
s
,
internal
::
StrLen
(
s
));
}
explicit
GenericValue
(
const
Ch
*
s
)
{
SetStringRaw
(
s
,
internal
::
StrLen
(
s
));
}
//! Constructor for copy-string (i.e. do make a copy of string)
GenericValue
(
const
Ch
*
s
,
SizeType
length
,
Allocator
&
allocator
)
{
SetStringRaw
(
s
,
length
,
allocator
);
}
...
...
@@ -631,6 +631,7 @@ private:
kNumberInt64Flag
=
kNumberType
|
kNumberFlag
|
kInt64Flag
,
kNumberUint64Flag
=
kNumberType
|
kNumberFlag
|
kUint64Flag
,
kNumberDoubleFlag
=
kNumberType
|
kNumberFlag
|
kDoubleFlag
,
kNumberAnyFlag
=
kNumberType
|
kNumberFlag
|
kIntFlag
|
kInt64Flag
|
kUintFlag
|
kUint64Flag
|
kDoubleFlag
,
kConstStringFlag
=
kStringType
|
kStringFlag
,
kCopyStringFlag
=
kStringType
|
kStringFlag
|
kCopyFlag
,
kObjectFlag
=
kObjectType
,
...
...
@@ -694,17 +695,17 @@ private:
};
// 12 bytes in 32-bit mode, 16 bytes in 64-bit mode
// Initialize this value as array with initial data, without calling destructor.
void
SetArrayRaw
(
GenericValue
*
values
,
SizeType
count
,
Allocator
&
alloc
ta
or
)
{
void
SetArrayRaw
(
GenericValue
*
values
,
SizeType
count
,
Allocator
&
alloc
at
or
)
{
flags_
=
kArrayFlag
;
data_
.
a
.
elements
=
(
GenericValue
*
)
alloc
ta
or
.
Malloc
(
count
*
sizeof
(
GenericValue
));
data_
.
a
.
elements
=
(
GenericValue
*
)
alloc
at
or
.
Malloc
(
count
*
sizeof
(
GenericValue
));
memcpy
(
data_
.
a
.
elements
,
values
,
count
*
sizeof
(
GenericValue
));
data_
.
a
.
size
=
data_
.
a
.
capacity
=
count
;
}
//! Initialize this value as object with initial data, without calling destructor.
void
SetObjectRaw
(
Member
*
members
,
SizeType
count
,
Allocator
&
alloc
ta
or
)
{
void
SetObjectRaw
(
Member
*
members
,
SizeType
count
,
Allocator
&
alloc
at
or
)
{
flags_
=
kObjectFlag
;
data_
.
o
.
members
=
(
Member
*
)
alloc
ta
or
.
Malloc
(
count
*
sizeof
(
Member
));
data_
.
o
.
members
=
(
Member
*
)
alloc
at
or
.
Malloc
(
count
*
sizeof
(
Member
));
memcpy
(
data_
.
o
.
members
,
members
,
count
*
sizeof
(
Member
));
data_
.
o
.
size
=
data_
.
o
.
capacity
=
count
;
}
...
...
@@ -772,7 +773,7 @@ public:
template
<
unsigned
parseFlags
,
typename
SourceEncoding
,
typename
InputStream
>
GenericDocument
&
ParseStream
(
InputStream
&
is
)
{
ValueType
::
SetNull
();
// Remove existing root if exist
GenericReader
<
SourceEncoding
,
Encoding
,
Allocator
>
reader
;
GenericReader
<
SourceEncoding
,
Encoding
,
Allocator
>
reader
(
&
GetAllocator
())
;
if
(
reader
.
template
Parse
<
parseFlags
>
(
is
,
*
this
))
{
RAPIDJSON_ASSERT
(
stack_
.
GetSize
()
==
sizeof
(
ValueType
));
// Got one and only one root object
this
->
RawAssign
(
*
stack_
.
template
Pop
<
ValueType
>
(
1
));
// Add this-> to prevent issue 13.
...
...
@@ -787,6 +788,11 @@ public:
return
*
this
;
}
template
<
unsigned
parseFlags
,
typename
InputStream
>
GenericDocument
&
ParseStream
(
InputStream
&
is
)
{
return
ParseStream
<
parseFlags
,
Encoding
,
InputStream
>
(
is
);
}
//! Parse JSON text from a mutable string.
/*! \tparam parseFlags Combination of ParseFlag.
\param str Mutable zero-terminated string to be parsed.
...
...
include/rapidjson/filestream.h
View file @
60b8c119
...
...
@@ -16,7 +16,7 @@ class FileStream {
public
:
typedef
char
Ch
;
//!< Character type. Only support char.
FileStream
(
FILE
*
fp
)
:
fp_
(
fp
),
count_
(
0
)
{
Read
();
}
FileStream
(
FILE
*
fp
)
:
fp_
(
fp
),
c
urrent_
(
'\0'
),
c
ount_
(
0
)
{
Read
();
}
char
Peek
()
const
{
return
current_
;
}
char
Take
()
{
char
c
=
current_
;
Read
();
return
c
;
}
size_t
Tell
()
const
{
return
count_
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment