STORMM Source Documentation
|
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 | |
OrderedList & | operator= (const OrderedList &original)=default |
OrderedList & | operator= (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 ¤t_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 ¤t_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 ¤t_item) |
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.
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.
reserved_length | Number of list items to prepare for catalogging |
nested_reserved_length | Number of nested items to prepare for catalogging |
void stormm::review::OrderedList::addItem | ( | const std::string & | item_in, |
int | item_index = -1 ) |
Add an item to the list.
item_in | The item to add |
item_index | The 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) |
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:
item_in | The item to add |
item_index | Index of the main list item to add a new entry in front of |
current_item | A 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. |
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:
item_in | The item to add |
item_index | Index of the main list item to add a new entry in front of |
current_item | A 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. |
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:
nested_item_in | The nested item to add |
current_item | Item 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. |
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.
item_index | Index of the item of interest |
width | The 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_indent | An alternate indentation for the nested list item (a value of < 0 will defer to the object's internal setting) |
alt_style | An alternate style to apply to the item numbering (a value of NONE will defer to the object's internal setting) |
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.
item_index | Index of the main list item |
nested_item_index | Index of the nested item from within the sub-list |
width | The 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_indent | An alternate indentation for the nested list item (a value of < 0 will defer to the object's internal setting) |
alt_style | An alternate style to apply to the item numbering (a value of NONE will defer to the object's internal setting) |
int stormm::review::OrderedList::getNestedItemCount | ( | ) | const |
Get the number of nested items.
Overloaded:
item_index | Index of the item of interest |
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:
width | The 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. |
foutp | File stream pointer for the output |
file_name | Name of the file to open and write the table into |
expectation | The state in which the output file is to be found to permit writing |
style | One of several options for formatting the non-protected portion of the table to be amenable to certain plotting programs |
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.
bullet_in | The bullet character to set |
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.
format_width_in | The format width to set |
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.
nested_bullet_in | The bullet character to set |
void stormm::review::OrderedList::setNestedStyle | ( | ListEnumeration | nested_style_in | ) |
Set the nested itemization style. Recalculate the maximum marker lengths, anticipating format changes.
nested_style_in | The style to apply |
void stormm::review::OrderedList::setStyle | ( | ListEnumeration | style_in | ) |
Set the main list itemization style. Recalculate the maximum marker lengths, anticipating format changes.
style_in | The style to apply |