added a pretty output to JString.
This commit is contained in:
parent
d74fa9689d
commit
7eb2417456
33
JString.cpp
33
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;
|
||||
}
|
||||
|
12
MString.cpp
12
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<char> (*pf)(std::basic_ostream<char>&)) {
|
||||
|
@ -157,7 +157,7 @@ namespace coreutils {
|
||||
///
|
||||
///
|
||||
|
||||
// MString &operator<<(std::string value);
|
||||
MString &operator<<(char value);
|
||||
|
||||
///
|
||||
///
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user