mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-06 04:33:49 +01:00
JSON: Rename single-parameter getString to getStringOrDie to emphasize the danger.
This commit is contained in:
1 parent
7274b8b01e
commit
377a104e68
2 files changed
+9
-14
No files matched your search
+6
-1
@@ -33,6 +33,11 @@ int json_value::numSiblings() const {
|
||||
const json_value *json_value::get(const char *child_name) const {
|
||||
if (!this) {
|
||||
FLOG("Cannot get from null node");
|
||||
return 0;
|
||||
}
|
||||
if (!child_name) {
|
||||
FLOG("JSON: Cannot get from null child name");
|
||||
return 0;
|
||||
}
|
||||
const json_value *c = first_child;
|
||||
while (c) {
|
||||
@@ -52,7 +57,7 @@ const json_value *json_value::get(const char *child_name, json_type type) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *json_value::getString(const char *child_name) const {
|
||||
const char *json_value::getStringOrDie(const char *child_name) const {
|
||||
const json_value *val = get(child_name, JSON_STRING);
|
||||
if (val)
|
||||
return val->string_value;
|
||||
|
||||
+3
-13
@@ -7,8 +7,7 @@
|
||||
#include "block_allocator.h"
|
||||
#include "file/vfs.h"
|
||||
|
||||
enum json_type
|
||||
{
|
||||
enum json_type {
|
||||
JSON_NULL,
|
||||
JSON_OBJECT,
|
||||
JSON_ARRAY,
|
||||
@@ -18,8 +17,7 @@ enum json_type
|
||||
JSON_BOOL,
|
||||
};
|
||||
|
||||
struct json_value
|
||||
{
|
||||
struct json_value {
|
||||
json_value() {}
|
||||
|
||||
json_value *parent;
|
||||
@@ -47,7 +45,7 @@ struct json_value
|
||||
const json_value *getDict(const char *child_name) const {
|
||||
return get(child_name, JSON_OBJECT);
|
||||
}
|
||||
const char *getString(const char *child_name) const;
|
||||
const char *getStringOrDie(const char *child_name) const;
|
||||
const char *getString(const char *child_name, const char *default_value) const;
|
||||
bool getStringVector(std::vector<std::string> *vec) const;
|
||||
float getFloat(const char *child_name) const;
|
||||
@@ -69,7 +67,6 @@ private:
|
||||
json_value *json_parse(char *source, char **error_pos, char **error_desc, int *error_line, block_allocator *allocator);
|
||||
void json_print(json_value *value, int ident = 0);
|
||||
|
||||
|
||||
// Easy-wrapper
|
||||
class JsonReader {
|
||||
public:
|
||||
@@ -114,10 +111,3 @@ private:
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(JsonReader);
|
||||
};
|
||||
|
||||
// TODO: Make this a push/pop interface similar to JsonWriter. Maybe
|
||||
// we can get to the point where reading and writing is near identical or the same code.
|
||||
class JsonCursor {
|
||||
public:
|
||||
|
||||
};
|
||||
Reference in new issue
Block a user