Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
json
Commits
4e443900
Commit
4e443900
authored
Dec 29, 2014
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
+ fixed a bug in the stream input
parent
15a9d3cf
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
7 deletions
+20
-7
.gitignore
.gitignore
+2
-0
Makefile.am
Makefile.am
+5
-1
parse.cc
benchmark/parse.cc
+8
-0
JSON.cc
src/JSON.cc
+5
-6
No files found.
.gitignore
View file @
4e443900
...
...
@@ -34,3 +34,5 @@ test-driver
Makefile.in
*.plist
json_parser
Makefile.am
View file @
4e443900
noinst_PROGRAMS
=
json_unit
noinst_PROGRAMS
=
json_unit
json_parser
FLAGS
=
-Wall
-Wextra
-pedantic
-Weffc
++
-Wcast-align
-Wcast-qual
-Wctor-dtor-privacy
-Wdisabled-optimization
-Wformat
=
2
-Winit-self
-Wmissing-declarations
-Wmissing-include-dirs
-Wold-style-cast
-Woverloaded-virtual
-Wredundant-decls
-Wshadow
-Wsign-conversion
-Wsign-promo
-Wstrict-overflow
=
5
-Wswitch
-Wundef
-Wno-unused
-Wnon-virtual-dtor
-Wreorder
...
...
@@ -6,6 +6,10 @@ json_unit_SOURCES = src/JSON.cc src/JSON.h test/catch.hpp test/JSON_unit.cc
json_unit_CXXFLAGS
=
$(FLAGS)
-std
=
c++11
json_unit_CPPFLAGS
=
-I
$(top_srcdir)
/src
-I
$(top_srcdir)
/test
-Dprivate
=
public
json_parser_SOURCES
=
src/JSON.cc src/JSON.h benchmark/parse.cc
json_parser_CXXFLAGS
=
$(FLAGS)
-std
=
c++11
json_parser_CPPFLAGS
=
-I
$(top_srcdir)
/src
-I
$(top_srcdir)
/benchmark
cppcheck
:
cppcheck
--enable
=
all
--inconclusive
--std
=
c++11 src/JSON.
*
...
...
benchmark/parse.cc
0 → 100644
View file @
4e443900
#include "JSON.h"
int
main
()
{
JSON
j
;
j
<<
std
::
cin
;
return
0
;
}
src/JSON.cc
View file @
4e443900
...
...
@@ -1775,14 +1775,13 @@ Initialize the JSON parser given an input stream \p _is.
*/
JSON
::
Parser
::
Parser
(
std
::
istream
&
_is
)
{
// determine length of input stream
_is
.
seekg
(
0
,
std
::
ios
::
end
);
_length
=
static_cast
<
size_t
>
(
_is
.
tellg
());
_is
.
seekg
(
0
,
std
::
ios
::
beg
);
// copy stream to string
std
::
istreambuf_iterator
<
char
>
eos
;
std
::
string
string_input
(
std
::
istreambuf_iterator
<
char
>
(
_is
),
eos
);
// copy stream to buffer
_length
=
string_input
.
size
();
_buffer
=
new
char
[
_length
+
1
];
_is
.
read
(
_buffer
,
static_cast
<
std
::
streamsize
>
(
_length
));
std
::
strcpy
(
_buffer
,
string_input
.
c_str
(
));
// read first character
next
();
...
...
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