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

Public Member Functions

 Options (int argc, char *argv[])
const string & getProgName () const
const string & getAction () const
const string & getItem () const
string getOptByName (char opt) const
bool exists (char opt) const

Private Member Functions

 Options (const Options &)=delete
Options & operator= (const Options &)=delete

Private Attributes

std::map< char, string > m_argMap
string m_action
string m_item
string m_progName

Detailed Description

Definition at line 34 of file FCcmd.cxx.

Constructor & Destructor Documentation

◆ Options() [1/2]

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

Definition at line 56 of file FCcmd.cxx.

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

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

◆ getAction()

const string & Options::getAction ( ) const
inline

Definition at line 92 of file FCcmd.cxx.

92{ return m_action; }

◆ getItem()

const string & Options::getItem ( ) const
inline

Definition at line 93 of file FCcmd.cxx.

93{ return m_item; }

◆ getOptByName()

string Options::getOptByName ( char opt) const
inline

Definition at line 86 of file FCcmd.cxx.

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

◆ getProgName()

const string & Options::getProgName ( ) const
inline

Definition at line 91 of file FCcmd.cxx.

91{ return m_progName; }

◆ operator=()

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

Member Data Documentation

◆ m_action

string Options::m_action
private

Definition at line 46 of file FCcmd.cxx.

◆ m_argMap

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

Definition at line 45 of file FCcmd.cxx.

◆ m_item

string Options::m_item
private

Definition at line 47 of file FCcmd.cxx.

◆ m_progName

string Options::m_progName
private

Definition at line 48 of file FCcmd.cxx.


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