Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
json
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
json
Commits
d035fa58
Commit
d035fa58
authored
Jul 04, 2013
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- added missing headers
parent
ff41ca8f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
12 deletions
+10
-12
src/JSON.cc
src/JSON.cc
+10
-12
No files found.
src/JSON.cc
View file @
d035fa58
...
...
@@ -7,11 +7,9 @@
#include <iostream>
#include <streambuf>
#include <sstream>
#ifndef __cplusplus11
#include <cstring>
#include <cstdlib>
#
endif
#
include <cstddef>
#ifdef __cplusplus11
using
std
::
to_string
;
...
...
@@ -576,8 +574,8 @@ std::string JSON::_typename() const {
JSON
::
parser
::
parser
(
char
*
s
)
:
_pos
(
0
)
{
_buffer
=
new
char
[
strlen
(
s
)
+
1
];
strcpy
(
_buffer
,
s
);
_buffer
=
new
char
[
st
d
::
st
rlen
(
s
)
+
1
];
st
d
::
st
rcpy
(
_buffer
,
s
);
// read first character
next
();
...
...
@@ -585,7 +583,7 @@ JSON::parser::parser(char* s) : _pos(0) {
JSON
::
parser
::
parser
(
std
::
string
&
s
)
:
_pos
(
0
)
{
_buffer
=
new
char
[
s
.
length
()
+
1
];
strcpy
(
_buffer
,
s
.
c_str
());
st
d
::
st
rcpy
(
_buffer
,
s
.
c_str
());
// read first character
next
();
...
...
@@ -626,7 +624,7 @@ bool JSON::parser::next() {
std
::
string
JSON
::
parser
::
parseString
()
{
// get position of closing quotes
char
*
p
=
strchr
(
_buffer
+
_pos
,
'\"'
);
char
*
p
=
st
d
::
st
rchr
(
_buffer
+
_pos
,
'\"'
);
// if the closing quotes are escaped (viz. *(p-1) is '\\'),
// we continue looking for the "right" quotes
...
...
@@ -634,7 +632,7 @@ std::string JSON::parser::parseString() {
// length of the string so far
const
size_t
length
=
p
-
_buffer
-
_pos
;
// continue checking after escaped quote
p
=
strchr
(
_buffer
+
_pos
+
length
+
1
,
'\"'
);
p
=
st
d
::
st
rchr
(
_buffer
+
_pos
+
length
+
1
,
'\"'
);
}
// check if closing quotes were found
...
...
@@ -645,7 +643,7 @@ std::string JSON::parser::parseString() {
// copy string to return value
const
size_t
length
=
p
-
_buffer
-
_pos
;
char
*
tmp
=
new
char
[
length
+
1
];
strncpy
(
tmp
,
_buffer
+
_pos
,
length
);
st
d
::
st
rncpy
(
tmp
,
_buffer
+
_pos
,
length
);
std
::
string
result
(
tmp
);
delete
[]
tmp
;
...
...
@@ -659,7 +657,7 @@ std::string JSON::parser::parseString() {
}
void
JSON
::
parser
::
parseTrue
()
{
if
(
strncmp
(
_buffer
+
_pos
,
"rue"
,
3
))
{
if
(
st
d
::
st
rncmp
(
_buffer
+
_pos
,
"rue"
,
3
))
{
error
(
"expected true"
);
}
...
...
@@ -670,7 +668,7 @@ void JSON::parser::parseTrue() {
}
void
JSON
::
parser
::
parseFalse
()
{
if
(
strncmp
(
_buffer
+
_pos
,
"alse"
,
4
))
{
if
(
st
d
::
st
rncmp
(
_buffer
+
_pos
,
"alse"
,
4
))
{
error
(
"expected false"
);
}
...
...
@@ -681,7 +679,7 @@ void JSON::parser::parseFalse() {
}
void
JSON
::
parser
::
parseNull
()
{
if
(
strncmp
(
_buffer
+
_pos
,
"ull"
,
3
))
{
if
(
st
d
::
st
rncmp
(
_buffer
+
_pos
,
"ull"
,
3
))
{
error
(
"expected null"
);
}
...
...
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