Added namespace for the parser

This commit is contained in:
Benoît Blanchon
2014-07-03 14:00:51 +02:00
parent 78a920a5fc
commit 50b2a1b4a7
12 changed files with 156 additions and 122 deletions

View File

@ -7,41 +7,47 @@
#include "jsmn.h"
class JsonObjectBase
namespace ArduinoJson
{
public:
namespace Parser
{
class JsonObjectBase
{
public:
JsonObjectBase()
{
makeInvalid();
}
JsonObjectBase()
{
makeInvalid();
}
bool success()
{
return json != 0 && tokens != 0;
}
bool success()
{
return json != 0 && tokens != 0;
}
protected:
JsonObjectBase(char* json, jsmntok_t* tokens)
{
this->json = json;
this->tokens = tokens;
}
void makeInvalid()
{
json = 0;
tokens = 0;
}
static int getNestedTokenCount(jsmntok_t* token);
protected:
bool getBoolFromToken(jsmntok_t* token);
double getDoubleFromToken(jsmntok_t* token);
long getLongFromToken(jsmntok_t* token);
char* getStringFromToken(jsmntok_t* token);
JsonObjectBase(char* json, jsmntok_t* tokens)
{
this->json = json;
this->tokens = tokens;
}
char* json;
jsmntok_t* tokens;
};
void makeInvalid()
{
json = 0;
tokens = 0;
}
static int getNestedTokenCount(jsmntok_t* token);
bool getBoolFromToken(jsmntok_t* token);
double getDoubleFromToken(jsmntok_t* token);
long getLongFromToken(jsmntok_t* token);
char* getStringFromToken(jsmntok_t* token);
char* json;
jsmntok_t* tokens;
};
}
}