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

The ability to express multiple items as an ordered list in formatted output is a great luxury in a command-line code. This object will accept multiple text strings and manage their presentation as a list with appropriate identifiers. More...

#include <ordered_list.h>

Public Member Functions

int getItemCount () const
 Get the number of items in the list.
 
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.
 
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 nested marker symbol.
 
void setStyle (ListEnumeration style_in)
 Set the main list itemization style. Recalculate the maximum marker lengths, anticipating format changes.
 
void setNestedStyle (ListEnumeration nested_style_in)
 Set the nested itemization style. Recalculate the maximum marker lengths, anticipating format changes.
 
void setBullet (char bullet_in)
 Set the bullet character. This produces an error if the LineEnumeration type of main list items is not BULLET.
 
void setNestedBullet (char nested_bullet_in)
 Set the nested bullet character. This produces an error if the LineEnumeration type of main list items is not BULLET.
 
void setFormatWidth (int format_width_in)
 Set the format width for all getItem() and getNestedItem() calls. The width set here can be overridden by providing an explicit parameter to either call.
 
void addItem (const std::string &item_in, int item_index=-1)
 Add an item to the list.
 
 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 symbol, numbers, letters), a proposed length to the list, indentation, and an optional nesting style (with nested identation). Items must be subsequently added to the list in order to fill out primary and nested items.
 
 OrderedList (ListEnumeration style_in, ListEnumeration nested_style_in)
 
 OrderedList (const OrderedList &original)=default
 With no const members or pointers to repair and all Standard Template Library components, the OrderedList can be copied or moved using default constructors and assignement operators.
 
 OrderedList (OrderedList &&original)=default
 
OrderedListoperator= (const OrderedList &original)=default
 
OrderedListoperator= (OrderedList &&original)=default
 
int getNestedItemCount () const
 Get the number of nested items.
 
int getNestedItemCount (int item_index) const
 
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 work to one of the prior overloads.
 
TextFile printList (OutputSyntax style, int width, int alt_indent=-1, int alt_nested_indent=-1, ListEnumeration alt_marking=ListEnumeration::NONE, ListEnumeration alt_nested_marking=ListEnumeration::NONE) const
 
void printList (std::ofstream *foutp, OutputSyntax style, int width=default_output_file_width, int alt_indent=-1, int alt_nested_indent=-1, ListEnumeration alt_marking=ListEnumeration::NONE, ListEnumeration alt_nested_marking=ListEnumeration::NONE) const
 
void printList (const std::string &file_name, PrintSituation expectation, OutputSyntax style, int width=default_output_file_width, int alt_indent=-1, int alt_nested_indent=-1, ListEnumeration alt_marking=ListEnumeration::NONE, ListEnumeration alt_nested_marking=ListEnumeration::NONE) const
 
void addItemBefore (const std::string &item_in, int item_index)
 Add an item before a specific member of the current list.
 
void addItemBefore (const std::string &item_in, const std::string &current_item)
 
void addItemAfter (const std::string &item_in, int item_index)
 Add an item after a specific member of the current list.
 
void addItemAfter (const std::string &item_in, const std::string &current_item)
 
void addNestedItem (const std::string &nested_item_in, int current_item=-1)
 Add a nested item to one of the main list items.
 
void addNestedItem (const std::string &nested_item_in, const std::string &current_item)
 

Detailed Description

The ability to express multiple items as an ordered list in formatted output is a great luxury in a command-line code. This object will accept multiple text strings and manage their presentation as a list with appropriate identifiers.

Constructor & Destructor Documentation

◆ OrderedList()

stormm::review::OrderedList::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 symbol, numbers, letters), a proposed length to the list, indentation, and an optional nesting style (with nested identation). Items must be subsequently added to the list in order to fill out primary and nested items.

Parameters
reserved_lengthNumber of list items to prepare for catalogging
nested_reserved_lengthNumber of nested items to prepare for catalogging

Member Function Documentation

◆ addItem()

void stormm::review::OrderedList::addItem ( const std::string & item_in,
int item_index = -1 )

Add an item to the list.

Parameters
item_inThe item to add
item_indexThe index point at which to add the item (the item currently occupying this index, and all others behind it, will be shifted back by one–it is std::vector insert)

◆ addItemAfter()

void stormm::review::OrderedList::addItemAfter ( const std::string & item_in,
int item_index )

Add an item after a specific member of the current list.

Overloaded:

  • Identify the main list item by index
  • Identify the main list item by matching the leading part of the string
