|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file.
74 throw std::runtime_error(
75 "Expected end of input while reading Json at " + input_stream.
at()
87 auto& it = input_stream;
101 }
else if( *it ==
'[' ) {
105 }
else if( *it ==
'{' ) {
109 }
else if( *it ==
'"' ) {
117 if( value ==
"null" ) {
121 }
else if( value ==
"true" ) {
123 }
else if( value ==
"false" ) {
126 throw std::runtime_error(
127 "Unexpected Json input string: '" + value +
"' at " + it.at() +
"."
132 }
else if(
is_digit( *it ) or ( *it ==
'+' ) or ( *it ==
'-' ) or ( *it ==
'.' )) {
137 throw std::runtime_error(
138 "Unexpected Json input char: '" + std::string( 1, *it ) +
"' at " + it.at() +
"."
150 auto& it = input_stream;
158 if( it && *it ==
']' ) {
159 assert( it && *it ==
']' );
170 if( !it || *it ==
']' ) {
180 if( !it || *it !=
']' ) {
181 throw std::runtime_error(
"Unexpected end of Json array at " + it.at() );
183 assert( it && *it ==
']' );
196 auto& it = input_stream;
204 if( it && *it ==
'}' ) {
205 assert( it && *it ==
'}' );
225 if( !it || *it ==
'}' ) {
235 if( !it || *it !=
'}' ) {
236 throw std::runtime_error(
"Unexpected end of Json object at " + it.at() );
238 assert( it && *it ==
'}' );
250 auto& it = input_stream;
253 throw std::runtime_error(
254 "Expecting number in " + it.source_name() +
" at " + it.at() +
"."
263 }
else if( *it ==
'+' ) {
268 bool found_mantisse =
false;
275 found_mantisse =
true;
279 if( found_mantisse && !( *it ==
'.' ||
utils::to_lower(*it) ==
'e' ) ) {
289 if( it && *it ==
'.' ) {
298 found_mantisse =
true;
303 if( ! found_mantisse ) {
304 throw std::runtime_error(
305 "Invalid float number in " + it.source_name() +
" at " + it.at() +
"."
314 int e = parse_signed_integer<int>( it );
325 if( ( e & 1 ) == 0 ) {
JsonDocument parse_object(InputStream &input_stream) const
static JsonDocument boolean(BooleanType value)
Explicitly create a boolean.
std::string read_while(InputStream &source, char criterion)
Lexing function that reads from the stream while its current char equals the provided one....
Provides functions for accessing the file system.
Store a Json value of any kind.
static JsonDocument number_unsigned(NumberUnsignedType value)
Explicitly create an unsigned number.
Provides some valuable additions to STD.
void affirm_char_or_throw(InputStream &source, char criterion, SkipWhitespace skip_ws=SkipWhitespace::kNone)
Lexing function that checks whether the current char from the stream equals the provided one.
Provides some commonly used string utility functions.
constexpr bool is_space(char c) noexcept
Return whether a char is some form of white space charater, so either space, tab, new line,...
void emplace_back(Args &&... args)
char read_char_or_throw(InputStream &source, char criterion, SkipWhitespace skip_ws=SkipWhitespace::kNone)
Lexing function that reads a single char from the stream and checks whether it equals the provided on...
static JsonDocument number_float(NumberFloatType value)
Explicitly create a float number.
JsonDocument parse_number(InputStream &input_stream) const
void skip_while(InputStream &source, char criterion)
Lexing function that advances the stream while its current char equals the provided one.
JsonDocument parse(InputStream &input_stream) const
static JsonDocument array(std::initializer_list< JsonDocument > init=std::initializer_list< JsonDocument >())
Explicitly create an array from an initializer list.
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
constexpr bool is_digit(char c) noexcept
Return whether a char is a digit (0-9), ASCII-only.
std::uint64_t NumberUnsignedType
static JsonDocument number_signed(NumberSignedType value)
Explicitly create a signed number.
JsonDocument read(std::shared_ptr< BaseInputSource > source) const
Read from a source containing a JSON document and parse its contents into a JsonDocument.
constexpr char to_lower(char c) noexcept
Return the lower case version of a letter, ASCII-only.
std::string parse_quoted_string(utils::InputStream &source, bool use_escapes, bool use_twin_quotes, bool include_qmarks)
Read a string in quotation marks from a stream and return it.
static JsonDocument object(std::initializer_list< JsonDocument > init=std::initializer_list< JsonDocument >())
Explicitly create an object from an initializer list.
JsonDocument parse_array(InputStream &input_stream) const
JsonDocument parse_value(InputStream &input_stream) const
constexpr bool is_alpha(char c) noexcept
Return whether a char is a letter (a-z or A-Z), ASCII-only.