📝 cleanup after the last PRs
This commit is contained in:
parent
be4fba7baf
commit
b0c380b0f8
6 changed files with 97 additions and 89 deletions
|
@ -875,7 +875,12 @@ I deeply appreciate the help of the following people.
|
||||||
- [WebProdPP](https://github.com/WebProdPP) fixed a subtle error in a precondition check.
|
- [WebProdPP](https://github.com/WebProdPP) fixed a subtle error in a precondition check.
|
||||||
- [Alex](https://github.com/leha-bot) noted an error in a code sample.
|
- [Alex](https://github.com/leha-bot) noted an error in a code sample.
|
||||||
- [Tom de Geus](https://github.com/tdegeus) reported some warnings with ICC and helped fixing them.
|
- [Tom de Geus](https://github.com/tdegeus) reported some warnings with ICC and helped fixing them.
|
||||||
|
- [Perry Kundert](https://github.com/pjkundert) simplified reading from input streams.
|
||||||
|
- [Sonu Lohani](https://github.com/sonulohani) fixed a small compilation error.
|
||||||
|
- [Jamie Seward](https://github.com/jseward) fixed all MSVC warnings.
|
||||||
|
- [Nate Vargas](https://github.com/eld00d) added a Doxygen tag file.
|
||||||
|
- [pvleuven](https://github.com/pvleuven) helped fixing a warning in ICC.
|
||||||
|
- [Pavel](https://github.com/crea7or) helped fixing some warnings in MSVC.
|
||||||
|
|
||||||
Thanks a lot for helping out! Please [let me know](mailto:mail@nlohmann.me) if I forgot someone.
|
Thanks a lot for helping out! Please [let me know](mailto:mail@nlohmann.me) if I forgot someone.
|
||||||
|
|
||||||
|
|
35
src/json.hpp
35
src/json.hpp
|
@ -1404,39 +1404,42 @@ consist of all valid char values as positive values (typically unsigned char),
|
||||||
plus an EOF value outside that range, specified by the value of the function
|
plus an EOF value outside that range, specified by the value of the function
|
||||||
std::char_traits<char>::eof(). This value is typically -1, but could be any
|
std::char_traits<char>::eof(). This value is typically -1, but could be any
|
||||||
arbitrary value which is not a valid char value.
|
arbitrary value which is not a valid char value.
|
||||||
|
|
||||||
@return Typically [0,255] plus std::char_traits<char>::eof().
|
|
||||||
*/
|
*/
|
||||||
struct input_adapter_protocol
|
struct input_adapter_protocol
|
||||||
{
|
{
|
||||||
|
/// get a character [0,255] or std::char_traits<char>::eof().
|
||||||
virtual std::char_traits<char>::int_type get_character() = 0;
|
virtual std::char_traits<char>::int_type get_character() = 0;
|
||||||
virtual void unget_character() = 0; // restore the last non-eof() character to input
|
/// restore the last non-eof() character to input
|
||||||
|
virtual void unget_character() = 0;
|
||||||
virtual ~input_adapter_protocol() = default;
|
virtual ~input_adapter_protocol() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// a type to simplify interfaces
|
/// a type to simplify interfaces
|
||||||
using input_adapter_t = std::shared_ptr<input_adapter_protocol>;
|
using input_adapter_t = std::shared_ptr<input_adapter_protocol>;
|
||||||
|
|
||||||
/// input adapter for a (caching) istream. Ignores a UFT Byte Order Mark at
|
/*!
|
||||||
/// beginning of input. Does not support changing the underlying std::streambuf
|
Input adapter for a (caching) istream. Ignores a UFT Byte Order Mark at
|
||||||
/// in mid-input. Maintains underlying std::istream and std::streambuf to
|
beginning of input. Does not support changing the underlying std::streambuf
|
||||||
/// support subsequent use of standard std::istream operations to process any
|
in mid-input. Maintains underlying std::istream and std::streambuf to support
|
||||||
/// input characters following those used in parsing the JSON input. Clears the
|
subsequent use of standard std::istream operations to process any input
|
||||||
/// std::istream flags; any input errors (eg. EOF) will be detected by the first
|
characters following those used in parsing the JSON input. Clears the
|
||||||
/// subsequent call for input from the std::istream.
|
std::istream flags; any input errors (e.g., EOF) will be detected by the first
|
||||||
|
subsequent call for input from the std::istream.
|
||||||
|
*/
|
||||||
class input_stream_adapter : public input_adapter_protocol
|
class input_stream_adapter : public input_adapter_protocol
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~input_stream_adapter() override
|
~input_stream_adapter() override
|
||||||
{
|
{
|
||||||
// clear stream flags; we use underlying streambuf I/O, do not maintain ifstream flags
|
// clear stream flags; we use underlying streambuf I/O, do not
|
||||||
|
// maintain ifstream flags
|
||||||
is.clear();
|
is.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit input_stream_adapter(std::istream& i)
|
explicit input_stream_adapter(std::istream& i)
|
||||||
: is(i)
|
: is(i), sb(*i.rdbuf())
|
||||||
, sb(*i.rdbuf())
|
|
||||||
{
|
{
|
||||||
// Ignore Byte Order Mark at start of input
|
// ignore Byte Order Mark at start of input
|
||||||
std::char_traits<char>::int_type c;
|
std::char_traits<char>::int_type c;
|
||||||
if ((c = get_character()) == 0xEF)
|
if ((c = get_character()) == 0xEF)
|
||||||
{
|
{
|
||||||
|
@ -1478,10 +1481,10 @@ class input_stream_adapter : public input_adapter_protocol
|
||||||
|
|
||||||
void unget_character() override
|
void unget_character() override
|
||||||
{
|
{
|
||||||
sb.sungetc(); // Avoided for performance: is.unget();
|
sb.sungetc(); // is.unget() avoided for performance
|
||||||
}
|
}
|
||||||
private:
|
|
||||||
|
|
||||||
|
private:
|
||||||
/// the associated input stream
|
/// the associated input stream
|
||||||
std::istream& is;
|
std::istream& is;
|
||||||
std::streambuf& sb;
|
std::streambuf& sb;
|
||||||
|
|
Loading…
Reference in a new issue