42 #ifndef TEUCHOS_COMMAND_LINE_PROCESSOR_HPP 
   43 #define TEUCHOS_COMMAND_LINE_PROCESSOR_HPP 
   56 #include "Teuchos_Ptr.hpp" 
   84   {
public: 
ParseError(
const std::string& what_arg) : std::logic_error(what_arg) {}};
 
  100     ,PARSE_HELP_PRINTED            =  1 
 
  101     ,PARSE_UNRECOGNIZED_OPTION     =  2 
 
  126     bool    throwExceptions       = 
true 
  127     ,
bool   recogniseAllOptions   = 
true 
  128     ,
bool   addOutputSetupOptions = 
false 
  141   void throwExceptions( 
const bool & throwExceptions );
 
  144   bool throwExceptions() 
const;
 
  147   void recogniseAllOptions( 
const bool & recogniseAllOptions );
 
  150   bool recogniseAllOptions() 
const;
 
  153   void addOutputSetupOptions( 
const bool &addOutputSetupOptions );
 
  156   bool addOutputSetupOptions() 
const;
 
  165   void setDocString( 
const char doc_string[] );
 
  180     const char     option_true[]
 
  181     ,
const char    option_false[]
 
  183     ,
const char    documentation[] = NULL
 
  197     const char     option_name[]
 
  199     ,
const char    documentation[] = NULL
 
  200     ,
const bool    required        = 
false 
  214     const char     option_name[]
 
  215     ,
long int      *option_val
 
  216     ,
const char    documentation[] = NULL
 
  217     ,
const bool    required        = 
false 
  231     const char     option_name[]
 
  233     ,
const char    documentation[] = NULL
 
  234     ,
const bool    required        = 
false 
  248     const char     option_name[]
 
  249     ,
long long int *option_val
 
  250     ,
const char    documentation[] = NULL
 
  251     ,
const bool    required        = 
false 
  265     const char     option_name[]
 
  267     ,
const char    documentation[] = NULL
 
  268     ,
const bool    required        = 
false 
  282     const char     option_name[]
 
  284     ,
const char    documentation[] = NULL
 
  285     ,
const bool    required        = 
false 
  299     const char     option_name[]
 
  300     ,std::string   *option_val
 
  301     ,
const char    documentation[] = NULL
 
  302     ,
const bool    required        = 
false 
  333   template <
class EType>
 
  335     const char    enum_option_name[]
 
  336     ,
EType        *enum_option_val
 
  337     ,
const int    num_enum_opt_values
 
  338     ,
const EType  enum_opt_values[]
 
  339     ,
const char*  enum_opt_names[]
 
  340     ,
const char   documentation[] = NULL
 
  341     ,
