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 33 of file FCcmd.cxx.

Constructor & Destructor Documentation

◆ Options() [1/2]

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

Definition at line 55 of file FCcmd.cxx.

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

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

◆ getAction()

const string & Options::getAction ( ) const
inline

Definition at line 91 of file FCcmd.cxx.

91{ return m_action; }

◆ getItem()

const string & Options::getItem ( ) const
inline

Definition at line 92 of file FCcmd.cxx.

92{ return m_item; }

◆ getOptByName()

string Options::getOptByName ( char opt) const
inline

Definition at line 85 of file FCcmd.cxx.

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

◆ getProgName()

const string & Options::getProgName ( ) const
inline

Definition at line 90 of file FCcmd.cxx.

90{ return m_progName; }

◆ operator=()

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

Member Data Documentation

◆ m_action

string Options::m_action
private

Definition at line 45 of file FCcmd.cxx.

◆ m_argMap

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

Definition at line 44 of file FCcmd.cxx.

◆ m_item

string Options::m_item
private

Definition at line 46 of file FCcmd.cxx.

◆ m_progName

string Options::m_progName
private

Definition at line 47 of file FCcmd.cxx.


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