Parameters
item_inThe item to add
item_indexIndex of the main list item to add a new entry in front of
current_itemA sequence of characters matching an item in the current list. The first item matching this sequence in its totality will be taken as the point after which to add the new item. Failing to find this sequence at the front of any list item produces a runtime error.

◆ addItemBefore()

void stormm::review::OrderedList::addItemBefore ( const std::string & item_in,
int item_index )

Add an item before a specific member of the current list.

Overloaded:

  • Identify the main list item by index
  • Identify the main list item by matching the leading part of the string
Parameters
item_inThe item to add
item_indexIndex of the main list item to add a new entry in front of
current_itemA sequence of characters matching an item in the current list. The first item matching this sequence in its totality will be taken as the point before which to add the new item. Failing to find this sequence at the front of any list item produces a runtime error.

◆ addNestedItem()

void stormm::review::OrderedList::addNestedItem ( const std::string & nested_item_in,
int current_item = -1 )

Add a nested item to one of the main list items.

Overloaded:

  • Identify the main list item by index
  • Identify the main list item by matching the leading part of the string
Parameters
nested_item_inThe nested item to add
current_itemItem in the current main item list (a positive value must be valid). Negative values (including the default) provided here will cause the nested items to be assigned to the most recently added list item.

◆ getItem()

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

Parameters
item_indexIndex of the item of interest
widthThe width at which to print the formatted text, including indentation and marker characters. The default of -1 triggers use of the object's format_width member variable.
alt_indentAn alternate indentation for the nested list item (a value of < 0 will defer to the object's internal setting)
alt_styleAn alternate style to apply to the item numbering (a value of NONE will defer to the object's internal setting)

◆ getNestedItem()

std::string stormm::review::OrderedList::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 nested marker symbol.

Parameters
item_indexIndex of the main list item
nested_item_indexIndex of the nested item from within the sub-list
widthThe width at which to print the formatted text, including indentation and marker characters. The default of -1 triggers use of the object's format_width member variable.
alt_indentAn alternate indentation for the nested list item (a value of < 0 will defer to the object's internal setting)
alt_styleAn alternate style to apply to the item numbering (a value of NONE will defer to the object's internal setting)

◆ getNestedItemCount()

int stormm::review::OrderedList::getNestedItemCount ( ) const

Get the number of nested items.

Overloaded:

  • Get the total number of nested items in the entire list
  • Get the number of nested items for an item of a particular index
Parameters
item_indexIndex of the item of interest

◆ printList()

std::string stormm::review::OrderedList::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 work to one of the prior overloads.

Overloaded:

  • Print the output to a string (this output will not be protected by any comment character to prevent interpretation by a program reading it)
  • Print the output to a TextFile object as it would be output to an open file stream, using character protection for various output formats.
  • Print the output to a file stream using the indicated style (this dertermines the comment protection character used to shield the list and its items from interpretation by the chosen plotting program)
  • Print the output to a named file so long as it is found in the state indicated
Parameters
widthThe width at which to print the formatted text, including indentation and marker characters. The default of -1 triggers use of the object's format_width member variable.
foutpFile stream pointer for the output
file_nameName of the file to open and write the table into
expectationThe state in which the output file is to be found to permit writing
styleOne of several options for formatting the non-protected portion of the table to be amenable to certain plotting programs

◆ setBullet()

void stormm::review::OrderedList::setBullet ( char bullet_in)

Set the bullet character. This produces an error if the LineEnumeration type of main list items is not BULLET.

Parameters
bullet_inThe bullet character to set

◆ setFormatWidth()

void stormm::review::OrderedList::setFormatWidth ( int format_width_in)

Set the format width for all getItem() and getNestedItem() calls. The width set here can be overridden by providing an explicit parameter to either call.

Parameters
format_width_inThe format width to set

◆ setNestedBullet()

void stormm::review::OrderedList::setNestedBullet ( char nested_bullet_in)

Set the nested bullet character. This produces an error if the LineEnumeration type of main list items is not BULLET.

Parameters
nested_bullet_inThe bullet character to set

◆ setNestedStyle()

void stormm::review::OrderedList::setNestedStyle ( ListEnumeration nested_style_in)

Set the nested itemization style. Recalculate the maximum marker lengths, anticipating format changes.

Parameters
nested_style_inThe style to apply

◆ setStyle()

void stormm::review::OrderedList::setStyle ( ListEnumeration style_in)

Set the main list itemization style. Recalculate the maximum marker lengths, anticipating format changes.

Parameters
style_inThe style to apply

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