Sharg 1.1.2-rc.1
The argument parser for bio-c++ tools.
Loading...
Searching...
No Matches
sharg::detail::format_html Class Reference

The format that prints the help page as html to std::cout. More...

#include <sharg/detail/format_html.hpp>

+ Inheritance diagram for sharg::detail::format_html:

Public Member Functions

Constructors, destructor and assignment
 format_html ()=default
 Defaulted.
 
 format_html (format_html const &pf)=default
 Defaulted.
 
format_htmloperator= (format_html const &pf)=default
 Defaulted.
 
 format_html (format_html &&)=default
 Defaulted.
 
format_htmloperator= (format_html &&)=default
 Defaulted.
 
 ~format_html ()=default
 Defaulted.
 
 format_html (std::vector< std::string > const &names, update_notifications const version_updates, bool const advanced=false)
 Defaulted.
 
- Public Member Functions inherited from sharg::detail::format_help_base< format_html >
void add_option (option_type &value, config< validator_t > const &config)
 Adds a sharg::print_list_item call to be evaluated later on.
 
void add_flag (bool &value, config< validator_t > const &config)
 Adds a sharg::print_list_item call to be evaluated later on.
 
void add_positional_option (option_type &value, config< validator_t > const &config)
 Adds a sharg::print_list_item call to be evaluated later on.
 
void parse (parser_meta_data &parser_meta)
 Initiates the printing of the help page to std::cout.
 
void add_section (std::string const &title, bool const advanced_only)
 Adds a print_section call to parser_set_up_calls.
 
void add_subsection (std::string const &title, bool const advanced_only)
 Adds a print_subsection call to parser_set_up_calls.
 
void add_line (std::string const &text, bool is_paragraph, bool const advanced_only)
 Adds a print_line call to parser_set_up_calls.
 
void add_list_item (std::string const &key, std::string const &desc, bool const advanced_only)
 Adds a sharg::print_list_item call to parser_set_up_calls.
 

Private Types

using base_type = format_help_base<format_html>
 The CRTP base class type.
 

Private Member Functions

void maybe_close_list ()
 Closes HTML list tag (dl) if needed.
 
void maybe_close_paragraph ()
 Closes HTML paragraph tag (p) if needed.
 
void print_header ()
 Prints a help page header in HTML format to std::cout.
 
void print_section (std::string const &title)
 Prints a section title in HTML format to std::cout.
 
void print_subsection (std::string const &title)
 Prints a subsection title in HTML format to std::cout.
 
void print_line (std::string const &text, bool line_is_paragraph)
 Prints a text in HTML format to std::cout.
 
void print_list_item (std::string const &term, std::string const &desc)
 Prints a help page list_item in HTML format to std::cout.
 
void print_footer ()
 Prints a help page footer in HTML format to std::cout.
 
std::string to_html (std::string const &input)
 Converts console output formatting to the HTML equivalent.
 
std::string in_bold (std::string const &str)
 Format string as in_bold.
 

Private Attributes

friend base_type
 Befriend the base class to give access to the private member functions.
 
bool is_dl {false}
 Current state is either inside a html <dl> tag (true) or not (false).
 
bool is_p {false}
 Current state is either inside a html <p> tag (true) or not (false).
 

Additional Inherited Members

- Public Attributes inherited from sharg::detail::format_help_base< format_html >
parser_meta_data meta
 Stores all meta information about the application.
 
friend derived_type
 Befriend the derived type so it can access private functions.
 
- Protected Member Functions inherited from sharg::detail::format_help_base< format_html >
format_htmlderived_t ()
 Returns the derived type.
 
void print_synopsis ()
 Prints a synopsis in any format.
 
void print_line (std::string const &text)
 Delegates to sharg::print_line(std::string const & text, true) of each format.
 
void print_version ()
 Prints the version information.
 
void print_legal ()
 Prints the legal information.
 
