STORMM Source Documentation
Loading...
Searching...
No Matches
stormm::review::SectionContents Class Reference

Any output file is expected to break into sections, which should be numbered in order and formatted consistently. This object will collect the elements of a section and provide methods for automatically writing them to an arbitrary output file. More...

#include <section_contents.h>

Public Member Functions

const std::string & getOutputFileName ()
 Get the name of the output file.
 
int getWidth () const
 Get the target file width, the maximum number of characters on a typical line.
 
OutputSyntax getSyntax () const
 Get the output file syntax.
 
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 be listed out.
 
bool isSubsection () const
 Get an indication of whether the contents constitute a subsection.
 
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, and will overwritte any existing title).
 
void designateSubsection (bool subsection_in=true)
 Set whether the object contains a subsection or a full section.
 
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 limit memory movement in cases when output sections may contain voluminous data.
 
void addList (const OrderedList &list_in)
 Add a new ordered list to the section.
 
void addTable (const ReportTable &table_in)
 Add a new table to the section.
 
 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, syntax. Specifying whether the information constitutes a subsection or not is optional, and as with other such details this can be specified after creation of the object.
 
 SectionContents (const std::string &title_in=std::string(""), const std::string &file_name_in=std::string(""), int width_in=default_output_file_width, OutputSyntax style_in=OutputSyntax::STANDALONE, double table_precision_in=1.0e-6)
 
 SectionContents (const SectionContents &original)=default
 With no const members or pointers to repair and all Standard Template Library components, the SectionContents can be copied or moved using default constructors and assignement operators.
 
 SectionContents (SectionContents &&original)=default
 
SectionContentsoperator= (const SectionContents &original)=default
 
SectionContentsoperator= (SectionContents &&original)=default
 
int getComponentCount () const
 Get the number of components in the object.
 
int getComponentCount (SectionComponent kind) const
 
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.
 
std::string sectionAsString (int alt_section_id, int alt_subsection_id, int list_indent, int nested_list_indent, ListEnumeration list_numbering=ListEnumeration::NONE, ListEnumeration nested_list_numbering=ListEnumeration::NONE) const
 
std::string sectionAsString (int list_indent=-1, int nested_list_indent=-1, ListEnumeration list_numbering=ListEnumeration::NONE, ListEnumeration nested_list_numbering=ListEnumeration::NONE) const
 
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.
 
void printSection (std::ostream *foutp, int list_indent=-1, int nested_list_indent=-1, ListEnumeration list_numbering=ListEnumeration::NONE, ListEnumeration nested_list_numbering=ListEnumeration::NONE) const
 
void printSection (const std::string &alt_file_name, PrintSituation alt_expectation=PrintSituation::APPEND, int list_indent=-1, int nested_list_indent=-1, ListEnumeration list_numbering=ListEnumeration::NONE, ListEnumeration nested_list_numbering=ListEnumeration::NONE) const
 
void printSection (int list_indent=-1, int nested_list_indent=-1, ListEnumeration list_numbering=ListEnumeration::NONE, ListEnumeration nested_list_numbering=ListEnumeration::NONE) const
 
void setSectionDetails (int section_id_in)
 Set the section identifier (and, optionally, the numbering style).
 
void setSectionDetails (ListEnumeration section_marking_in)
 
void setSectionDetails (int section_id_in, ListEnumeration section_marking_in)
 
void addNarration (const std::string &narration_in)
 Add a block of narrative to the section.
 
void addNarration (const TextFile &narration_in, TextEnds line_endings=TextEnds::AS_IS)
 
void addScript (const std::string &script_in)
 Add new commands to the section as script, unprotected by comment characters.
 
void addScript (const TextFile &script_in, TextEnds line_endings=TextEnds::AS_IS)
 

Detailed Description

Any output file is expected to break into sections, which should be numbered in order and formatted consistently. This object will collect the elements of a section and provide methods for automatically writing them to an arbitrary output file.

Member Function Documentation

◆ addList()

void stormm::review::SectionContents::addList ( const OrderedList & list_in)

Add a new ordered list to the section.

Parameters
list_inThe list to add

◆ addNarration()

