-
Notifications
You must be signed in to change notification settings - Fork 37
/
text_report_generator.hpp
49 lines (42 loc) · 2.61 KB
/
text_report_generator.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once
#ifndef __TEXT_REPORT_GENERATOR_HPP__
#define __TEXT_REPORT_GENERATOR_HPP__
#include <iostream>
#include "external/nlohmann/json.hpp"
using json = nlohmann::json;
class TextReportGenerator {
public:
void output(std::ostream& f, const json& report, bool show_region_depth);
void output_template(std::ostream& f, const json& report, int template_type, bool show_region_depth);
private:
void output_error(std::ostream& f, const json& error);
void output_event(std::ostream& f, const json& event);
void output_region(std::ostream& f, const json& region, bool show_unit_attitudes, bool show_region_depth);
void output_region_header(std::ostream& f, const json& region, bool show_region_depth);
void output_item_list(std::ostream& f, const json& item_list, std::string header);
void output_items(std::ostream& f, const json& item_list, bool assume_singular = false, bool show_single_amt = false);
void output_item(std::ostream& f, const json& item, bool assume_singular = false, bool show_single_amt = false);
void output_ships(std::ostream& f, const json& ships);
void output_structure(std::ostream& f, const json& structure, bool show_unit_attitudes);
void output_unit(std::ostream& f, const json& unit, bool show_unit_attitudes);
void output_unit_summary(std::ostream& f, const json& unit, bool show_faction = true);
void output_region_template(std::ostream& f, const json& region, int template_type, bool show_region_depth);
void output_region_map_header(std::ostream& f, const json& region, bool show_region_depth);
void output_region_map_header_line(std::ostream& f, std::string line);
std::string next_map_header_line(int line, const json& region);
std::string map_header_item(const std::string& header, const json& item);
void output_unit_template(std::ostream& f, const json& unit, int template_type);
void output_unit_orders(std::ostream& f, const json& orders);
// Without this utility function for strings, we end up printing "<string>" instead of <string> since the
// item is a json element at that point, so we have a nice utility function here.
std::string to_s(const json& item);
// Some private data members to help with output formatting of the map template
static const int line_width;
static const int map_width;
static const size_t template_fill_size;
static const int template_max_lines;
static const std::string template_map[];
static const std::map<const std::string, const std::array<std::string, 2>> terrain_fill;
static const std::map<const std::string, const std::array<int, 2>> direction_offsets;
};
#endif