YASK
Yet Another Stencil Kit: a software framework for creating HPC stencil code. Copyright 2014-2023 Intel Corporation.
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
yask::command_line_parser::option_base Class Referenceabstract

Base class for a command-line option. More...

#include <yask_common_api.hpp>

+ Inheritance diagram for yask::command_line_parser::option_base:

Public Member Functions

 option_base (const std::string &name, const std::string &help_msg, const std::string &current_value_prefix=std::string("Current value = "), const std::string &help_line_prefix=std::string(" "))
 Constructor.
 
virtual const std::string & get_name () const
 Get the current option name.
 
virtual const std::string & get_help () const
 Get the unformatted help string.
 
virtual void print_help (std::ostream &os, int width) const
 Print help on this option.
 
virtual std::ostream & print_value (std::ostream &os) const =0
 Print current value of this option.
 
virtual bool check_arg (const string_vec &args, int &argi)=0
 Check for matching option and any needed args at args[argi].
 

Protected Member Functions

virtual void _print_help (std::ostream &os, const std::string &display_name, int width) const
 Format and print help for option named display_name to os.
 
virtual bool _is_opt (const string_vec &args, int &argi, const std::string &str) const
 Check for matching option to str at args[argi].
 
virtual double _double_val (const string_vec &args, int &argi)
 Get one double value from args[argi++].
 
virtual idx_t _idx_val (const string_vec &args, int &argi)
 Get one idx_t value from args[argi++].
 
virtual std::string _string_val (const string_vec &args, int &argi)
 Get one string value from args[argi++].
 

Detailed Description

Base class for a command-line option.

The API programmer can extend this class to add new option types.

Member Function Documentation

◆ _is_opt()

virtual bool yask::command_line_parser::option_base::_is_opt ( const string_vec args,
int &  argi,
const std::string &  str 
) const
protectedvirtual

Check for matching option to str at args[argi].

Returns
true and increments argi if match, false if not a match.

◆ _double_val()

virtual double yask::command_line_parser::option_base::_double_val ( const string_vec args,
int &  argi 
)
protectedvirtual

Get one double value from args[argi++].

Returns
the value at args[argi] and increments argi.
Exceptions
yask_exceptionif args[argi] is not a double.

◆ _idx_val()

virtual idx_t yask::command_line_parser::option_base::_idx_val ( const string_vec args,
int &  argi 
)
protectedvirtual

Get one idx_t value from args[argi++].

Returns
the value at args[argi] and increments argi.
Exceptions
yask_exceptionif args[argi] is not an integer.

◆ _string_val()

virtual std::string yask::command_line_parser::option_base::_string_val ( const string_vec args,
int &  argi 
)
protectedvirtual

Get one string value from args[argi++].

Returns
the value at args[argi] and increments argi.
Exceptions
yask_exceptionif args[argi] does not exist.

◆ print_help()

virtual void yask::command_line_parser::option_base::print_help ( std::ostream &  os,
int  width 
) const
inlinevirtual

◆ print_value()

virtual std::ostream & yask::command_line_parser::option_base::print_value ( std::ostream &  os) const
pure virtual

◆ check_arg()

virtual bool yask::command_line_parser::option_base::check_arg ( const string_vec args,
int &  argi 
)
pure virtual

Check for matching option and any needed args at args[argi].

Returns
true, sets value of option, and increments argi if match; false if no match, and doesn't modify argi.

Implemented in yask::command_line_parser::bool_option, yask::command_line_parser::int_option, yask::command_line_parser::double_option, yask::command_line_parser::idx_option, yask::command_line_parser::string_option, and yask::command_line_parser::string_list_option.


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