JString now streams properly.

This commit is contained in:
barant committed 2024-12-11 09:55:40 -08:00
1 parent 0baa44d076
commit 7531c885a7
5 files changed
+57 -122

No files matched your search

+35 -18
View File
@@ -33,8 +33,7 @@ namespace coreutils {
public:
JString();
// JString(const char *data);
void set(ZString &path, ZString &value);
///
@@ -45,28 +44,46 @@ namespace coreutils {
ZString find(ZString &path);
private:
bool locate(ZString &path);
bool notfirst;
ZString path;
ZString keyx;
public:
operator ZString () {
std::cout << "operator0" << std::endl;
return find(keyx);
}
JString &operator[](coreutils::ZString key) {
std::cout << "operator[" << key << "]" << std::endl;
keyx = key;
return *this;
class Proxy {
public:
Proxy(JString &jstring, ZString key) : jstring(jstring), key(key) {}
friend std::ostream &operator<<(std::ostream &os, const Proxy &proxy);
operator coreutils::ZString () {
// std::cout << "operator to ZString: " << key << std::endl;
return jstring.find(key);
}
operator coreutils::MString () {
// std::cout << "operator to MString: " << key << std::endl;
return jstring.find(key);
}
Proxy& operator=(coreutils::ZString value) {
// std::cout << "proxy operator=" << value << std::endl;
jstring.set(key, value);
return *this;
}
private:
JString &jstring;
ZString key;
};
Proxy operator[](coreutils::ZString key) {
// std::cout << "operator[" << key << "]" << std::endl;
return Proxy(*this, key);
}
JString & operator=(coreutils:: ZString value) {
std::cout << "should set key [" << keyx << "] operator=" << value << std::endl;
set(keyx, value);
std::cout << "operator=" << value << std::endl;
return *this;
}