GClasses

GClasses::GArgReader Class Reference

Parses command-line args and provides methods to conveniently process them. More...

#include <GApp.h>

List of all members.

Public Member Functions

 GArgReader (int argc, char *argv[])
 Pass the args that are passed in to main.
int get_pos ()
 Returns the current position--that is, the argument number.
void set_pos (int n)
 Sets the current position.
const char * peek ()
 Returns the current arg (without advancing)
const char * pop_string ()
 Returns the current arg as a string, and advances. Throws an exception if the end of the args was already reached before this call.
unsigned int pop_uint ()
 Returns the current arg as a uint, and advances. Throws an exception if the end of the args was already reached before this call.
double pop_double ()
 Returns the current arg as a double, and advances. Throws an exception if the end of the args was already reached before this call.
bool if_pop (const char *flagName)
 If the current arg matches flagName, advances and returns true. Otherwise, returns false (without advancing).
int size ()
 Returns the number of remaining args.
bool next_is_flag ()
 Returns true if there is another arg, and it begins with '-'.
bool next_is_uint ()
 Returns true if there is another arg, and it would parse accurately as an unsigned integer.

Detailed Description

Parses command-line args and provides methods to conveniently process them.


Constructor & Destructor Documentation

GClasses::GArgReader::GArgReader ( int  argc,
char *  argv[] 
)

Pass the args that are passed in to main.


Member Function Documentation

int GClasses::GArgReader::get_pos ( )

Returns the current position--that is, the argument number.

bool GClasses::GArgReader::if_pop ( const char *  flagName)

If the current arg matches flagName, advances and returns true. Otherwise, returns false (without advancing).

bool GClasses::GArgReader::next_is_flag ( )

Returns true if there is another arg, and it begins with '-'.

bool GClasses::GArgReader::next_is_uint ( )

Returns true if there is another arg, and it would parse accurately as an unsigned integer.

const char* GClasses::GArgReader::peek ( )

Returns the current arg (without advancing)

double GClasses::GArgReader::pop_double ( )

Returns the current arg as a double, and advances. Throws an exception if the end of the args was already reached before this call.

const char* GClasses::GArgReader::pop_string ( )

Returns the current arg as a string, and advances. Throws an exception if the end of the args was already reached before this call.

unsigned int GClasses::GArgReader::pop_uint ( )

Returns the current arg as a uint, and advances. Throws an exception if the end of the args was already reached before this call.

void GClasses::GArgReader::set_pos ( int  n)

Sets the current position.

int GClasses::GArgReader::size ( )

Returns the number of remaining args.