void (*handleNull) (void* userData);
void (*handleString) (void* userData, char* string);
void (*handleBool) (void* userData, int boolval);
- void (*handleNumber) (void* userData, long double num);
+ void (*handleNumber) (void* userData, double num);
void (*handleError) (void* userData, char* err, ...);
};
typedef struct jsonParserHandlerStruct jsonParserHandler;
osrfList* l; /* array container */
char* s; /* string */
int b; /* bool */
- long double n; /* number */
+// double n; /* number */
+ double n; /* number */
} value;
};
typedef struct _jsonObjectStruct jsonObject;
/**
* Creates a new number object
*/
-jsonObject* jsonNewNumberObject( long double num );
+jsonObject* jsonNewNumberObject( double num );
/**
is a string. Otherwise returns NULL*/
char* jsonObjectGetString(const jsonObject*);
-long double jsonObjectGetNumber( const jsonObject* obj );
+double jsonObjectGetNumber( const jsonObject* obj );
/* sets the string data */
void jsonObjectSetString(jsonObject* dest, const char* string);
void _jsonHandleNull(void*);
void _jsonHandleString(void*, char* string);
void _jsonHandleBool(void*, int boolval);
-void _jsonHandleNumber(void*, long double num);
+void _jsonHandleNumber(void*, double num);
void _jsonHandleError(void*, char* str, ...);
struct jsonInternalParserStruct {
return o;
}
-jsonObject* jsonNewNumberObject( long double num ) {
+jsonObject* jsonNewNumberObject( double num ) {
jsonObject* o = jsonNewObject(NULL);
o->type = JSON_NUMBER;
o->value.n = num;
break;
case JSON_NUMBER: {
- long double x = obj->value.n;
+ double x = obj->value.n;
if( x == (long) x ) {
LONG_TO_STRING((long)x);
OSRF_BUFFER_ADD(buf, LONGSTR);
} else {
- LONG_DOUBLE_TO_STRING(x);
- OSRF_BUFFER_ADD(buf, LONGDOUBLESTR);
+ DOUBLE_TO_STRING(x);
+ OSRF_BUFFER_ADD(buf, DOUBLESTR);
}
break;
}
return (obj && obj->type == JSON_STRING) ? obj->value.s : NULL;
}
-long double jsonObjectGetNumber( const jsonObject* obj ) {
+double jsonObjectGetNumber( const jsonObject* obj ) {
return (obj && obj->type == JSON_NUMBER) ? obj->value.n : 0;
}
value = strdup(LONGSTR);
} else {
- LONG_DOUBLE_TO_STRING(o->value.n);
- value = strdup(LONGDOUBLESTR);
+ DOUBLE_TO_STRING(o->value.n);
+ value = strdup(DOUBLESTR);
}
break;
/* make me more strict */
char* err = NULL;
- long double d = strtod(ctx->buffer->buf, &err);
+ double d = strtod(ctx->buffer->buf, &err);
if(err && err[0] != '\0')
return _jsonParserError(ctx, "Invalid number sequence");
JSON_STATE_REMOVE(ctx, JSON_STATE_IN_NUMBER);
_jsonInsertParserItem(p, obj);
}
-void _jsonHandleNumber(void* ctx, long double num) {
+void _jsonHandleNumber(void* ctx, double num) {
jsonInternalParser* p = (jsonInternalParser*) ctx;
_jsonInsertParserItem(p, jsonNewNumberObject(num));
}