Serious work on JString and some minor MString ajustments.

This commit is contained in:
barant committed 2024-12-11 16:58:34 -08:00
1 parent 7531c885a7
commit c6e0486c14
8 files changed
+51 -13

No files matched your search

+25 -8
View File
@@ -21,7 +21,12 @@ namespace coreutils {
pop();
remove(offset(), old.getLength() + 2);
MString key;
key << "\"" << value << "\"";
if(value.startsWith("["))
key << value;
else if(value.startsWith("{"))
key << value;
else
key << "\"" << value << "\"";
insert(key, offset());
} else {
pop();
@@ -32,17 +37,13 @@ namespace coreutils {
MString key;
if(notfirst)
key << ",";
// 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());
}
}
@@ -64,9 +65,24 @@ namespace coreutils {
}
bool JString::locate(ZString &path) {
std::cout << "path locate: " << path << std::endl;
path.split(".", 1);
ZString pathx = path[0].getTokenExclude("[");
ZString index;
if(path[0].ifNext("[")) {
index = path[0].getTokenExclude("]");
if(path[0].ifNext("]")) {
// TODO: index value here
std::cout << ":::" << pathx << ":" << index << std::endl;
}
}
else
pathx = path[0];
pathx.reset();
index.reset();
path[0].reset();
notfirst = false;
if(ifNext("{")) {
if(ifNext("{")) {
while(startsWith("\"")) {
notfirst = true;
ZString label;
@@ -77,9 +93,10 @@ namespace coreutils {
} else
throw coreutils::Exception("Labels must be contained in double quotes.");
if(ifNext(":")) {
if(label == path[0]) {
// std::cout << "path: (" << pathx << ") " << label << std::endl;
if(label == pathx) {
if(path.getList().size() == 1) {
// std::cout << "found cursor: " << unparsed() << std::endl;
std::cout << "found cursor: " << unparsed() << std::endl;
return true;
}
return locate(path[1]);