NCBI C++ ToolKit
Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members

Search Toolkit Book for CArgs

CArgs –. More...

#include <corelib/ncbiargs.hpp>

+ Collaboration diagram for CArgs:

Public Member Functions

 CArgs (void)
 Constructor. More...
 
 ~CArgs (void)
 Destructor. More...
 
 CArgs (const CArgs &other)
 Creating copy of this object usually makes no sense if it is really required, please use Assign method. More...
 
CArgsoperator= (const CArgs &other)
 Creating copy of this object usually makes no sense if it is really required, please use Assign method. More...
 
CArgsAssign (const CArgs &other)
 Copy contents of another object into this one. More...
 
bool Exist (const string &name) const
 Check existence of argument description. More...
 
const CArgValueoperator[] (const string &name) const
 Get value of argument by name. More...
 
size_t GetNExtra (void) const
 Get the number of unnamed positional (a.k.a. extra) args. More...
 
const CArgValueoperator[] (size_t idx) const
 Return N-th extra arg value, N = 1 to GetNExtra(). More...
 
vector< CRef< CArgValue > > GetAll (void) const
 Get all available arguments. More...
 
stringPrint (string &str) const
 Print (append) all arguments to the string "str" and return "str". More...
 
void Add (CArgValue *arg, bool update=false, bool add_value=false)
 Add new argument name and value. More...
 
bool IsEmpty (void) const
 Check if there are no arguments in this container. More...
 
void Remove (const string &name)
 Remove argument of name "name". More...
 
void Reset (void)
 Remove all arguments. More...
 
string GetCommand (void) const
 Get current command. More...
 

Protected Member Functions

CArgsSetCommand (const string &command)
 Set current command. More...
 

Private Types

typedef set< CRef< CArgValue > > TArgs
 Type for arguments. More...
 
typedef TArgs::iterator TArgsI
 Type for iterator. More...
 
typedef TArgs::const_iterator TArgsCI
 Type for const iterator. More...
 

Private Member Functions

TArgsCI x_Find (const string &name) const
 Find argument value with name "name". More...
 
TArgsI x_Find (const string &name)
 

Private Attributes

TArgs m_Args
 Assoc. map of arguments' name/value. More...
 
size_t m_nExtra
 Cached # of unnamed positional arguments. More...
 
string m_Command
 

Friends

class CCommandArgDescriptions
 

Detailed Description

CArgs –.

Defines parsed arguments.

Argument values are obtained from the unprocessed command-line arguments (via CNcbiArguments) and then verified and processed according to the argument descriptions defined by user in "CArgDescriptions".

NOTE: the extra arguments can be accessed using virtual names: "#1", "#2", "#3", ..., "#<GetNExtra()>" in the order of insertion (by method Add).

Definition at line 356 of file ncbiargs.hpp.

Member Typedef Documentation

typedef set< CRef<CArgValue> > CArgs::TArgs
private

Type for arguments.

Definition at line 454 of file ncbiargs.hpp.

Type for const iterator.

Definition at line 456 of file ncbiargs.hpp.

typedef TArgs::iterator CArgs::TArgsI
private

Type for iterator.

Definition at line 455 of file ncbiargs.hpp.

Constructor & Destructor Documentation

CArgs::CArgs ( void  )

Constructor.

Definition at line 1682 of file ncbiargs.cpp.

References m_nExtra.

CArgs::~CArgs ( void  )

Destructor.

Definition at line 1688 of file ncbiargs.cpp.

CArgs::CArgs ( const CArgs other)

Creating copy of this object usually makes no sense if it is really required, please use Assign method.

Definition at line 1693 of file ncbiargs.cpp.

References Assign().

Member Function Documentation

void CArgs::Add ( CArgValue arg,
bool  update = false,
bool  add_value = false 
)

Add new argument name and value.

Throw an exception if the "name" is not an empty string, and if there is an argument with this name already and "update" parameter is not set.

HINT: Use empty "name" to add extra (unnamed) args, and they will be automagically assigned with the virtual names: "#1", "#2", "#3", etc.

