Khem khem
This commit is contained in:
parent
d4c48ea269
commit
fadf87c0d2
2
.gitignore
vendored
2
.gitignore
vendored
@ -9,4 +9,4 @@ building/*.png
|
||||
building/*.svg
|
||||
|
||||
.idea/
|
||||
|
||||
local.sh
|
||||
|
@ -69,7 +69,7 @@ struct TestWebsiteBuildScript {
|
||||
};
|
||||
for (std::string& u: T.exported_headers)
|
||||
u = "jsonincpp/" + u;
|
||||
T.installation_dir = "";
|
||||
T.installation_dir = "json";
|
||||
my_targets.push_back(T);
|
||||
}
|
||||
if (make_tests) { CTarget T{"libjsonincpp_test0", "executable"};
|
||||
|
@ -29,6 +29,11 @@ namespace json {
|
||||
struct JSON_reference;
|
||||
struct JSON_reference_const;
|
||||
|
||||
struct JSON;
|
||||
|
||||
typedef std::vector<JSON> jarr;
|
||||
typedef std::map<std::string, JSON> jdict;
|
||||
|
||||
struct JSON {
|
||||
void* value = NULL;
|
||||
json_t type = null_symbol;
|
||||
|
@ -83,18 +83,34 @@ namespace json {
|
||||
}
|
||||
|
||||
Integer & JSON::asInteger() {
|
||||
if (isNull()) {
|
||||
value = new Integer();
|
||||
type = integer;
|
||||
}
|
||||
return const_cast<Integer&>(const_cast<const JSON*>(this)->asInteger());
|
||||
}
|
||||
|
||||
std::string &JSON::asString() {
|
||||
if (isNull()) {
|
||||
value = new std::string();
|
||||
type = string;
|
||||
}
|
||||
return const_cast<std::string&>(const_cast<const JSON*>(this)->asString());
|
||||
}
|
||||
|
||||
std::vector<JSON> &JSON::asArray() {
|
||||
if (isNull()) {
|
||||
value = new ArrayData();
|
||||
type = array;
|
||||
}
|
||||
return const_cast<std::vector<JSON>&>(const_cast<const JSON*>(this)->asArray());
|
||||
}
|
||||
|
||||
std::map<std::string, JSON> &JSON::asDictionary() {
|
||||
if (isNull()) {
|
||||
value = new DictionaryData();
|
||||
type = dictionary;
|
||||
}
|
||||
return const_cast<std::map<std::string, JSON>&>(const_cast<const JSON*>(this)->asDictionary());
|
||||
}
|
||||
|
||||
|
@ -34,12 +34,17 @@ void test_obvious(const JSON& A) {
|
||||
test(*big[0], *big[1], true);
|
||||
}
|
||||
|
||||
int main() {
|
||||
json::JSON cba;
|
||||
cba["boba"] = json::JSON("<>");
|
||||
printf("%s\n", generate_str(cba["boba"].g(), print_compact).c_str());
|
||||
// return 0;
|
||||
void ftest(int i) {
|
||||
JSON A;
|
||||
JSON B;
|
||||
A["aaa"][(size_t)i]["bbb"].g().asArray().push_back(JSON(jarr{JSON(""), JSON("")}));
|
||||
// B.asDictionary().
|
||||
}
|
||||
|
||||
int main() {
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
ftest(i);
|
||||
}
|
||||
test_obvious(parse_str_flawless("{ \"aaa\": true, \"2\":[true]}"));
|
||||
test_obvious(parse_str_flawless("{ \"aa\": true, \"tttt\": [true, false]}"));
|
||||
test_obvious(parse_str_flawless("[[[]]]"));
|
||||
|
Loading…
Reference in New Issue
Block a user