Make unused parsers compile-time optional
This commit is contained in:
parent
cb9c61fa2d
commit
1ae3cc2fad
3 changed files with 11 additions and 2 deletions
|
|
@ -18,14 +18,18 @@ namespace fc
|
||||||
enum parse_type
|
enum parse_type
|
||||||
{
|
{
|
||||||
legacy_parser = 0,
|
legacy_parser = 0,
|
||||||
|
#ifdef WITH_EXOTIC_JSON_PARSERS
|
||||||
strict_parser = 1,
|
strict_parser = 1,
|
||||||
relaxed_parser = 2,
|
relaxed_parser = 2,
|
||||||
legacy_parser_with_string_doubles = 3
|
legacy_parser_with_string_doubles = 3
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
enum output_formatting
|
enum output_formatting
|
||||||
{
|
{
|
||||||
stringify_large_ints_and_doubles = 0,
|
stringify_large_ints_and_doubles = 0,
|
||||||
|
#ifdef WITH_EXOTIC_JSON_PARSERS
|
||||||
legacy_generator = 1
|
legacy_generator = 1
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
static ostream& to_stream( ostream& out, const fc::string&);
|
static ostream& to_stream( ostream& out, const fc::string&);
|
||||||
|
|
|
||||||
|
|
@ -671,5 +671,4 @@ namespace fc { namespace json_relaxed
|
||||||
}
|
}
|
||||||
return variant();
|
return variant();
|
||||||
}
|
}
|
||||||
|
|
||||||
} } // fc::json_relaxed
|
} } // fc::json_relaxed
|
||||||
|
|
|
||||||
|
|
@ -319,7 +319,11 @@ namespace fc
|
||||||
if (str == "-." || str == ".") // check the obviously wrong things we could have encountered
|
if (str == "-." || str == ".") // check the obviously wrong things we could have encountered
|
||||||
FC_THROW_EXCEPTION(parse_error_exception, "Can't parse token \"${token}\" as a JSON numeric constant", ("token", str));
|
FC_THROW_EXCEPTION(parse_error_exception, "Can't parse token \"${token}\" as a JSON numeric constant", ("token", str));
|
||||||
if( dot )
|
if( dot )
|
||||||
return parser_type == json::legacy_parser_with_string_doubles ? variant(str) : variant(to_double(str));
|
return
|
||||||
|
#ifdef WITH_EXOTIC_JSON_PARSERS
|
||||||
|
parser_type == json::legacy_parser_with_string_doubles ? variant(str) :
|
||||||
|
#endif
|
||||||
|
variant(to_double(str));
|
||||||
if( neg )
|
if( neg )
|
||||||
return to_int64(str);
|
return to_int64(str);
|
||||||
return to_uint64(str);
|
return to_uint64(str);
|
||||||
|
|
@ -768,12 +772,14 @@ namespace fc
|
||||||
{
|
{
|
||||||
case legacy_parser:
|
case legacy_parser:
|
||||||
return variant_from_stream<fc::buffered_istream, legacy_parser>( in );
|
return variant_from_stream<fc::buffered_istream, legacy_parser>( in );
|
||||||
|
#ifdef WITH_EXOTIC_JSON_PARSERS
|
||||||
case legacy_parser_with_string_doubles:
|
case legacy_parser_with_string_doubles:
|
||||||
return variant_from_stream<fc::buffered_istream, legacy_parser_with_string_doubles>( in );
|
return variant_from_stream<fc::buffered_istream, legacy_parser_with_string_doubles>( in );
|
||||||
case strict_parser:
|
case strict_parser:
|
||||||
return json_relaxed::variant_from_stream<buffered_istream, true>( in );
|
return json_relaxed::variant_from_stream<buffered_istream, true>( in );
|
||||||
case relaxed_parser:
|
case relaxed_parser:
|
||||||
return json_relaxed::variant_from_stream<buffered_istream, false>( in );
|
return json_relaxed::variant_from_stream<buffered_istream, false>( in );
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
FC_ASSERT( false, "Unknown JSON parser type {ptype}", ("ptype", ptype) );
|
FC_ASSERT( false, "Unknown JSON parser type {ptype}", ("ptype", ptype) );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue