Fixed JSON lib automatic conversion from string to long long int.

This commit is contained in:
Thulinma 2012-05-01 15:10:59 +02:00
parent 332f399067
commit 76d7acfbb7

View file

@ -3,6 +3,7 @@
#include "json.h"
#include <sstream>
#include <fstream>
#include <stdlib.h>
int JSON::Value::c2hex(int c){
if (c >= '0' && c <= '9') return c - '0';
@ -252,10 +253,16 @@ JSON::Value & JSON::Value::operator=(const unsigned int &rhs){
return ((*this) = (long long int)rhs);
}
/// Automatic conversion to long long int - returns 0 if not an integer type.
/// Automatic conversion to long long int - returns 0 if not convertable.
JSON::Value::operator long long int(){
if (myType == INTEGER){
return intVal;
}
if (myType == STRING){
return atoll(strVal.c_str());
}
return 0;
}
/// Automatic conversion to std::string.