NCBI C++ ToolKit
Public Member Functions | Private Attributes | List of all members
CNcbiArguments Class Reference

Search Toolkit Book for CNcbiArguments

CNcbiArguments –. More...

#include <corelib/ncbienv.hpp>

+ Collaboration diagram for CNcbiArguments:

Public Member Functions

 CNcbiArguments (int argc, const char *const *argv, const string &program_name=kEmptyStr, const string &real_name=kEmptyStr)
 Constructor. More...
 
virtual ~CNcbiArguments (void)
 Destructor. More...
 
 CNcbiArguments (const CNcbiArguments &args)
 Copy constructor. More...
 
CNcbiArgumentsoperator= (const CNcbiArguments &args)
 Assignment operator. More...
 
void Reset (int argc, const char *const *argv, const string &program_name=kEmptyStr, const string &real_name=kEmptyStr)
 Reset arguments. More...
 
SIZE_TYPE Size (void) const
 Get size (number) of arguments. More...
 
const stringoperator[] (SIZE_TYPE pos) const
 Get the argument specified by "pos". More...
 
void Add (const string &arg)
 Add a new argument. More...
 
void Shift (int n=1)
 Delete arguments from 1 to n. More...
 
const stringGetProgramName (EFollowLinks follow_links=eIgnoreLinks) const
 Get program name. More...
 
string GetProgramBasename (EFollowLinks follow_links=eIgnoreLinks) const
 Get program base name. More...
 
string GetProgramDirname (EFollowLinks follow_links=eIgnoreLinks) const
 Get program directory name. More...
 
void SetProgramName (const string &program_name, const string &real_name=kEmptyStr)
 Set program name. More...
 

Private Attributes

string m_ProgramName
 Program name if different from the default m_Args[0]. More...
 
deque< stringm_Args
 Queue of arguments. More...
 
string m_ResolvedName
 
CFastMutex m_ResolvedNameMutex
 

Detailed Description

CNcbiArguments –.

Store application command-line arguments & application name.

CNcbiArgument provides a data structure for storing and accessing the command line arguments and application name.

Definition at line 224 of file ncbienv.hpp.

Constructor & Destructor Documentation

CNcbiArguments::CNcbiArguments ( int  argc,
const char *const argv,
const string program_name = kEmptyStr,
const string real_name = kEmptyStr 
)

Constructor.

Parameters
argcStandard argument count
argvStandard argument vector
program_nameProgram name
real_nameResolved name

Definition at line 285 of file ncbienv.cpp.

References Reset().

CNcbiArguments::~CNcbiArguments ( void  )
virtual

Destructor.

Definition at line 293 of file ncbienv.cpp.

CNcbiArguments::CNcbiArguments ( const CNcbiArguments args)

Copy constructor.

Definition at line 299 of file ncbienv.cpp.

Member Function Documentation

void CNcbiArguments::Add ( const string arg)

Add a new argument.

Definition at line 409 of file ncbienv.cpp.

References m_Args.

string CNcbiArguments::GetProgramBasename ( EFollowLinks  follow_links = eIgnoreLinks) const

Get program base name.

Definition at line 380 of file ncbienv.cpp.

References GetProgramName(), and NPOS.

Referenced by CNcbiApplication::LoadConfig().

string CNcbiArguments::GetProgramDirname ( EFollowLinks  follow_links = eIgnoreLinks) const

Get program directory name.

Program name includes the last '/'.

Definition at line 390 of file ncbienv.cpp.

References GetProgramName(), NcbiEmptyString, and NPOS.

Referenced by CMetaRegistry::GetDefaultSearchPath(), and CSystemPath::GetStdPath().

const string & CNcbiArguments::GetProgramName ( EFollowLinks  follow_links = eIgnoreLinks) const
CNcbiArguments & CNcbiArguments::operator= ( const CNcbiArguments args)

Assignment operator.

Definition at line 308 of file ncbienv.cpp.

References copy(), m_Args, and m_ProgramName.

const string& CNcbiArguments::operator[] ( SIZE_TYPE  pos) const
inline

Get the argument specified by "pos".

Definition at line 257 of file ncbienv.hpp.

References m_Args.

void CNcbiArguments::Reset ( int  argc,
const char *const argv,
const string program_name = kEmptyStr,
const string real_name = kEmptyStr 
)

Reset arguments.

Delete all cached args and program name. Load new ones from "argc", "argv", "program_name", and "real_name".

Parameters
argcStandard argument count
argvStandard argument vector
program_nameProgram name
real_nameResolved name

Definition at line 320 of file ncbienv.cpp.

References ERR_POST_X, i, Info(), m_Args, NCBI_THROW, SetProgramName(), and Warning().

Referenced by CNcbiArguments().

void CNcbiArguments::SetProgramName ( const string program_name,
const string real_name = kEmptyStr 
)

Set program name.

If real_name is supplied, it should be the fully resolved path to the executable (whereas program_name may legitimately involve symlinks).

Definition at line 400 of file ncbienv.cpp.

References m_ProgramName, m_ResolvedName, and m_ResolvedNameMutex.

Referenced by Reset().

void CNcbiArguments::Shift ( int  n = 1)

Delete arguments from 1 to n.

Definition at line 414 of file ncbienv.cpp.

References m_Args.

Referenced by CCommandArgDescriptions::CreateArgs().

SIZE_TYPE CNcbiArguments::Size ( void  ) const
inline

Member Data Documentation

deque<string> CNcbiArguments::m_Args
private

Queue of arguments.

Definition at line 286 of file ncbienv.hpp.

Referenced by Add(), GetProgramName(), operator=(), operator[](), Reset(), Shift(), and Size().

string CNcbiArguments::m_ProgramName
private

Program name if different from the default m_Args[0].

Definition at line 284 of file ncbienv.hpp.

Referenced by GetProgramName(), operator=(), and SetProgramName().

string CNcbiArguments::m_ResolvedName
mutableprivate

Definition at line 288 of file ncbienv.hpp.

Referenced by GetProgramName(), and SetProgramName().

CFastMutex CNcbiArguments::m_ResolvedNameMutex
mutableprivate

Definition at line 289 of file ncbienv.hpp.

Referenced by GetProgramName(), and SetProgramName().


The documentation for this class was generated from the following files:
Modified on Mon Jul 27 20:17:19 2015 by modify_doxy.py rev. 426318