messing around with jstring.

This commit is contained in:
barant committed 2024-12-10 17:10:49 -08:00
1 parent c644d8346f
commit 0baa44d076
6 files changed
+148 -74

No files matched your search

+22 -7
View File
@@ -5,7 +5,7 @@ namespace coreutils {
JString::JString() : MString("{}") {}
JString::JString(const char *data) : MString(data) {}
// JString::JString(const char *data) : MString(data) {}
void JString::set(ZString &path, ZString &value) {
reset();
@@ -23,11 +23,21 @@ namespace coreutils {
throw coreutils::Exception("Fix me to accept integer type.");
}
} else {
std::cout << "[" << unparsed() << "]" << std::endl;
std::cout << "[" << unparsed() << "] >" << value << "<" << std::endl;
MString key;
if(notfirst)
if(notfirst)
key << ",";
key << "\"" << path << "\":" << "\"" << value << "\"";
// TODO: The value added must be parsed down to remove all whitespace.
value.push();
value.skipWhitespace();
if(value.startsWith("["))
key << "\"" << path << "\":" << value;
else if(value.startsWith("{"))
key << "\"" << path << "\":" << value;
else
key << "\"" << path << "\":" << "\"" << value << "\"";
value.pop();
insert(key, offset());
}
}
@@ -63,14 +73,18 @@ namespace coreutils {
if(label == path[0]) {
if(path.getList().size() == 1)
{
// std::cout << "cursor: " << unparsed() << std::endl;
// std::cout << "found cursor: " << unparsed() << std::endl;
return true;
}
return locate(path[1]);
} if(startsWith("\"")) {
getContainer();;
}
// std::cout << "+++" << unparsed() << std::endl;
if(startsWith("\"")) {
getContainer();
} else if(startsWith("[")) {
getContainer();
} else if(startsWith("{")) {
getContainer();
} else {
throw coreutils::Exception("Unrecognized data type.");
}
@@ -96,6 +110,7 @@ namespace coreutils {
}
}
}
// std::cout << "not found cursor: " << unparsed() << std::endl;
return false;
}
}