Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Location: bacline.h
Link against: bafl.lib

Class CCommandLineArguments

CCommandLineArguments

Support

Supported from 5.0

Description

Parses command line arguments.

The class provides functions to access the arguments that are supplied when a program is launched as a new process.

The program name is returned as argument 0. Other arguments are returned as arguments 1, 2 etc.

The Count() function indicates how many arguments there are, including the program name. Arguments may be quoted to contain blanks and quotes.

The command line arguments and process name occupy 256 characters each. In order to minimise the space used throughout the lifetime of a program, it is recommended that the program parse the arguments shortly after initialisation, save the argument values appropriately, and then destroy the CCommandLineArguments object.

This class is not intended for user derivation

Derivation

CBaseBase class for all classes to be instantiated on the heap
CCommandLineArgumentsParses command line arguments

Defined in CCommandLineArguments:
Arg(), Count(), NewL(), NewLC(), ~CCommandLineArguments()

Inherited from CBase:
operator new()


Construction and destruction


NewL()

static CCommandLineArguments* NewL();

Description

Allocates and constructs a command line arguments parser. The function leaves if there is insufficient memory.

Return value

CCommandLineArguments*

The command line arguments parser.


NewLC()

static CCommandLineArguments* NewLC();

Description

Allocates and constructs a command line arguments parser, putting the returned pointer onto the cleanup stack. The function leaves if there is insufficient memory.

Return value

CCommandLineArguments*

The command line arguments parser.


~CCommandLineArguments()

~CCommandLineArguments();

Description

Frees resources prior to destruction.

[Top]


Obtaining arguments


Count()

TInt Count() const;

Description

Returns the number of command line arguments, including the program name.

Return value

TInt

The number of command line arguments, plus one for the program name. Returns 1, if no arguments are specified.


Arg()

TPtrC Arg(TInt aArg) const;

Description

Returns a non-modifiable pointer descriptor representing the specified command-line argument.

Arg(0) is the file name as specified on the command line. Arg(1), Arg(2) etc. are the arguments specified to the command.

The pointer descriptor is valid throughout the lifetime of the CCommandLineArguments object. If you wish to retain argument values after the CCommandLineArguments object is destroyed, you should copy the argument data into a different object.

Parameters

TInt aArg

The index of the desired argument. This number must be less than Count(). Specify 0 for the name used to invoke the process. Specify 1, 2 etc. for the arguments.

Return value

TPtrC

Non-modifiable pointer descriptor to the specified argument text.