STORMM Source Documentation
Loading...
Searching...
No Matches
section_contents.h
1// -*-c++-*-
2#ifndef STORMM_SECTION_CONTENTS_H
3#define STORMM_SECTION_CONTENTS_H
4
5#include <fstream>
6#include <iostream>
7#include <string>
8#include <vector>
9#include "copyright.h"
10#include "FileManagement/file_enumerators.h"
11#include "ordered_list.h"
12#include "reporting_enumerators.h"
13#include "report_table.h"
14#include "summary_file.h"
15
16namespace stormm {
17namespace review {
18
19using diskutil::PrintSituation;
20
25public:
26
32 SectionContents(const std::string &title_in, const std::string &file_name_in, int width_in,
33 bool subsection_in, int section_id_in, int subsection_id_in,
34 ListEnumeration section_marking_in, ListEnumeration subsection_marking_in,
35 OutputSyntax style_in, double table_precision_in);
36
37 SectionContents(const std::string &title_in = std::string(""),
38 const std::string &file_name_in = std::string(""),
39 int width_in = default_output_file_width,
40 OutputSyntax style_in = OutputSyntax::STANDALONE,
41 double table_precision_in = 1.0e-6);
43
48 SectionContents(const SectionContents &original) = default;
49 SectionContents(SectionContents &&original) = default;
50 SectionContents& operator=(const SectionContents &original) = default;
51 SectionContents& operator=(SectionContents &&original) = default;
53
55 const std::string& getOutputFileName();
56
58 int getWidth() const;
59
61 OutputSyntax getSyntax() const;
62
71 int getComponentCount() const;
72 int getComponentCount(SectionComponent kind) const;
74
79 SectionComponent getComponentType(int index) const;
80
82 bool isSubsection() const;
83
113 std::string sectionAsString(OutputSyntax alt_style, int alt_width = -1, int alt_section_id = -1,
114 int alt_subsection_id = -1, int list_indent = -1,
115 int nested_list_indent = -1,
116 ListEnumeration list_marking = ListEnumeration::NONE,
117 ListEnumeration nested_list_marking = ListEnumeration::NONE) const;
118
119 std::string sectionAsString(int alt_section_id, int alt_subsection_id,
120 int list_indent, int nested_list_indent,
121 ListEnumeration list_numbering = ListEnumeration::NONE,
122 ListEnumeration nested_list_numbering = ListEnumeration::NONE) const;
123
124 std::string sectionAsString(int list_indent = -1, int nested_list_indent = -1,
125 ListEnumeration list_numbering = ListEnumeration::NONE,
126 ListEnumeration nested_list_numbering = ListEnumeration::NONE) const;
128
144 void printSection(std::ofstream *foutp, int list_indent = -1, int nested_list_indent = -1,
145 ListEnumeration list_numbering = ListEnumeration::NONE,
146 ListEnumeration nested_list_numbering = ListEnumeration::NONE) const;
147
148 void printSection(std::ostream *foutp, int list_indent = -1, int nested_list_indent = -1,
149 ListEnumeration list_numbering = ListEnumeration::NONE,
150 ListEnumeration nested_list_numbering = ListEnumeration::NONE) const;
151
152 void printSection(const std::string &alt_file_name,
153 PrintSituation alt_expectation = PrintSituation::APPEND,
154 int list_indent = -1, int nested_list_indent = -1,
155 ListEnumeration list_numbering = ListEnumeration::NONE,
156 ListEnumeration nested_list_numbering = ListEnumeration::NONE) const;
157
158 void printSection(int list_indent = -1, int nested_list_indent = -1,
159 ListEnumeration list_numbering = ListEnumeration::NONE,
160 ListEnumeration nested_list_numbering = ListEnumeration::NONE) const;
162
167 void setTitle(const std::string &title_in);
168
174 void designateSubsection(bool subsection_in = true);
175
186 void setSectionDetails(int section_id_in);
187 void setSectionDetails(ListEnumeration section_marking_in);
188 void setSectionDetails(int section_id_in, ListEnumeration section_marking_in);
190
197 void reserve(SectionComponent item_kind, int item_count);
198
210 void addNarration(const std::string &narration_in);
211 void addNarration(const TextFile &narration_in, TextEnds line_endings = TextEnds::AS_IS);
213
217 void addList(const OrderedList &list_in);
218
222 void addTable(const ReportTable &table_in);
223
235 void addScript(const std::string &script_in);
236 void addScript(const TextFile &script_in, TextEnds line_endings = TextEnds::AS_IS);
238
239private:
240 std::string title;
243 int component_count;
245 int width;
248 bool subsection;
254 int section_id;
256 int subsection_id;
258 ListEnumeration section_marking;
260 ListEnumeration subsection_marking;
262 OutputSyntax style;
266 std::vector<std::string> narrations;
271 std::vector<OrderedList> lists;
275 std::vector<ReportTable> tables;
282 std::vector<std::string> scripts;
286 std::vector<SectionComponent> sources;
289 std::string file_name;
295 PrintSituation expectation;
297
303 void validateComponentIndex(int index) const;
304};
305
337std::string printAllSections(const std::vector<SectionContents> &info,
338 OutputSyntax style = OutputSyntax::STANDALONE,
339 ListEnumeration numbering = ListEnumeration::NUMBERED,
340 ListEnumeration nested_numbering = ListEnumeration::NUMBERED,
341 int width = -1, int list_indent = -1, int nested_list_indent = -1,
342 ListEnumeration list_numbering = ListEnumeration::NONE,
343 ListEnumeration nested_list_numbering = ListEnumeration::NONE);
344
345void printAllSections(std::ofstream *foutp, const std::vector<SectionContents> &info,
346 OutputSyntax style = OutputSyntax::STANDALONE,
347 ListEnumeration numbering = ListEnumeration::NUMBERED,
348 ListEnumeration nested_numbering = ListEnumeration::NUMBERED,
349 int width = -1, int list_indent = -1, int nested_list_indent = -1,
350 ListEnumeration list_numbering = ListEnumeration::NONE,
351 ListEnumeration nested_list_numbering = ListEnumeration::NONE);
352
353void printAllSections(const std::string &file_name, const PrintSituation expectation,
354 const std::vector<SectionContents> &info,
355 OutputSyntax style = OutputSyntax::STANDALONE,
356 ListEnumeration numbering = ListEnumeration::NUMBERED,
357 ListEnumeration nested_numbering = ListEnumeration::NUMBERED,
358 int width = -1, int list_indent = -1, int nested_list_indent = -1,
359 ListEnumeration list_numbering = ListEnumeration::NONE,
360 ListEnumeration nested_list_numbering = ListEnumeration::NONE);
362
363} // namespace review
364} // namespace stormm
365
366#endif
Structure for translating a text file into a compact, rapidly parsable vector of characters in CPU RA...
Definition textfile.h:45
The ability to express multiple items as an ordered list in formatted output is a great luxury in a c...
Definition ordered_list.h:22
Tables in output file sections work differently than tables dumped to the terminal window....
Definition report_table.h:24
void addNarration(const std::string &narration_in)
Add a block of narrative to the section.
Definition section_contents.cpp:302
void printSection(std::ofstream *foutp, int list_indent=-1, int nested_list_indent=-1, ListEnumeration list_numbering=ListEnumeration::NONE, ListEnumeration nested_list_numbering=ListEnumeration::NONE) const
Print the section contents to a file.
Definition section_contents.cpp:217
void setSectionDetails(int section_id_in)
Set the section identifier (and, optionally, the numbering style).
Definition section_contents.cpp:267
bool isSubsection() const
Get an indication of whether the contents constitute a subsection.
Definition section_contents.cpp:85
void addTable(const ReportTable &table_in)
Add a new table to the section.
Definition section_contents.cpp:321
void reserve(SectionComponent item_kind, int item_count)
Reserve space for a number of blocks of narrative, ordered lists, or tables. This can be used to limi...
Definition section_contents.cpp:284
SectionContents(const std::string &title_in, const std::string &file_name_in, int width_in, bool subsection_in, int section_id_in, int subsection_id_in, ListEnumeration section_marking_in, ListEnumeration subsection_marking_in, OutputSyntax style_in, double table_precision_in)
The constructor takes critical components of the output format: target, format width,...
Definition section_contents.cpp:16
void addList(const OrderedList &list_in)
Add a new ordered list to the section.
Definition section_contents.cpp:314
std::string sectionAsString(OutputSyntax alt_style, int alt_width=-1, int alt_section_id=-1, int alt_subsection_id=-1, int list_indent=-1, int nested_list_indent=-1, ListEnumeration list_marking=ListEnumeration::NONE, ListEnumeration nested_list_marking=ListEnumeration::NONE) const
Produce a string containing the section contents.
Definition section_contents.cpp:90
OutputSyntax getSyntax() const
Get the output file syntax.
Definition section_contents.cpp:54
void setTitle(const std::string &title_in)
Set the title of the section (this can be used if the title was not specified in the constructor,...
Definition section_contents.cpp:257
void addScript(const std::string &script_in)
Add new commands to the section as script, unprotected by comment characters.
Definition section_contents.cpp:328
int getComponentCount() const
Get the number of components in the object.
Definition section_contents.cpp:59
void designateSubsection(bool subsection_in=true)
Set whether the object contains a subsection or a full section.
Definition section_contents.cpp:262
SectionComponent getComponentType(int index) const
Get the type of one of the components of the section, based on the index in which the components will...
Definition section_contents.cpp:79
const std::string & getOutputFileName()
Get the name of the output file.
Definition section_contents.cpp:44
SectionContents(const SectionContents &original)=default
With no const members or pointers to repair and all Standard Template Library components,...
int getWidth() const
Get the target file width, the maximum number of characters on a typical line.
Definition section_contents.cpp:49