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();
|
ch = nextChar();
|
||||||
if(ch == '{') {
|
if(ch == '{') {
|
||||||
index += 3;
|
index += 3;
|
||||||
std::cout << "{\n";
|
output << ch << '\n';
|
||||||
for(int ix = 0; ix < index; ++ix)
|
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 == ':') {
|
else if(ch == ':') {
|
||||||
std::cout << ": ";
|
output << ": ";
|
||||||
}
|
}
|
||||||
else if(ch == '}') {
|
else if(ch == '}') {
|
||||||
index -= 3;
|
index -= 3;
|
||||||
std::cout << '\n';
|
output << '\n';
|
||||||
for(int ix = 0; ix < index; ++ix)
|
for(int ix = 0; ix < index; ++ix)
|
||||||
std::cout << ' ';
|
output << ' ';
|
||||||
std::cout << ch << '\n';
|
output << ch;
|
||||||
|
}
|
||||||
|
else if(ch == ']') {
|
||||||
|
index -= 3;
|
||||||
|
output << '\n';
|
||||||
|
for(int ix = 0; ix < index; ++ix)
|
||||||
|
output << ' ';
|
||||||
|
output << ch;
|
||||||
}
|
}
|
||||||
else if(ch == ',') {
|
else if(ch == ',') {
|
||||||
std::cout << ",\n";
|
output << ch << '\n';
|
||||||
for(int ix = 0; ix < index; ++ix)
|
for(int ix = 0; ix < index; ++ix)
|
||||||
std::cout << ' ';
|
output << ' ';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
std::cout << ch;
|
output << ch;
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
12
MString.cpp
12
MString.cpp
@ -186,13 +186,11 @@ namespace coreutils {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// MString &MString::operator<<(std::string value) {
|
MString &MString::operator<<(char value) {
|
||||||
// int temp = length;
|
setSize(length + 1);
|
||||||
// int len = length + value.length();
|
data[length - 1] = value;
|
||||||
// setSize(len);
|
return *this;
|
||||||
// memcpy(data + temp, value.c_str(), value.length());
|
}
|
||||||
// return *this;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// MString &MString::operator<<(std::ostream (*f)(std::ostream&)) {
|
// MString &MString::operator<<(std::ostream (*f)(std::ostream&)) {
|
||||||
MString &MString::operator<<(std::basic_ostream<char> (*pf)(std::basic_ostream<char>&)) {
|
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