diff --git a/JString.h b/JString.h index 04dc25c..7b07b5b 100644 --- a/JString.h +++ b/JString.h @@ -56,17 +56,18 @@ namespace coreutils { 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); } + operator std::string () { + return jstring.find(key).str(); + } + Proxy& operator=(coreutils::ZString value) { -// std::cout << "proxy operator=" << value << std::endl; jstring.set(key, value); return *this; } @@ -77,7 +78,6 @@ namespace coreutils { }; Proxy operator[](coreutils::ZString key) { -// std::cout << "operator[" << key << "]" << std::endl; return Proxy(*this, key); } diff --git a/MString.cpp b/MString.cpp index 1fbb689..394de4a 100644 --- a/MString.cpp +++ b/MString.cpp @@ -165,7 +165,8 @@ namespace coreutils { MString &MString::operator<<(const int value) { std::stringstream temp; temp << value; - *this << temp.str(); + MString temp2 = temp.str(); + write(temp2); return *this; } @@ -185,13 +186,13 @@ namespace coreutils { return *this; } - MString &MString::operator<<(std::string value) { - int temp = length; - int len = length + value.length(); - setSize(len); - memcpy(data + temp, value.c_str(), value.length()); - return *this; - } +// MString &MString::operator<<(std::string value) { +// int temp = length; +// int len = length + value.length(); +// setSize(len); +// memcpy(data + temp, value.c_str(), value.length()); +// return *this; +// } // MString &MString::operator<<(std::ostream (*f)(std::ostream&)) { MString &MString::operator<<(std::basic_ostream (*pf)(std::basic_ostream&)) { diff --git a/MString.h b/MString.h index 2ef52d9..1d0c57f 100644 --- a/MString.h +++ b/MString.h @@ -157,7 +157,7 @@ namespace coreutils { /// /// - MString &operator<<(std::string value); +// MString &operator<<(std::string value); /// /// diff --git a/testing/jstring_test b/testing/jstring_test index d47fb17..edb5933 100755 Binary files a/testing/jstring_test and b/testing/jstring_test differ diff --git a/testing/jstring_test.cpp b/testing/jstring_test.cpp index cde5090..0c90fe6 100644 --- a/testing/jstring_test.cpp +++ b/testing/jstring_test.cpp @@ -1,5 +1,7 @@ #include #include "../JString.h" +#include +#include int main(int argc, char **argv) { @@ -45,6 +47,13 @@ int main(int argc, char **argv) { std::cout << test1["array[1]"] << std::endl; std::cout << test1["array[2]"] << std::endl; + std::string string1 = test1["tester"]; + std::cout << "from string: " << string1 << std::endl; + + coreutils::MString testout; + testout << "this is a test: " << test1["comment"]; + std::cout << testout << std::endl; + return 0; }