diff options
Diffstat (limited to 'base/json/json_reader.cc')
-rw-r--r-- | base/json/json_reader.cc | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/base/json/json_reader.cc b/base/json/json_reader.cc index 391f58b3..dd5d088 100644 --- a/base/json/json_reader.cc +++ b/base/json/json_reader.cc @@ -81,6 +81,11 @@ const char* JSONReader::kUnsupportedEncoding = const char* JSONReader::kUnquotedDictionaryKey = "Dictionary keys must be quoted."; +JSONReader::JSONReader() + : start_pos_(NULL), json_pos_(NULL), stack_depth_(0), + allow_trailing_comma_(false), + error_code_(JSON_NO_ERROR), error_line_(0), error_col_(0) {} + /* static */ Value* JSONReader::Read(const std::string& json, bool allow_trailing_comma) { @@ -106,16 +111,6 @@ Value* JSONReader::ReadAndReturnError(const std::string& json, } /* static */ -std::string JSONReader::FormatErrorMessage(int line, int column, - const std::string& description) { - if (line || column) { - return StringPrintf("Line: %i, column: %i, %s", - line, column, description.c_str()); - } - return description; -} - -/* static */ std::string JSONReader::ErrorCodeToString(JsonParseError error_code) { switch (error_code) { case JSON_NO_ERROR: @@ -147,11 +142,6 @@ std::string JSONReader::GetErrorMessage() const { ErrorCodeToString(error_code_)); } -JSONReader::JSONReader() - : start_pos_(NULL), json_pos_(NULL), stack_depth_(0), - allow_trailing_comma_(false), - error_code_(JSON_NO_ERROR), error_line_(0), error_col_(0) {} - Value* JSONReader::JsonToValue(const std::string& json, bool check_root, bool allow_trailing_comma) { // The input must be in UTF-8. @@ -195,6 +185,16 @@ Value* JSONReader::JsonToValue(const std::string& json, bool check_root, return NULL; } +/* static */ +std::string JSONReader::FormatErrorMessage(int line, int column, + const std::string& description) { + if (line || column) { + return StringPrintf("Line: %i, column: %i, %s", + line, column, description.c_str()); + } + return description; +} + Value* JSONReader::BuildValue(bool is_root) { ++stack_depth_; if (stack_depth_ > kStackLimit) { @@ -580,16 +580,6 @@ JSONReader::Token JSONReader::ParseToken() { return token; } -bool JSONReader::NextStringMatch(const std::wstring& str) { - for (size_t i = 0; i < str.length(); ++i) { - if ('\0' == *json_pos_) - return false; - if (*(json_pos_ + i) != str[i]) - return false; - } - return true; -} - void JSONReader::EatWhitespaceAndComments() { while ('\0' != *json_pos_) { switch (*json_pos_) { @@ -645,6 +635,16 @@ bool JSONReader::EatComment() { return true; } +bool JSONReader::NextStringMatch(const std::wstring& str) { + for (size_t i = 0; i < str.length(); ++i) { + if ('\0' == *json_pos_) + return false; + if (*(json_pos_ + i) != str[i]) + return false; + } + return true; +} + void JSONReader::SetErrorCode(JsonParseError error, const wchar_t* error_pos) { int line_number = 1; |