5 #ifndef JODA_CURSESHANDLER_H
6 #define JODA_CURSESHANDLER_H
9 #include <rapidjson/rapidjson.h>
19 typedef RJChar::Ch Ch;
23 : identionSize(idention), win(win), colors(has_colors() == TRUE) {}
39 writeWString(
"false");
47 writeWString(std::to_string(i));
55 writeWString(std::to_string(i));
63 writeWString(std::to_string(i));
71 writeWString(std::to_string(i));
79 writeWString(std::to_string(d));
84 bool RawNumber(
const Ch *str, rapidjson::SizeType length,
bool copy) {
87 auto basicString = std::string(str, length);
88 writeWString(basicString);
93 bool String(
const Ch *str, rapidjson::SizeType length,
bool copy) {
96 auto basicString = std::string(str, length);
97 basicString =
"\"" + basicString +
"\"";
98 writeWString(basicString);
103 bool Key(
const Ch *str, rapidjson::SizeType length,
bool copy) {
106 auto basicString = std::string(str, length);
107 basicString =
"\"" + basicString +
"\"";
108 writeWString(basicString);
116 levels.emplace_back(
false);
121 auto empty = levels.back().valueCount == 0;
134 levels.emplace_back(
true);
139 auto empty = levels.back().valueCount == 0;
152 str.insert(0, identionSize * levels.size(),
' ');
157 if (!levels.empty()) {
158 auto &level = levels.back();
161 if (level.valueCount > 0) {
168 if (level.valueCount > 0) {
169 if (level.valueCount % 2 == 0) {
177 if (level.valueCount % 2 == 0) writeIndent();
183 void writeWString(
const std::string &str) {
184 std::wstring_convert<std::codecvt_utf8<wchar_t>> cv;
186 std::wstring wstr = cv.from_bytes(str);
187 waddwstr(win, wstr.c_str());
195 Level(
bool inArray_) : valueCount(0), inArray(inArray_) {}
201 std::vector<Level> levels;
203 static constexpr
size_t jDefaultIdention = 4;
Definition: CursesHandler.h:18
bool Bool(bool b)
Definition: CursesHandler.h:33
bool RawNumber(const Ch *str, rapidjson::SizeType length, bool copy)
Definition: CursesHandler.h:84
bool StartArray()
Definition: CursesHandler.h:131
bool Double(double d)
Definition: CursesHandler.h:76
bool Null()
Definition: CursesHandler.h:25
bool Int(int i)
Definition: CursesHandler.h:44
bool StartObject()
Definition: CursesHandler.h:113
bool Int64(int64_t i)
Definition: CursesHandler.h:60
bool Key(const Ch *str, rapidjson::SizeType length, bool copy)
Definition: CursesHandler.h:103
bool Uint(unsigned i)
Definition: CursesHandler.h:52
bool EndArray(rapidjson::SizeType elementCount)
Definition: CursesHandler.h:138
CursesPrettyHandler(WINDOW *win, size_t idention=jDefaultIdention)
Definition: CursesHandler.h:22
bool Uint64(uint64_t i)
Definition: CursesHandler.h:68
bool String(const Ch *str, rapidjson::SizeType length, bool copy)
Definition: CursesHandler.h:93
bool EndObject(rapidjson::SizeType memberCount)
Definition: CursesHandler.h:120
#define JODA_JSON_OUTPUT_COLOR_NUMBER
Definition: CursesFWD.h:8
#define JODA_JSON_OUTPUT_COLOR_BOOL
Definition: CursesFWD.h:10
#define JODA_JSON_OUTPUT_COLOR_STRING
Definition: CursesFWD.h:9
#define JODA_JSON_OUTPUT_COLOR_KEY
Definition: CursesFWD.h:12
#define JODA_JSON_OUTPUT_COLOR_NULL
Definition: CursesFWD.h:11