Changed naming convention to avoid shadowing (issue #25)

This commit is contained in:
Benoit Blanchon
2014-09-28 13:36:41 +02:00
parent cc19266470
commit ce788d96c4
19 changed files with 147 additions and 148 deletions

View File

@@ -24,12 +24,12 @@ namespace ArduinoJson
{
public:
JsonParser()
: JsonParserBase(tokens, MAX_TOKENS)
: JsonParserBase(_tokens, MAX_TOKENS)
{
}
private:
jsmntok_t tokens[MAX_TOKENS];
jsmntok_t _tokens[MAX_TOKENS];
};
}
}

View File

@@ -13,8 +13,8 @@ JsonValue JsonParserBase::parse(char* json)
jsmn_parser parser;
jsmn_init(&parser);
if (JSMN_SUCCESS != jsmn_parse(&parser, json, tokens, maxTokens))
if (JSMN_SUCCESS != jsmn_parse(&parser, json, _tokens, _maxTokens))
return JsonToken::null();
return JsonToken(json, tokens);
return JsonToken(json, _tokens);
}

View File

@@ -19,7 +19,7 @@ namespace ArduinoJson
// Create a JSON parser using the provided buffer
JsonParserBase(jsmntok_t* tokens, int maxTokens)
: tokens(tokens), maxTokens(maxTokens)
: _tokens(tokens), _maxTokens(maxTokens)
{
}
@@ -42,8 +42,8 @@ namespace ArduinoJson
}
private:
jsmntok_t* tokens;
int maxTokens;
jsmntok_t* _tokens;
int _maxTokens;
};
}
}

View File

@@ -9,8 +9,8 @@ using namespace ArduinoJson::Parser;
char* JsonToken::getText()
{
char* s = json + token->start;
json[token->end] = 0;
char* s = _json + _token->start;
_json[_token->end] = 0;
unescapeString(s);
@@ -54,7 +54,7 @@ inline char JsonToken::unescapeChar(char c)
JsonToken JsonToken::nextSibling() const
{
// start with current token
jsmntok_t* t = token;
jsmntok_t* t = _token;
// count the number of token to skip
int yetToVisit = 1;
@@ -67,5 +67,5 @@ JsonToken JsonToken::nextSibling() const
}
// build a JsonToken at the new location
return JsonToken(json, t);
return JsonToken(_json, t);
}

View File

@@ -18,13 +18,13 @@ namespace ArduinoJson
// Create a "null" pointer
JsonToken()
: token(0)
: _token(0)
{
}
// Create a pointer to the specified JSON token
JsonToken(char* json, jsmntok_t* token)
: json(json), token(token)
: _json(json), _token(token)
{
}
@@ -34,13 +34,13 @@ namespace ArduinoJson
// Get the number of children tokens
int childrenCount()
{
return token->size;
return _token->size;
}
// Get a pointer to the first child of the current token
JsonToken firstChild() const
{
return JsonToken(json, token + 1);
return JsonToken(_json, _token + 1);
}
// Get a pointer to the next sibling token (ie skiping the children tokens)
@@ -49,37 +49,37 @@ namespace ArduinoJson
// Test equality
bool operator!=(const JsonToken& other) const
{
return token != other.token;
return _token != other._token;
}
// Tell if the pointer is "null"
bool isValid()
{
return token != 0;
return _token != 0;
}
// Tell if the JSON token is a JSON object
bool isObject()
{
return token != 0 && token->type == JSMN_OBJECT;
return _token != 0 && _token->type == JSMN_OBJECT;
}
// Tell if the JSON token is a JSON array
bool isArray()
{
return token != 0 && token->type == JSMN_ARRAY;
return _token != 0 && _token->type == JSMN_ARRAY;
}
// Tell if the JSON token is a primitive
bool isPrimitive()
{
return token != 0 && token->type == JSMN_PRIMITIVE;
return _token != 0 && _token->type == JSMN_PRIMITIVE;
}
// Tell if the JSON token is a string
bool isString()
{
return token != 0 && token->type == JSMN_STRING;
return _token != 0 && _token->type == JSMN_STRING;
}
// Explicit wait to create a "null" JsonToken
@@ -89,8 +89,8 @@ namespace ArduinoJson
}
private:
char* json;
jsmntok_t* token;
char* _json;
jsmntok_t* _token;
static char unescapeChar(char c);
static void unescapeString(char* s);