const bool   required        = 
false 
  408   EParseCommandLineReturn  parse(
 
  411     ,std::ostream   *errout = &std::cerr
 
  427    void printHelpMessage( 
const char program_name[], std::ostream &out ) 
const;
 
  440   enum EOptType { OPT_NONE, OPT_BOOL_TRUE, OPT_BOOL_FALSE, OPT_INT, OPT_LONG_INT, OPT_SIZE_T,
 
  442   OPT_DOUBLE, OPT_FLOAT, OPT_STRING, OPT_ENUM_INT };
 
  459   struct opt_val_val_t {
 
  465     opt_val_val_t( EOptType opt_type_in, 
const any& opt_val_in, 
bool required_in )
 
  466       :opt_type(opt_type_in),opt_val(opt_val_in),required(required_in),was_read(false)
 
  482     opt_doc_t(EOptType opt_type_in, 
const std::string& opt_name_in, 
const std::string& opt_name_false_in
 
  483             ,
const std::string &documentation_in, 
const any &default_val_in )
 
  484       :opt_type(opt_type_in),opt_name(opt_name_in),opt_name_false(opt_name_false_in)
 
  485       ,documentation(documentation_in),default_val(default_val_in)
 
  488     std::string  opt_name;
 
  489     std::string  opt_name_false; 
 
  490     std::string  documentation;
 
  495   typedef std::vector<opt_doc_t>   options_documentation_list_t;
 
  498   struct enum_opt_data_t {
 
  500       :enum_option_val(NULL), num_enum_opt_values(0)
 
  503       int          *_enum_option_val
 
  504       ,
const int    _num_enum_opt_values
 
  505       ,
const int    _enum_opt_values[]
 
  506       ,
const char*  _enum_opt_names[]
 
  508       :enum_option_val(_enum_option_val)
 
  509       ,num_enum_opt_values(_num_enum_opt_values)
 
  510       ,enum_opt_values(_enum_opt_values,_enum_opt_values+_num_enum_opt_values)
 
  512         for( 
int k = 0; k < num_enum_opt_values; ++k )
 
  513           enum_opt_names.push_back(std::string(_enum_opt_names[k]));
 
  515     int                  *enum_option_val;
 
  516     int                  num_enum_opt_values;
 
  517     std::vector<int>     enum_opt_values;
 
  518     std::vector<std::string>  enum_opt_names;
 
  522   typedef std::vector<enum_opt_data_t> enum_opt_data_list_t;
 
  527   bool                             throwExceptions_;
 
  528   bool                             recogniseAllOptions_;
 
  529   bool                             addOutputSetupOptions_;
 
  530   std::string                      doc_string_;
 
  534 #pragma warning(push) 
  535 #pragma warning(disable:4251) 
  537   mutable options_list_t           options_list_;
 
  538   options_documentation_list_t     options_documentation_list_;
 
  539   enum_opt_data_list_t             enum_opt_data_list_;
 
  544   bool  output_all_front_matter_;
 
  545   bool  output_show_line_prefix_;
 
  546   bool  output_show_tab_count_;
 
  547   bool  output_show_proc_rank_;
 
  548   int   output_to_root_rank_only_;
 
  549   bool  print_rcpnode_statistics_on_exit_;
 
  550   bool  show_timer_summary_on_exit_;
 
  552   bool printed_timer_summary_;
 
  554   bool  added_extra_output_setup_options_;
 
  555   bool  in_add_extra_output_setup_options_;
 
  557   static const bool  output_all_front_matter_default_;
 
  558   static const bool  output_show_line_prefix_default_;
 
  559   static const bool  output_show_tab_count_default_;
 
  560   static const bool  output_show_proc_rank_default_;
 
  561   static const int   output_to_root_rank_only_default_;
 
  562   static const bool  print_rcpnode_statistics_on_exit_default_;
 
  563   static const bool  show_timer_summary_on_exit_default_;
 
  569   void add_extra_output_setup_options() 
const;
 
  573     const char    enum_option_name[]
 
  574     ,
int          *enum_option_val
 
  575     ,
const int    num_enum_opt_values
 
  576     ,
const int    enum_opt_values[]
 
  577     ,
const char*  enum_opt_names[]
 
  578     ,
const char   documentation[]
 
  586     ,
const std::string   &enum_opt_name
 
  588     ,
const std::string   &enum_str_val
 
  589     ,std::ostream        *errout
 
  593   void print_enum_opt_names(
 
  599   std::string enum_opt_default_val_name(
 
  600     const std::string    &enum_name
 
  602     ,std::ostream        *errout
 
  606   int find_enum_opt_index(
 
  607     const std::string           &enum_opt_name
 
  609     ,
const enum_opt_data_t      &enum_data
 
  610     ,std::ostream               *errout
 
  617     ,std::string   *opt_name
 
  618     ,std::string   *opt_val_str 
 
  622   std::string opt_type_str( EOptType ) 
const;
 
  628     ,std::ostream   *errout
 
  672     virtual void summarize(std::ostream &out=std::cout) = 0;
 
  695 { throwExceptions_ = throwExceptions_in; }
 
  700 { 
return throwExceptions_; }
 
  705 { recogniseAllOptions_ = recogniseAllOptions_in; }
 
  710 { 
return recogniseAllOptions_; }
 
  715 { addOutputSetupOptions_ = addOutputSetupOptions_in; }
 
  720 { 
return addOutputSetupOptions_; }
 
  723 template <
class EType>
 
  726   const char    enum_option_name[]
 
  727   ,
EType       *enum_option_val
 
  728   ,
const int    num_enum_opt_values
 
  729   ,
const EType  enum_opt_values[]
 
  730   ,
const char*  enum_opt_names[]
 
  731   ,
const char   documentation[]
 
  746     ,reinterpret_cast<int*>(enum_option_val)
 
  748     ,reinterpret_cast<const int*>(enum_opt_values)
 
  757 std::string CommandLineProcessor::opt_type_str( EOptType opt_type )
 const 
  773     case OPT_LONG_LONG_INT:
 
  774       str = 
"long long int";
 
  798 #endif // TEUCHOS_COMMAND_LINE_PROCESSOR_HPP 
Modified boost::any class for holding a templated value. 
 
Thrown if –help was specified and throwExceptions==true. 
 
Template classes for testing assertions at compile time. 
 
bool throwExceptions() const 
Returns true if an std::exception is thrown, there is a parse error, or help is printed. 
 
virtual ~TimeMonitorSurrogate()
! brief. 
 
Thrown if an unrecognized option was found and throwExceptions==true. 
 
void setOption(const char option_true[], const char option_false[], bool *option_val, const char documentation[]=NULL)
Set a boolean option. 
 
Interface by which CommandLineProcessor may use TimeMonitor. 
 
bool addOutputSetupOptions() const 
Returns true options will be automatically added to setup Teuchos::VerboseObjectBase::getDefaultOStre...
 
Provides std::map class for deficient platforms. 
 
EParseCommandLineReturn
Return value for CommandLineProcessor::parse(). Note: These enums are all given non-negative values s...
 
bool recogniseAllOptions() const 
Returns true if all options must be recognized by the parser. 
 
Smart reference counting pointer class for automatic garbage collection. 
 
If instantiated (for Test!=0) then this should not compile! 
 
Thrown if a parse std::exception occurs and throwExceptions==true. 
 
Class that helps parse command line input arguments from (argc,argv[]) and set options. 
 
Simple wrapper class for raw pointers to single objects where no persisting relationship exists...