void stormm::review::SectionContents::addNarration ( const std::string & narration_in)

Add a block of narrative to the section.

Overloaded:

  • Provide the narrative as a string, containing carriage returns where explicit line breaks are intended.
  • Provide the narrative as a TextFile object, the various lines of which will be delimited by carriage returns or spaces.
Parameters
narration_inThe new block of narrative
line_endingsThe manner in which to terminate lines of a TextFile object

◆ addScript()

void stormm::review::SectionContents::addScript ( const std::string & script_in)

Add new commands to the section as script, unprotected by comment characters.

Overloaded:

  • Provide the script commands as a string, containing carriage returns where explicit line breaks are intended.
  • Provide the script as a TextFile object, the various lines of which will be delimited by carriage returns or spaces.
Parameters
script_inThe new block of narrative
line_endingsThe manner in which to terminate lines of a TextFile object

◆ addTable()

void stormm::review::SectionContents::addTable ( const ReportTable & table_in)

Add a new table to the section.

Parameters
table_inThe table to add

◆ designateSubsection()

void stormm::review::SectionContents::designateSubsection ( bool subsection_in = true)

Set whether the object contains a subsection or a full section.

Parameters
subsection_inIndicate that the information contained in the object is a subsection by setting this to TRUE. The default setting allows the function to be called with no argument to achieve the obvious effect.

◆ getComponentCount()

int stormm::review::SectionContents::getComponentCount ( ) const

Get the number of components in the object.

Overloaded:

  • Get the total number of components
  • Get the number of a specific type of component
Parameters
kindThe type of component to seek

◆ getComponentType()

SectionComponent stormm::review::SectionContents::getComponentType ( int index) const

Get the type of one of the components of the section, based on the index in which the components will be listed out.

Parameters
indexThe component index of interest

◆ printSection()

void stormm::review::SectionContents::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.

Overloaded:

  • Print to a file based on a pointer provided directly to the member function
  • Print to a file based on the pointer stored internally

Parameter descriptions for this function follow from sectionAsString() above, in addition to:

Parameters
foutpAlternate file pointer (overrides the file pointer stored internally)
alt_file_nameName of a file to write (the file will be opened and then closed)
alt_expectationState in which the alternate file to write is expected to be found, if the file is indicated by name

◆ reserve()

void stormm::review::SectionContents::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 limit memory movement in cases when output sections may contain voluminous data.

Parameters
item_kindThe type of output section item for which to allocate space
item_countThe number of such items to prepare the section to hold

◆ sectionAsString()

std::string stormm::review::SectionContents::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.

Overloaded:

  • Provide alternate section and subsection identification numbers
  • Rely on the object's internal section and subsection numbers
Parameters
alt_styleAlternate formatting style to use (this can help enforce a consistent style if printing from a central output management function)
alt_section_idAlternate section index (to be translated into the enumeration scheme used by the object). Any value < 0 here will defer to the object's internal subsection index. Again, this can be useful when printing from central output management functions.
alt_subsection_idAlternate subsection index (to be translated into the enumeration scheme used by the object). Any value < 0 here will defer to the object's internal subsection index.
list_indentNumber of white space characters to indent main list elements (a value < 0 here will defer to the indentation indicated by the OrderedList object itself)
nested_list_indentNumber of white space characters to indent nested list elements (a value < 0 here will defer to the indentation indicated by the OrderedList object itself)
list_numberingThe style in which to increment main list enumerations (a NONE value here will defer to the enumerative scheme within the OrderedList object itself)
nested_list_numberingThe style in which to increment nested list enumerations (a NONE value here will defer to the enumerative scheme within the OrderedList object itself)

◆ setSectionDetails()

void stormm::review::SectionContents::setSectionDetails ( int section_id_in)

Set the section identifier (and, optionally, the numbering style).

Overloaded:

  • Set the section number only
  • Set the section marking style
  • Set the section number and marking style
Parameters
section_id_inThe number to be assigned to the section
section_marking_inThe manner in which to mark and increment section numbers

◆ setTitle()

void stormm::review::SectionContents::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, and will overwritte any existing title).

Parameters
title_inThe title to set

The documentation for this class was generated from the following files: