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
e8730e5e
Commit
e8730e5e
authored
Sep 29, 2018
by
Julian Becker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BSON: Reworked `binary_reader::get_bson_cstr()`
parent
0a09db9c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
40 deletions
+22
-40
include/nlohmann/detail/input/binary_reader.hpp
include/nlohmann/detail/input/binary_reader.hpp
+11
-20
single_include/nlohmann/json.hpp
single_include/nlohmann/json.hpp
+11
-20
No files found.
include/nlohmann/detail/input/binary_reader.hpp
View file @
e8730e5e
...
...
@@ -125,36 +125,27 @@ class binary_reader
private:
template
<
class
OutputIt
,
class
UnaryPredicate
,
class
Gen
>
OutputIt
generate_until
(
OutputIt
&&
d_first
,
UnaryPredicate
&&
pred
,
Gen
&&
gen
)
{
for
(
auto
x
=
gen
();
!
pred
(
x
);
x
=
gen
())
{
*
d_first
++
=
x
;
}
return
d_first
;
}
/*!
@return whether array creation completed
*/
bool
get_bson_cstr
(
string_t
&
result
)
{
bool
success
=
true
;
generate_until
(
std
::
back_inserter
(
result
),
[
&
success
](
char
c
)
{
return
c
==
0x00
||
!
success
;
},
[
this
,
&
success
]
auto
out
=
std
::
back_inserter
(
result
);
while
(
true
)
{
get
();
if
(
JSON_UNLIKELY
(
not
unexpect_eof
()))
{
success
=
false
;
return
false
;
}
return
static_cast
<
char
>
(
current
);
});
return
success
;
if
(
current
==
0x00
)
{
return
true
;
}
*
out
++
=
static_cast
<
char
>
(
current
);
}
return
true
;
}
bool
parse_bson_entries
(
bool
is_array
)
...
...
single_include/nlohmann/json.hpp
View file @
e8730e5e
...
...
@@ -6109,36 +6109,27 @@ class binary_reader
private:
template
<
class
OutputIt
,
class
UnaryPredicate
,
class
Gen
>
OutputIt
generate_until
(
OutputIt
&&
d_first
,
UnaryPredicate
&&
pred
,
Gen
&&
gen
)
{
for
(
auto
x
=
gen
();
!
pred
(
x
);
x
=
gen
())
{
*
d_first
++
=
x
;
}
return
d_first
;
}
/*!
@return whether array creation completed
*/
bool
get_bson_cstr
(
string_t
&
result
)
{
bool
success
=
true
;
generate_until
(
std
::
back_inserter
(
result
),
[
&
success
](
char
c
)
{
return
c
==
0x00
||
!
success
;
},
[
this
,
&
success
]
auto
out
=
std
::
back_inserter
(
result
);
while
(
true
)
{
get
();
if
(
JSON_UNLIKELY
(
not
unexpect_eof
()))
{
success
=
false
;
return
false
;
}
return
static_cast
<
char
>
(
current
);
});
return
success
;
if
(
current
==
0x00
)
{
return
true
;
}
*
out
++
=
static_cast
<
char
>
(
current
);
}
return
true
;
}
bool
parse_bson_entries
(
bool
is_array
)
...
...
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