LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
testing::details::CommandLineArguments Class Reference

Reads and makes available the command line parameters. More...

#include "unit_test_base.h"

Public Member Functions

 CommandLineArguments ()
 Constructor: automatically parses from Boost arguments. More...
 
 CommandLineArguments (int argc, char **argv)
 Constructor: parses from specified arguments. More...
 
void ParseArguments (int argc, char **argv)
 Parses arguments. More...
 
std::string Executable () const
 Returns the name of the executable as started. More...
 
std::vector< std::string > const & Arguments () const
 Returns the list of non-Boost-test arguments on the command line. More...
 
bool hasArgument (size_t iArg) const
 Returns whether we have arguments up to the iArg-th (0-based) More...
 
std::string const & Argument (size_t iArg) const
 Returns the value of the iArg-th (0-based; no range check!) More...
 

Private Member Functions

void Clear ()
 Erases the stored arguments. More...
 

Private Attributes

std::string exec_name
 name of the test executable (from argv[0]) More...
 
std::vector< std::string > args
 command line arguments (from argv[0]) More...
 

Detailed Description

Reads and makes available the command line parameters.

Definition at line 63 of file unit_test_base.h.

Constructor & Destructor Documentation

testing::details::CommandLineArguments::CommandLineArguments ( )
inline

Constructor: automatically parses from Boost arguments.

Definition at line 66 of file unit_test_base.h.

References Clear().

66 { Clear(); }
void Clear()
Erases the stored arguments.
testing::details::CommandLineArguments::CommandLineArguments ( int  argc,
char **  argv 
)
inline

Constructor: parses from specified arguments.

Definition at line 69 of file unit_test_base.h.

References ParseArguments().

69 { ParseArguments(argc, argv); }
void ParseArguments(int argc, char **argv)
Parses arguments.

Member Function Documentation

std::string const& testing::details::CommandLineArguments::Argument ( size_t  iArg) const
inline

Returns the value of the iArg-th (0-based; no range check!)

Definition at line 84 of file unit_test_base.h.

References args.

84 { return args[iArg]; }
std::vector< std::string > args
command line arguments (from argv[0])
std::vector<std::string> const& testing::details::CommandLineArguments::Arguments ( ) const
inline

Returns the list of non-Boost-test arguments on the command line.

Definition at line 78 of file unit_test_base.h.

References args.

78 { return args; }
std::vector< std::string > args
command line arguments (from argv[0])
void testing::details::CommandLineArguments::Clear ( )
inlineprivate

Erases the stored arguments.

Definition at line 91 of file unit_test_base.h.

Referenced by CommandLineArguments(), and ParseArguments().

92  {
93  exec_name.clear();
94  args.clear();
95  }
std::string exec_name
name of the test executable (from argv[0])
std::vector< std::string > args
command line arguments (from argv[0])
std::string testing::details::CommandLineArguments::Executable ( ) const
inline

Returns the name of the executable as started.

Definition at line 75 of file unit_test_base.h.

References exec_name.

75 { return exec_name; }
std::string exec_name
name of the test executable (from argv[0])
bool testing::details::CommandLineArguments::hasArgument ( size_t  iArg) const
inline

Returns whether we have arguments up to the iArg-th (0-based)

Definition at line 81 of file unit_test_base.h.

References args.

81 { return iArg < args.size(); }
std::vector< std::string > args
command line arguments (from argv[0])
void testing::details::CommandLineArguments::ParseArguments ( int  argc,
char **  argv 
)
inline

Parses arguments.

Definition at line 99 of file unit_test_base.h.

References args, Clear(), and exec_name.

Referenced by CommandLineArguments().

100  {
101  Clear();
102  if (argc == 0) return;
103 
104  exec_name = argv[0];
105 
106  args.resize(argc - 1);
107  std::copy(argv + 1, argv + argc, args.begin());
108 
109  } // CommandLineArguments:ParseArguments()
std::string exec_name
name of the test executable (from argv[0])
std::vector< std::string > args
command line arguments (from argv[0])
void Clear()
Erases the stored arguments.

Member Data Documentation

std::string testing::details::CommandLineArguments::exec_name
private

name of the test executable (from argv[0])

Definition at line 87 of file unit_test_base.h.

Referenced by Executable(), and ParseArguments().


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