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
1a1381f0
Commit
1a1381f0
authored
4 years ago
by
David Pfahler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #2728
includes some macros to be defined for using without file io.
parent
db78ac1d
develop
bon8
coverity_scan
gcc_warning_flags
icpc
issue2932
issue3232_use_catch
master
release/3.10.2
release/3.10.3
release/3.10.4
release/3.10.5
string_view
string_view2
update_doctest
v3.10.5
v3.10.4
v3.10.3
v3.10.2
v3.10.1
v3.10.0
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
4 deletions
+12
-4
include/nlohmann/detail/input/input_adapters.hpp
include/nlohmann/detail/input/input_adapters.hpp
+4
-0
include/nlohmann/detail/output/output_adapters.hpp
include/nlohmann/detail/output/output_adapters.hpp
+4
-0
include/nlohmann/json.hpp
include/nlohmann/json.hpp
+4
-4
No files found.
include/nlohmann/detail/input/input_adapters.hpp
View file @
1a1381f0
...
@@ -26,6 +26,7 @@ enum class input_format_t { json, cbor, msgpack, ubjson, bson };
...
@@ -26,6 +26,7 @@ enum class input_format_t { json, cbor, msgpack, ubjson, bson };
// input adapters //
// input adapters //
////////////////////
////////////////////
#ifndef JSON_NO_IO
/*!
/*!
Input adapter for stdio file access. This adapter read only 1 byte and do not use any
Input adapter for stdio file access. This adapter read only 1 byte and do not use any
buffer. This adapter is a very low level adapter.
buffer. This adapter is a very low level adapter.
...
@@ -115,6 +116,7 @@ class input_stream_adapter
...
@@ -115,6 +116,7 @@ class input_stream_adapter
std
::
istream
*
is
=
nullptr
;
std
::
istream
*
is
=
nullptr
;
std
::
streambuf
*
sb
=
nullptr
;
std
::
streambuf
*
sb
=
nullptr
;
};
};
#endif // JSON_NO_IO
// General-purpose iterator-based adapter. It might not be as fast as
// General-purpose iterator-based adapter. It might not be as fast as
// theoretically possible for some containers, but it is extremely versatile.
// theoretically possible for some containers, but it is extremely versatile.
...
@@ -381,6 +383,7 @@ auto input_adapter(const ContainerType& container) -> decltype(input_adapter(beg
...
@@ -381,6 +383,7 @@ auto input_adapter(const ContainerType& container) -> decltype(input_adapter(beg
return
input_adapter
(
begin
(
container
),
end
(
container
));
return
input_adapter
(
begin
(
container
),
end
(
container
));
}
}
#ifndef JSON_NO_IO
// Special cases with fast paths
// Special cases with fast paths
inline
file_input_adapter
input_adapter
(
std
::
FILE
*
file
)
inline
file_input_adapter
input_adapter
(
std
::
FILE
*
file
)
{
{
...
@@ -396,6 +399,7 @@ inline input_stream_adapter input_adapter(std::istream&& stream)
...
@@ -396,6 +399,7 @@ inline input_stream_adapter input_adapter(std::istream&& stream)
{
{
return
input_stream_adapter
(
stream
);
return
input_stream_adapter
(
stream
);
}
}
#endif // JSON_NO_IO
using
contiguous_bytes_input_adapter
=
decltype
(
input_adapter
(
std
::
declval
<
const
char
*>
(),
std
::
declval
<
const
char
*>
()));
using
contiguous_bytes_input_adapter
=
decltype
(
input_adapter
(
std
::
declval
<
const
char
*>
(),
std
::
declval
<
const
char
*>
()));
...
...
This diff is collapsed.
Click to expand it.
include/nlohmann/detail/output/output_adapters.hpp
View file @
1a1381f0
...
@@ -50,6 +50,7 @@ class output_vector_adapter : public output_adapter_protocol<CharType>
...
@@ -50,6 +50,7 @@ class output_vector_adapter : public output_adapter_protocol<CharType>
std
::
vector
<
CharType
>&
v
;
std
::
vector
<
CharType
>&
v
;
};
};
#ifndef JSON_NO_IO
/// output adapter for output streams
/// output adapter for output streams
template
<
typename
CharType
>
template
<
typename
CharType
>
class
output_stream_adapter
:
public
output_adapter_protocol
<
CharType
>
class
output_stream_adapter
:
public
output_adapter_protocol
<
CharType
>
...
@@ -73,6 +74,7 @@ class output_stream_adapter : public output_adapter_protocol<CharType>
...
@@ -73,6 +74,7 @@ class output_stream_adapter : public output_adapter_protocol<CharType>
private:
private:
std
::
basic_ostream
<
CharType
>&
stream
;
std
::
basic_ostream
<
CharType
>&
stream
;
};
};
#endif // JSON_NO_IO
/// output adapter for basic_string
/// output adapter for basic_string
template
<
typename
CharType
,
typename
StringType
=
std
::
basic_string
<
CharType
>
>
template
<
typename
CharType
,
typename
StringType
=
std
::
basic_string
<
CharType
>
>
...
@@ -105,8 +107,10 @@ class output_adapter
...
@@ -105,8 +107,10 @@ class output_adapter
output_adapter
(
std
::
vector
<
CharType
>&
vec
)
output_adapter
(
std
::
vector
<
CharType
>&
vec
)
:
oa
(
std
::
make_shared
<
output_vector_adapter
<
CharType
>>
(
vec
))
{}
:
oa
(
std
::
make_shared
<
output_vector_adapter
<
CharType
>>
(
vec
))
{}
#ifndef JSON_NO_IO
output_adapter
(
std
::
basic_ostream
<
CharType
>&
s
)
output_adapter
(
std
::
basic_ostream
<
CharType
>&
s
)
:
oa
(
std
::
make_shared
<
output_stream_adapter
<
CharType
>>
(
s
))
{}
:
oa
(
std
::
make_shared
<
output_stream_adapter
<
CharType
>>
(
s
))
{}
#endif // JSON_NO_IO
output_adapter
(
StringType
&
s
)
output_adapter
(
StringType
&
s
)
:
oa
(
std
::
make_shared
<
output_string_adapter
<
CharType
,
StringType
>>
(
s
))
{}
:
oa
(
std
::
make_shared
<
output_string_adapter
<
CharType
,
StringType
>>
(
s
))
{}
...
...
This diff is collapsed.
Click to expand it.
include/nlohmann/json.hpp
View file @
1a1381f0
...
@@ -6521,7 +6521,7 @@ class basic_json
...
@@ -6521,7 +6521,7 @@ class basic_json
/// @name serialization
/// @name serialization
/// @{
/// @{
#ifndef JSON_NO_IO
/*!
/*!
@brief serialize to stream
@brief serialize to stream
...
@@ -6581,7 +6581,7 @@ class basic_json
...
@@ -6581,7 +6581,7 @@ class basic_json
{
{
return
o
<<
j
;
return
o
<<
j
;
}
}
#endif // JSON_NO_IO
/// @}
/// @}
...
@@ -6837,7 +6837,7 @@ class basic_json
...
@@ -6837,7 +6837,7 @@ class basic_json
?
parser
(
std
::
move
(
ia
),
nullptr
,
true
,
ignore_comments
).
sax_parse
(
sax
,
strict
)
?
parser
(
std
::
move
(
ia
),
nullptr
,
true
,
ignore_comments
).
sax_parse
(
sax
,
strict
)
:
detail
::
binary_reader
<
basic_json
,
decltype
(
ia
),
SAX
>
(
std
::
move
(
ia
)).
sax_parse
(
format
,
sax
,
strict
);
:
detail
::
binary_reader
<
basic_json
,
decltype
(
ia
),
SAX
>
(
std
::
move
(
ia
)).
sax_parse
(
format
,
sax
,
strict
);
}
}
#ifndef JSON_NO_IO
/*!
/*!
@brief deserialize from stream
@brief deserialize from stream
@deprecated This stream operator is deprecated and will be removed in
@deprecated This stream operator is deprecated and will be removed in
...
@@ -6882,7 +6882,7 @@ class basic_json
...
@@ -6882,7 +6882,7 @@ class basic_json
parser
(
detail
::
input_adapter
(
i
)).
parse
(
false
,
j
);
parser
(
detail
::
input_adapter
(
i
)).
parse
(
false
,
j
);
return
i
;
return
i
;
}
}
#endif // JSON_NO_IO
/// @}
/// @}
///////////////////////////
///////////////////////////
...
...
This diff is collapsed.
Click to expand it.
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