added a pretty output to JString.

This commit is contained in:
barant 2024-12-18 09:49:34 -08:00
parent d74fa9689d
commit 7eb2417456
4 changed files with 29 additions and 18 deletions

View File

@ -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;
}

View File

@ -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<char> (*pf)(std::basic_ostream<char>&)) {

View File

@ -157,7 +157,7 @@ namespace coreutils {
///
///
// MString &operator<<(std::string value);
MString &operator<<(char value);
///
///

Binary file not shown.