1 //===-- MICmdArgValOptionShort.cpp ------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 // File: MICmdArgValOptionShort.cpp
13 // Overview: CMICmdArgValOptionShort implementation.
15 // Environment: Compilers: Visual C++ 12.
16 // gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
17 // Libraries: See MIReadmetxt.
23 #include "MICmdArgValOptionShort.h"
24 #include "MICmdArgContext.h"
26 //++ ------------------------------------------------------------------------------------
27 // Details: CMICmdArgValOptionShort constructor.
33 CMICmdArgValOptionShort::CMICmdArgValOptionShort( void )
37 //++ ------------------------------------------------------------------------------------
38 // Details: CMICmdArgValOptionShort constructor.
40 // Args: vrArgName - (R) Argument's name to search by.
41 // vbMandatory - (R) True = Yes must be present, false = optional argument.
42 // vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
46 CMICmdArgValOptionShort::CMICmdArgValOptionShort( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd )
47 : CMICmdArgValOptionLong( vrArgName, vbMandatory, vbHandleByCmd )
51 //++ ------------------------------------------------------------------------------------
52 // Details: CMICmdArgValOptionLong constructor.
54 // Args: vrArgName - (R) Argument's name to search by.
55 // vbMandatory - (R) True = Yes must be present, false = optional argument.
56 // vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
57 // veType - (R) The type of argument to look for and create argument object of a certain type.
58 // vnExpectingNOptions - (R) The number of options expected to read following *this argument.
62 CMICmdArgValOptionShort::CMICmdArgValOptionShort( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd, const ArgValType_e veType, const MIuint vnExpectingNOptions )
63 : CMICmdArgValOptionLong( vrArgName, vbMandatory, vbHandleByCmd, veType, vnExpectingNOptions )
67 //++ ------------------------------------------------------------------------------------
68 // Details: CMICmdArgValOptionShort destructor.
74 CMICmdArgValOptionShort::~CMICmdArgValOptionShort( void )
78 //++ ------------------------------------------------------------------------------------
79 // Details: Examine the string and determine if it is a valid short type option argument.
81 // Args: vrTxt - (R) Some text.
82 // Return: bool - True = yes valid arg, false = no.
85 bool CMICmdArgValOptionShort::IsArgShortOption( const CMIUtilString & vrTxt ) const
87 // Look for --someLongOption
88 MIint nPos = vrTxt.find( "--" );
92 // Look for -f short option
93 nPos = vrTxt.find( "-" );
97 if( vrTxt.length() > 2 )
103 //++ ------------------------------------------------------------------------------------
104 // Details: Examine the string and determine if it is a valid short type option argument.
105 // Long type argument looks like -f some short option.
107 // Args: vrTxt - (R) Some text.
108 // Return: bool - True = yes valid arg, false = no.
111 bool CMICmdArgValOptionShort::IsArgOptionCorrect( const CMIUtilString & vrTxt ) const
113 return IsArgShortOption( vrTxt );
116 //++ ------------------------------------------------------------------------------------
117 // Details: Does the argument name of the argument being parsed ATM match the name of
118 // *this argument object.
120 // Args: vrTxt - (R) Some text.
121 // Return: bool - True = yes arg name matched, false = no.
124 bool CMICmdArgValOptionShort::ArgNameMatch( const CMIUtilString & vrTxt ) const
126 const CMIUtilString strArg = vrTxt.substr( 1 ).c_str();
127 return (strArg == GetName() );