ATLAS Offline Software
Loading...
Searching...
No Matches
Options Class Reference
Collaboration diagram for Options:

Public Member Functions

 Options (int argc, char *argv[])
const stringgetProgName () const
const stringgetAction () const
const stringgetItem () const
string getOptByName (char opt) const
bool exists (char opt) const

Private Member Functions

 Options (const Options &)=delete
Optionsoperator= (const Options &)=delete

Private Attributes

std::map< char, stringm_argMap
string m_action
string m_item
string m_progName

Detailed Description

Definition at line 32 of file FCcmd.cxx.

Constructor & Destructor Documentation

◆ Options() [1/2]

Options::Options ( int argc,
char * argv[] )

Definition at line 54 of file FCcmd.cxx.

54 {
55 if( argc > 0 ) {
56 m_progName = string( argv[0] );
57 }
58 if( argc > 1 ) {
59 m_action = string( argv[1] );
60 }
61 if( argc > 2 ) {
62 m_item = string( argv[2] );
63 }
64 // scan from the beginning (in case there is a lone -h)
65 int pos = 1;
66 while( argc > pos ) {
67 char opt {};
68 string val;
69 string arg = string( argv[pos++] );
70 if( arg.length() == 2 && arg[0] == '-' ) {
71 opt = arg[1];
72 } else continue;
73 if( argc > pos ) {
74 arg = string( argv[pos] );
75 if( arg.length() != 2 or arg[0] != '-' ) {
76 val = std::move(arg);
77 pos++;
78 }
79 }
80 m_argMap[opt] = std::move(val);
81 }
82}
std::map< char, string > m_argMap
Definition FCcmd.cxx:43
string m_action
Definition FCcmd.cxx:44
string m_progName
Definition FCcmd.cxx:46
string m_item
Definition FCcmd.cxx:45
End of vector before end of string
Definition Arrayrep.cxx:228

◆ Options() [2/2]

Options::Options ( const Options & )
privatedelete

Member Function Documentation

◆ exists()

bool Options::exists ( char opt) const
inline

Definition at line 92 of file FCcmd.cxx.

92{ return m_argMap.find(opt) != m_argMap.end(); }

◆ getAction()

const string & Options::getAction ( ) const
inline

Definition at line 90 of file FCcmd.cxx.

90{ return m_action; }

◆ getItem()

const string & Options::getItem ( ) const
inline

Definition at line 91 of file FCcmd.cxx.

91{ return m_item; }

◆ getOptByName()

string Options::getOptByName ( char opt) const
inline

Definition at line 84 of file FCcmd.cxx.

84 {
85 auto it = m_argMap.find( opt );
86 return (it != m_argMap.end())? it->second : "" ;
87}

◆ getProgName()

const string & Options::getProgName ( ) const
inline

Definition at line 89 of file FCcmd.cxx.

89{ return m_progName; }

◆ operator=()

Options & Options::operator= ( const Options & )
privatedelete

Member Data Documentation

◆ m_action

string Options::m_action
private

Definition at line 44 of file FCcmd.cxx.

◆ m_argMap

std::map<char, string> Options::m_argMap
private

Definition at line 43 of file FCcmd.cxx.

◆ m_item

string Options::m_item
private

Definition at line 45 of file FCcmd.cxx.

◆ m_progName

string Options::m_progName
private

Definition at line 46 of file FCcmd.cxx.


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