Parameters
argargument value added to the collection
updatewhen TRUE and argument already exists it will be replaced when FALSE throws an exception
add_valuewhen TRUE and argument already exists the value is added to the string list (multiple argument)

Definition at line 1850 of file ncbiargs.cpp.

References _ASSERT, CArgValue::AsString(), set< Key, Compare >::end(), CArgValue::GetName(), set< Key, Compare >::insert(), m_Args, CArgValue::m_Name, m_nExtra, NCBI_THROW, Remove(), s_ComposeNameExtra(), CArgValue::SetOrdinalPosition(), CArgValue::SetStringList(), set< Key, Compare >::size(), CArgDescriptions::VerifyName(), and x_Find().

Referenced by CArgDescriptions::x_PostCheck().

CArgs & CArgs::Assign ( const CArgs other)

Copy contents of another object into this one.

Definition at line 1703 of file ncbiargs.cpp.

References m_Args, m_Command, and m_nExtra.

Referenced by CArgs(), CInputStreamSource::InitArgs(), operator=(), and CXcompareAnnotsApplication::Run().

bool CArgs::Exist ( const string name) const

Check existence of argument description.

Return TRUE if arg "name" was described in the parent CArgDescriptions.

Definition at line 1746 of file ncbiargs.cpp.

References set< Key, Compare >::end(), m_Args, and x_Find().

Referenced by BuildAlgorithmParametersString(), CBlastDBAliasApp::ConvertGiFile(), CBlastDBAliasApp::CreateAliasFile(), CWinMaskConfig::CWinMaskConfig(), CStdCmdLineArgs::ExtractAlgorithmOptions(), CGenericSearchArgs::ExtractAlgorithmOptions(), CFilteringArgs::ExtractAlgorithmOptions(), CNuclArgs::ExtractAlgorithmOptions(), CCompositionBasedStatsArgs::ExtractAlgorithmOptions(), CPssmEngineArgs::ExtractAlgorithmOptions(), CPsiBlastArgs::ExtractAlgorithmOptions(), CPhiBlastArgs::ExtractAlgorithmOptions(), CKBlastpArgs::ExtractAlgorithmOptions(), CDeltaBlastArgs::ExtractAlgorithmOptions(), CMappingArgs::ExtractAlgorithmOptions(), CQueryOptionsArgs::ExtractAlgorithmOptions(), CMapperQueryOptionsArgs::ExtractAlgorithmOptions(), CBlastDatabaseArgs::ExtractAlgorithmOptions(), CIgBlastArgs::ExtractAlgorithmOptions(), CFormattingArgs::ExtractAlgorithmOptions(), CMapperFormattingArgs::ExtractAlgorithmOptions(), CMTArgs::ExtractAlgorithmOptions(), CRemoteArgs::ExtractAlgorithmOptions(), CMbIndexArgs::ExtractAlgorithmOptions(), CSearchStrategyArgs::GetExportStream(), CSearchStrategyArgs::GetImportStream(), GetSubjectFile(), CBlastDatabaseArgs::HasBeenSet(), CMbIndexArgs::HasBeenSet(), RecoverSearchStrategy(), CSampleBasicApplication::Run(), CSeedTopApp::Run(), CIgBlastnApp::Run(), CNcbiApplogApp::Run(), CBlastAppArgs::SetOptions(), CBlastpAppArgs::x_CreateOptionsHandle(), CBlastnAppArgs::x_CreateOptionsHandle(), CBlastxAppArgs::x_CreateOptionsHandle(), CTblastnAppArgs::x_CreateOptionsHandle(), CPsiBlastAppArgs::x_CreateOptionsHandle(), CArgDependencyGroup::x_Evaluate(), CArgDescriptions::x_PostCheck(), CDataLoadersUtil::x_SetupASNCacheDataLoader(), CDataLoadersUtil::x_SetupBlastDataLoader(), CDataLoadersUtil::x_SetupGenbankDataLoader(), CDataLoadersUtil::x_SetupLDS2DataLoader(), CDataLoadersUtil::x_SetupSRADataLoader(), and CDataLoadersUtil::x_SetupVDBDataLoader().

