STORMM Source Documentation
Loading...
Searching...
No Matches
ordered_list.h
1// -*-c++-*-
2#ifndef STORMM_ORDERED_LIST_H
3#define STORMM_ORDERED_LIST_H
4
5#include <string>
6#include <vector>
7#include "copyright.h"
8#include "FileManagement/file_enumerators.h"
9#include "Parsing/textfile.h"
10#include "reporting_enumerators.h"
11#include "summary_file.h"
12
13namespace stormm {
14namespace review {
15
16using diskutil::PrintSituation;
17using parse::TextFile;
18
23public:
24
33 OrderedList(ListEnumeration style_in, int reserved_length = 0, int indentation_in = 2,
34 char bullet_in = '*', ListEnumeration nested_style_in = ListEnumeration::BULLET,
35 int nested_reserved_length = 0, int nested_indentation_in = 4,
36 char nested_bullet_in = '-', int format_width_in = default_output_file_width);
37
38 OrderedList(ListEnumeration style_in, ListEnumeration nested_style_in);
40
45 OrderedList(const OrderedList &original) = default;
46 OrderedList(OrderedList &&original) = default;
47 OrderedList& operator=(const OrderedList &original) = default;
48 OrderedList& operator=(OrderedList &&original) = default;
50
52 int getItemCount() const;
53
62 int getNestedItemCount() const;
63 int getNestedItemCount(int item_index) const;
65
76 std::string getItem(int item_index, int width = -1, int alt_indent = -1,
77 ListEnumeration alt_style = ListEnumeration::NONE) const;
78
91 std::string getNestedItem(int item_index, int nested_item_index, int width = -1,
92 int alt_indent = -1,
93 ListEnumeration alt_style = ListEnumeration::NONE) const;
94
117 std::string printList(int width = default_output_file_width, int alt_indent = -1,
118 int alt_nested_indent = -1,
119 ListEnumeration alt_style = ListEnumeration::NONE,
120 ListEnumeration alt_nested_style = ListEnumeration::NONE) const;
121
122 TextFile printList(OutputSyntax style, int width, int alt_indent = -1,
123 int alt_nested_indent = -1,
124 ListEnumeration alt_marking = ListEnumeration::NONE,
125 ListEnumeration alt_nested_marking = ListEnumeration::NONE) const;
126
127 void printList(std::ofstream *foutp, OutputSyntax style, int width = default_output_file_width,
128 int alt_indent = -1, int alt_nested_indent = -1,
129 ListEnumeration alt_marking = ListEnumeration::NONE,
130 ListEnumeration alt_nested_marking = ListEnumeration::NONE) const;
131
132 void printList(const std::string &file_name, PrintSituation expectation, OutputSyntax style,
133 int width = default_output_file_width, int alt_indent = -1,
134 int alt_nested_indent = -1, ListEnumeration alt_marking = ListEnumeration::NONE,
135 ListEnumeration alt_nested_marking = ListEnumeration::NONE) const;
137
142 void setStyle(ListEnumeration style_in);
143
148 void setNestedStyle(ListEnumeration nested_style_in);
149
154 void setBullet(char bullet_in);
155
160 void setNestedBullet(char nested_bullet_in);
161
166 void setFormatWidth(int format_width_in);
167
174 void addItem(const std::string &item_in, int item_index = -1);
175
189 void addItemBefore(const std::string &item_in, int item_index);
190 void addItemBefore(const std::string &item_in, const std::string &current_item);
192
206 void addItemAfter(const std::string &item_in, int item_index);
207 void addItemAfter(const std::string &item_in, const std::string &current_item);
209
221 void addNestedItem(const std::string &nested_item_in, int current_item = -1);
222 void addNestedItem(const std::string &nested_item_in, const std::string &current_item);
224
225private:
226 int item_count;
227 ListEnumeration style;
228 int indentation;
232 ListEnumeration nested_style;
236 int nested_indentation;
240 char bullet;
242 char nested_bullet;
245 int max_marker_length;
247 int max_nested_marker_length;
249 int format_width;
253 std::vector<std::string> items;
255 std::vector<int> nested_item_limits;
257 std::vector<int> nested_item_contents;
259 std::vector<std::string> nested_items;
260 std::vector<int> item_homes;
261
266 void validateItemIndex(int item_index, const char* caller = nullptr) const;
267
272 void validateNestedItemIndex(int item_index, int nested_item_index,
273 const char* caller = nullptr) const;
274
283 int locateItem(const std::string &current_item) const;
284
288 void calculateMarkerLengths();
289};
290
291} // namespace review
292} // namespace stormm
293
294#endif
Structure for translating a text file into a compact, rapidly parsable vector of characters in CPU RA...
Definition textfile.h:45
void addItemAfter(const std::string &item_in, int item_index)
Add an item after a specific member of the current list.
Definition ordered_list.cpp:269
std::string printList(int width=default_output_file_width, int alt_indent=-1, int alt_nested_indent=-1, ListEnumeration alt_style=ListEnumeration::NONE, ListEnumeration alt_nested_style=ListEnumeration::NONE) const
Print all items and nested items in the list, in order. Each overloads of this function delegates wor...
Definition ordered_list.cpp:132
int getNestedItemCount() const
Get the number of nested items.
Definition ordered_list.cpp:55
void setBullet(char bullet_in)
Set the bullet character. This produces an error if the LineEnumeration type of main list items is no...
Definition ordered_list.cpp:202
void setNestedBullet(char nested_bullet_in)
Set the nested bullet character. This produces an error if the LineEnumeration type of main list item...
Definition ordered_list.cpp:208
std::string getNestedItem(int item_index, int nested_item_index, int width=-1, int alt_indent=-1, ListEnumeration alt_style=ListEnumeration::NONE) const
Get one of the nested items associates with a main list item, formated with indentation and the neste...
Definition ordered_list.cpp:99
void addItemBefore(const std::string &item_in, int item_index)
Add an item before a specific member of the current list.
Definition ordered_list.cpp:249
OrderedList(ListEnumeration style_in, int reserved_length=0, int indentation_in=2, char bullet_in=' *', ListEnumeration nested_style_in=ListEnumeration::BULLET, int nested_reserved_length=0, int nested_indentation_in=4, char nested_bullet_in='-', int format_width_in=default_output_file_width)
The constructor takes an indication of the enumerative style (e.g. bullet points with a specific symb...
Definition ordered_list.cpp:22
OrderedList(const OrderedList &original)=default
With no const members or pointers to repair and all Standard Template Library components,...
void setFormatWidth(int format_width_in)
Set the format width for all getItem() and getNestedItem() calls. The width set here can be overridde...
Definition ordered_list.cpp:214
void setStyle(ListEnumeration style_in)
Set the main list itemization style. Recalculate the maximum marker lengths, anticipating format chan...
Definition ordered_list.cpp:190
int getItemCount() const
Get the number of items in the list.
Definition ordered_list.cpp:50
std::string getItem(int item_index, int width=-1, int alt_indent=-1, ListEnumeration alt_style=ListEnumeration::NONE) const
Get one of the items in the list, formatted with indentation and the marker symbol.
Definition ordered_list.cpp:69
void addItem(const std::string &item_in, int item_index=-1)
Add an item to the list.
Definition ordered_list.cpp:219
void setNestedStyle(ListEnumeration nested_style_in)
Set the nested itemization style. Recalculate the maximum marker lengths, anticipating format changes...
Definition ordered_list.cpp:196
void addNestedItem(const std::string &nested_item_in, int current_item=-1)
Add a nested item to one of the main list items.
Definition ordered_list.cpp:289