- Static Protected Member Functions inherited from sharg::detail::format_base
template<typename value_type >
static std::string get_type_name_as_string (value_type const &)
 Returns the input type as a string (reflection).
 
template<detail::is_container_option container_type>
static std::string get_type_name_as_string (container_type const &)
 Returns the value_type of the input container as a string (reflection).
 
template<typename option_value_type >
static std::string option_type_and_list_info (option_value_type const &value)
 Formats the type of a value for the help page printing.
 
template<detail::is_container_option container_type>
static std::string option_type_and_list_info (container_type const &container)
 Formats the container and its value_type for the help page printing.
 
static std::string prep_id_for_help (char const short_id, std::string const &long_id)
 Formats the option/flag identifier pair for the help page printing.
 
static std::string escape_special_xml_chars (std::string const &original)
 Escapes certain characters for correct output.
 
static std::string expand_multiple_flags (std::string const &flag_cluster)
 Expands multiple one character flag identifiers for pretty help output.
 
template<typename option_type , typename default_type >
static std::string get_default_message (option_type const &option, default_type const &value)
 Returns the default message for the help page.
 
- Protected Attributes inherited from sharg::detail::format_help_base< format_html >
update_notifications version_check_dev_decision
 Set on construction and indicates whether the developer deactivated the version check calls completely.
 
std::vector< std::function< void()> > parser_set_up_calls
 Vector of functions that stores all calls except add_positional_option.
 
std::vector< std::function< void()> > positional_option_calls
 Vector of functions that stores add_positional_option calls.
 
unsigned positional_option_count
 Keeps track of the number of positional options.
 
std::vector< std::stringcommand_names
 The names of subcommand programs.
 
bool show_advanced_options
 Whether to show advanced options or not.
 

Detailed Description

The format that prints the help page as html to std::cout.

The help page printing is not done immediately, because the user might not provide meta information, positional options, etc. in the correct order. In addition the needed order would be different from the parse format. Thus the calls are stored (parser_set_up_calls and positional_option_calls) and only evaluated when calling format_help::parse().

Remarks
For a complete overview, take a look at Parser

Constructor & Destructor Documentation

◆ format_html()

sharg::detail::format_html::format_html ( std::vector< std::string > const & names,
update_notifications const version_updates,
bool const advanced = false )
inline

Defaulted.

Member Function Documentation

◆ in_bold()

std::string sharg::detail::format_html::in_bold ( std::string const & str)
inlineprivate

Format string as in_bold.

Parameters
[in]strThe input string to format in bold.
Returns
The string str wrapped in bold formatting.

◆ print_line()

void sharg::detail::format_html::print_line ( std::string const & text,
bool line_is_paragraph )
inlineprivate

Prints a text in HTML format to std::cout.

Parameters
[in]textThe text to print.
[in]line_is_paragraphWhether to insert as paragraph or just a line (only one line break if not a paragraph).

◆ print_list_item()

void sharg::detail::format_html::print_list_item ( std::string const & term,
std::string const & desc )
inlineprivate

Prints a help page list_item in HTML format to std::cout.

Parameters
[in]termThe key of the key-value pair of the list item.
[in]descThe value of the key-value pair of the list item.

A list item is composed of a key (term) and value (desc) and usually used for option identifier-description-pairs.

◆ print_section()

void sharg::detail::format_html::print_section ( std::string const & title)
inlineprivate

Prints a section title in HTML format to std::cout.

Parameters
[in]titleThe title of the section of the help page.

◆ print_subsection()

void sharg::detail::format_html::print_subsection ( std::string const & title)
inlineprivate

Prints a subsection title in HTML format to std::cout.

Parameters
[in]titleThe title of the subsection of the help page.

◆ to_html()

std::string sharg::detail::format_html::to_html ( std::string const & input)
inlineprivate

Converts console output formatting to the HTML equivalent.

Parameters
[in]inputThe text to transform.

The documentation for this class was generated from the following file:
Hide me