vector< CRef< CArgValue > > CArgs::GetAll ( void  ) const

Get all available arguments.

Definition at line 1797 of file ncbiargs.cpp.

References rapidjson::a, ITERATE, m_Args, and res.

Referenced by CJniUtil::GetArgsFromNcbiApp(), CArgDescriptions::x_CreateArg(), and CBlastAppArgs::x_IssueWarningsForIgnoredOptions().

string CArgs::GetCommand ( void  ) const
inline
size_t CArgs::GetNExtra ( void  ) const
inline
bool CArgs::IsEmpty ( void  ) const

Check if there are no arguments in this container.

Definition at line 1888 of file ncbiargs.cpp.

References set< Key, Compare >::empty(), and m_Args.

Referenced by CArgDescriptions::x_PostCheck().

CArgs & CArgs::operator= ( const CArgs other)

Creating copy of this object usually makes no sense if it is really required, please use Assign method.

Definition at line 1698 of file ncbiargs.cpp.

References Assign().

const CArgValue & CArgs::operator[] ( const string name) const

Get value of argument by name.

If the name starts with '-' (e.g. '-arg') the argument can also be found by 'arg' name if there is no another argument named 'arg'.

Throw an exception if such argument does not exist (not described in the CArgDescriptions).

Attention
CArgValue::operator bool() can return TRUE even if the argument was not specified in the command-line – if the argument has a default value.
See also
Exist() above.

Definition at line 1752 of file ncbiargs.cpp.

References set< Key, Compare >::end(), kMax_UInt, m_Args, m_nExtra, NCBI_THROW, s_ComposeNameExtra(), NStr::StringToUInt(), and x_Find().

const CArgValue & CArgs::operator[] ( size_t  idx) const

Return N-th extra arg value, N = 1 to GetNExtra().

Definition at line 1792 of file ncbiargs.cpp.

References s_ComposeNameExtra().

string & CArgs::Print ( string str) const
void CArgs::Remove ( const string name)

Remove argument of name "name".

Definition at line 1836 of file ncbiargs.cpp.

References set< Key, Compare >::erase(), set< Key, Compare >::find(), and m_Args.

Referenced by Add(), and CPsiBlastApp::x_RunLocalPsiBlastIterations().

void CArgs::Reset ( void  )

Remove all arguments.

Definition at line 1843 of file ncbiargs.cpp.

References set< Key, Compare >::clear(), m_Args, and m_nExtra.

Referenced by CDemoApp::Run(), and CTbl2AsnApp::Run().

CArgs* CArgs::SetCommand ( const string command)
inlineprotected

Set current command.

See also
CCommandArgDescriptions

Definition at line 447 of file ncbiargs.hpp.

References command.

Referenced by CCommandArgDescriptions::CreateArgs().

CArgs::TArgsCI CArgs::x_Find ( const string name) const
private

Find argument value with name "name".

Definition at line 1725 of file ncbiargs.cpp.

References set< Key, Compare >::end(), set< Key, Compare >::find(), m_Args, and s_IsArgNameChar().

Referenced by Add(), Exist(), and operator[]().

CArgs::TArgsI CArgs::x_Find ( const string name)
private

Friends And Related Function Documentation

friend class CCommandArgDescriptions
friend

Definition at line 465 of file ncbiargs.hpp.

Member Data Documentation

TArgs CArgs::m_Args
private

Assoc. map of arguments' name/value.

Definition at line 458 of file ncbiargs.hpp.

Referenced by Add(), Assign(), Exist(), GetAll(), IsEmpty(), operator[](), Print(), Remove(), Reset(), and x_Find().

string CArgs::m_Command
private

Definition at line 460 of file ncbiargs.hpp.

Referenced by Assign().

size_t CArgs::m_nExtra
private

Cached # of unnamed positional arguments.

Definition at line 459 of file ncbiargs.hpp.

Referenced by Add(), Assign(), CArgs(), operator[](), and Reset().


The documentation for this class was generated from the following files:
Modified on Thu Feb 22 13:22:28 2018 by modify_doxy.py rev. 546573