All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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 65 of file unit_test_base.h.

Constructor & Destructor Documentation

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

Constructor: automatically parses from Boost arguments.

Definition at line 68 of file unit_test_base.h.

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

Constructor: parses from specified arguments.

Definition at line 71 of file unit_test_base.h.

72  { 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 87 of file unit_test_base.h.

87 { 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 81 of file unit_test_base.h.

81 { 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 94 of file unit_test_base.h.

94 { exec_name.clear(); args.clear(); }
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 78 of file unit_test_base.h.

78 { 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 84 of file unit_test_base.h.

84 { 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.

99  {
100  Clear();
101  if (argc == 0) return;
102 
103  exec_name = argv[0];
104 
105  args.resize(argc - 1);
106  std::copy(argv + 1, argv + argc, args.begin());
107 
108  } // 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])
T copy(T const &v)
void Clear()
Erases the stored arguments.

Member Data Documentation

std::vector<std::string> testing::details::CommandLineArguments::args
private

command line arguments (from argv[0])

Definition at line 91 of file unit_test_base.h.

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

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

Definition at line 90 of file unit_test_base.h.


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