diff --git a/JString.cpp b/JString.cpp index 5687249..f13a080 100644 --- a/JString.cpp +++ b/JString.cpp @@ -179,27 +179,40 @@ namespace coreutils { ch = nextChar(); if(ch == '{') { index += 3; - std::cout << "{\n"; + output << ch << '\n'; for(int ix = 0; ix < index; ++ix) - std::cout << ' '; + output << ' '; + } + else if(ch == '[') { + index += 3; + output << ch << '\n'; + for(int ix = 0; ix < index; ++ix) + output << ' '; } else if(ch == ':') { - std::cout << ": "; + output << ": "; } else if(ch == '}') { index -= 3; - std::cout << '\n'; + output << '\n'; for(int ix = 0; ix < index; ++ix) - std::cout << ' '; - std::cout << ch << '\n'; + output << ' '; + output << ch; + } + else if(ch == ']') { + index -= 3; + output << '\n'; + for(int ix = 0; ix < index; ++ix) + output << ' '; + output << ch; } else if(ch == ',') { - std::cout << ",\n"; + output << ch << '\n'; for(int ix = 0; ix < index; ++ix) - std::cout << ' '; + output << ' '; } - else - std::cout << ch; + else + output << ch; } return output; } diff --git a/MString.cpp b/MString.cpp index 6dbac9b..b9aca9d 100644 --- a/MString.cpp +++ b/MString.cpp @@ -186,13 +186,11 @@ 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<<(char value) { + setSize(length + 1); + data[length - 1] = value; + 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 6e75bb1..dbd05d5 100644 --- a/MString.h +++ b/MString.h @@ -157,7 +157,7 @@ namespace coreutils { /// /// -// MString &operator<<(std::string value); + MString &operator<<(char value); /// /// diff --git a/testing/jstring_test b/testing/jstring_test index 22f23c7..92a2946 100755 Binary files a/testing/jstring_test and b/testing/jstring_test differ