Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions include/chaiscript/utility/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class JSON
}

Internal( double d ) : Float( d ), Type(Class::Floating) {}
Internal( long l ) : Int( l ), Type(Class::Integral) {}
Internal( int64_t l ) : Int( l ), Type(Class::Integral) {}
Internal( bool b ) : Bool( b ), Type(Class::Boolean) {}
Internal( std::string s ) : String(std::make_unique<std::string>(std::move(s))), Type(Class::String) {}
Internal() : Type(Class::Null) {}
Expand Down Expand Up @@ -192,7 +192,7 @@ class JSON
std::unique_ptr<QuickFlatMap> Map;
std::unique_ptr<std::string> String;
double Float = 0;
long Int = 0;
int64_t Int = 0;
bool Bool = false;

Class Type = Class::Null;
Expand Down Expand Up @@ -248,7 +248,7 @@ class JSON
explicit JSON( T b, typename enable_if<is_same<T,bool>::value>::type* = nullptr ) : internal( static_cast<bool>(b) ) {}

template <typename T>
explicit JSON( T i, typename enable_if<is_integral<T>::value && !is_same<T,bool>::value>::type* = nullptr ) : internal( static_cast<long>(i) ) {}
explicit JSON( T i, typename enable_if<is_integral<T>::value && !is_same<T,bool>::value>::type* = nullptr ) : internal( static_cast<int64_t>(i) ) {}

template <typename T>
explicit JSON( T f, typename enable_if<is_floating_point<T>::value>::type* = nullptr ) : internal( static_cast<double>(f) ) {}
Expand Down Expand Up @@ -335,8 +335,8 @@ class JSON
return ok ? internal.Float : 0.0;
}

long to_int() const { bool b; return to_int( b ); }
long to_int( bool &ok ) const {
int64_t to_int() const { bool b; return to_int( b ); }
int64_t to_int( bool &ok ) const {
ok = (internal.Type == Class::Integral);
return ok ? internal.Int : 0;
}
Expand Down Expand Up @@ -568,8 +568,8 @@ struct JSONParser {
char c = '\0';
bool isDouble = false;
bool isNegative = false;
int64_t exp = 0;
bool isExpNegative = false;
long exp = 0;
if( offset < str.size() && str.at(offset) == '-' ) {
isNegative = true;
++offset;
Expand Down Expand Up @@ -606,7 +606,7 @@ struct JSONParser {
break;
}
}
exp = chaiscript::parse_num<long>( exp_str ) * (isExpNegative?-1:1);
exp = chaiscript::parse_num<int64_t>( exp_str ) * (isExpNegative?-1:1);
}
else if( offset < str.size() && (!isspace( c ) && c != ',' && c != ']' && c != '}' )) {
throw std::runtime_error(std::string("JSON ERROR: Number: unexpected character '") + c + "'");
Expand All @@ -617,9 +617,9 @@ struct JSONParser {
return JSON((isNegative?-1:1) * chaiscript::parse_num<double>( val ) * std::pow( 10, exp ));
} else {
if( !exp_str.empty() ) {
return JSON((isNegative?-1:1) * static_cast<double>(chaiscript::parse_num<long>( val )) * std::pow( 10, exp ));
return JSON((isNegative?-1:1) * static_cast<double>(chaiscript::parse_num<int64_t>( val )) * std::pow( 10, exp ));
} else {
return JSON((isNegative?-1:1) * chaiscript::parse_num<long>( val ));
return JSON((isNegative?-1:1) * chaiscript::parse_num<int64_t>( val ));
}
}
}
Expand Down