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
dfc2c1ab
Commit
dfc2c1ab
authored
Aug 14, 2016
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added assertion for contiguous memory
parent
92ee1d56
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
9 deletions
+21
-9
json.hpp
src/json.hpp
+7
-1
json.hpp.re2c
src/json.hpp.re2c
+7
-1
unit-class_parser.cpp
test/src/unit-class_parser.cpp
+7
-7
No files found.
src/json.hpp
View file @
dfc2c1ab
...
@@ -8902,7 +8902,13 @@ basic_json_parser_63:
...
@@ -8902,7 +8902,13 @@ basic_json_parser_63:
:
callback
(
cb
),
:
callback
(
cb
),
m_lexer
(
reinterpret_cast
<
const
typename
lexer
::
lexer_char_t
*>
(
&
(
*
first
)),
m_lexer
(
reinterpret_cast
<
const
typename
lexer
::
lexer_char_t
*>
(
&
(
*
first
)),
static_cast
<
size_t
>
(
std
::
distance
(
first
,
last
)))
static_cast
<
size_t
>
(
std
::
distance
(
first
,
last
)))
{}
{
int
i
=
0
;
assert
(
std
::
accumulate
(
first
,
last
,
true
,
[
&
i
,
&
first
](
bool
res
,
decltype
(
*
first
)
val
)
{
return
res
and
(
val
==
*
(
std
::
next
(
std
::
addressof
(
*
first
),
i
++
)));
}));
}
/// public parser interface
/// public parser interface
basic_json
parse
()
basic_json
parse
()
...
...
src/json.hpp.re2c
View file @
dfc2c1ab
...
@@ -8199,7 +8199,13 @@ class basic_json
...
@@ -8199,7 +8199,13 @@ class basic_json
: callback(cb),
: callback(cb),
m_lexer(reinterpret_cast<const typename lexer::lexer_char_t*>(&(*first)),
m_lexer(reinterpret_cast<const typename lexer::lexer_char_t*>(&(*first)),
static_cast<size_t>(std::distance(first, last)))
static_cast<size_t>(std::distance(first, last)))
{}
{
int i = 0;
assert(std::accumulate(first, last, true, [&i, &first](bool res, decltype(*first) val)
{
return res and (val == *(std::next(std::addressof(*first), i++)));
}));
}
/// public parser interface
/// public parser interface
basic_json parse()
basic_json parse()
...
...
test/src/unit-class_parser.cpp
View file @
dfc2c1ab
...
@@ -750,42 +750,42 @@ TEST_CASE("parser class")
...
@@ -750,42 +750,42 @@ TEST_CASE("parser class")
SECTION
(
"from std::vector"
)
SECTION
(
"from std::vector"
)
{
{
std
::
vector
<
uint8_t
>
v
=
{
't'
,
'r'
,
'u'
,
'e'
,
'\0'
};
std
::
vector
<
uint8_t
>
v
=
{
't'
,
'r'
,
'u'
,
'e'
,
'\0'
};
CHECK
(
json
::
parser
(
std
::
begin
(
v
),
std
::
end
(
v
)).
parse
()
==
json
(
true
));
CHECK
(
json
::
parser
(
std
::
begin
(
v
),
std
::
end
(
v
)).
parse
()
==
json
(
true
));
}
}
SECTION
(
"from std::array"
)
SECTION
(
"from std::array"
)
{
{
std
::
array
<
uint8_t
,
5
>
v
{
{
't'
,
'r'
,
'u'
,
'e'
,
'\0'
}
};
std
::
array
<
uint8_t
,
5
>
v
{
{
't'
,
'r'
,
'u'
,
'e'
,
'\0'
}
};
CHECK
(
json
::
parser
(
std
::
begin
(
v
),
std
::
end
(
v
)).
parse
()
==
json
(
true
));
CHECK
(
json
::
parser
(
std
::
begin
(
v
),
std
::
end
(
v
)).
parse
()
==
json
(
true
));
}
}
SECTION
(
"from array"
)
SECTION
(
"from array"
)
{
{
uint8_t
v
[]
=
{
't'
,
'r'
,
'u'
,
'e'
};
uint8_t
v
[]
=
{
't'
,
'r'
,
'u'
,
'e'
};
CHECK
(
json
::
parser
(
std
::
begin
(
v
),
std
::
end
(
v
)).
parse
()
==
json
(
true
));
CHECK
(
json
::
parser
(
std
::
begin
(
v
),
std
::
end
(
v
)).
parse
()
==
json
(
true
));
}
}
SECTION
(
"from char literal"
)
SECTION
(
"from char literal"
)
{
{
CHECK
(
json
::
parser
(
"true"
).
parse
()
==
json
(
true
));
CHECK
(
json
::
parser
(
"true"
).
parse
()
==
json
(
true
));
}
}
SECTION
(
"from std::string"
)
SECTION
(
"from std::string"
)
{
{
std
::
string
v
=
{
't'
,
'r'
,
'u'
,
'e'
};
std
::
string
v
=
{
't'
,
'r'
,
'u'
,
'e'
};
CHECK
(
json
::
parser
(
std
::
begin
(
v
),
std
::
end
(
v
)).
parse
()
==
json
(
true
));
CHECK
(
json
::
parser
(
std
::
begin
(
v
),
std
::
end
(
v
)).
parse
()
==
json
(
true
));
}
}
SECTION
(
"from std::initializer_list"
)
SECTION
(
"from std::initializer_list"
)
{
{
std
::
initializer_list
<
uint8_t
>
v
=
{
't'
,
'r'
,
'u'
,
'e'
,
'\0'
};
std
::
initializer_list
<
uint8_t
>
v
=
{
't'
,
'r'
,
'u'
,
'e'
,
'\0'
};
CHECK
(
json
::
parser
(
std
::
begin
(
v
),
std
::
end
(
v
)).
parse
()
==
json
(
true
));
CHECK
(
json
::
parser
(
std
::
begin
(
v
),
std
::
end
(
v
)).
parse
()
==
json
(
true
));
}
}
SECTION
(
"from std::valarray"
)
SECTION
(
"from std::valarray"
)
{
{
std
::
valarray
<
uint8_t
>
v
=
{
't'
,
'r'
,
'u'
,
'e'
,
'\0'
};
std
::
valarray
<
uint8_t
>
v
=
{
't'
,
'r'
,
'u'
,
'e'
,
'\0'
};
CHECK
(
json
::
parser
(
std
::
begin
(
v
),
std
::
end
(
v
)).
parse
()
==
json
(
true
));
CHECK
(
json
::
parser
(
std
::
begin
(
v
),
std
::
end
(
v
)).
parse
()
==
json
(
true
));
}
}
}
}
}
}
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