1 //===-- MICmdArgValBase.cpp -------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 //++ 11 // File: MICmdArgValBase.cpp 12 // 13 // Overview: CMICmdArgValBase implementation. 14 // 15 // Environment: Compilers: Visual C++ 12. 16 // gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1 17 // Libraries: See MIReadmetxt. 18 // 19 // Copyright: None. 20 //-- 21 22 // In-house headers: 23 #include "MICmdArgValBase.h" 24 #include "MIUtilString.h" 25 #include "MICmdArgContext.h" 26 27 //++ ------------------------------------------------------------------------------------ 28 // Details: CMICmdArgValBase constructor. 29 // Type: Method. 30 // Args: None. 31 // Return: None. 32 // Throws: None. 33 //-- 34 CMICmdArgValBase::CMICmdArgValBase( void ) 35 : m_bFound( false ) 36 , m_bValid( false ) 37 , m_bMandatory( false ) 38 , m_bHandled( false ) 39 , m_bIsMissingOptions( false ) 40 { 41 } 42 43 //++ ------------------------------------------------------------------------------------ 44 // Details: CMICmdArgValBase constructor. 45 // Type: Method. 46 // Args: vrArgName - (R) Argument's name to search by. 47 // vbMandatory - (R) True = Yes must be present, false = optional argument. 48 // vbHandleByCmd - (R) True = Command processes *this option, false = not handled. 49 // Return: None. 50 // Throws: None. 51 //-- 52 CMICmdArgValBase::CMICmdArgValBase( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd ) 53 : m_bFound( false ) 54 , m_bValid( false ) 55 , m_bMandatory( vbMandatory ) 56 , m_strArgName( vrArgName ) 57 , m_bHandled( vbHandleByCmd ) 58 , m_bIsMissingOptions( false ) 59 { 60 } 61 62 //++ ------------------------------------------------------------------------------------ 63 // Details: CMICmdArgValBase destructor. 64 // Type: Overrideable. 65 // Args: None. 66 // Return: None. 67 // Throws: None. 68 //-- 69 CMICmdArgValBase::~CMICmdArgValBase( void ) 70 { 71 } 72 73 //++ ------------------------------------------------------------------------------------ 74 // Details: Retrieve the state flag of whether the argument is handled by the command or 75 // not. 76 // Type: Method. 77 // Args: None. 78 // Return: True - Command needs more information. 79 // False - All information is present as expected. 80 // Throws: None. 81 //-- 82 bool CMICmdArgValBase::GetIsMissingOptions( void ) const 83 { 84 return m_bIsMissingOptions; 85 } 86 87 //++ ------------------------------------------------------------------------------------ 88 // Details: Retrieve the state flag of whether the argument is handled by the command or 89 // not. 90 // Type: Method. 91 // Args: None. 92 // Return: True - Command handles *this argument or option. 93 // False - Not handled (argument specified but ignored). 94 // Throws: None. 95 //-- 96 bool CMICmdArgValBase::GetIsHandledByCmd( void ) const 97 { 98 return m_bHandled; 99 } 100 101 //++ ------------------------------------------------------------------------------------ 102 // Details: Retrieve the name of *this argument. 103 // Type: Method. 104 // Args: None. 105 // Return: CMIUtilString & - Return the text name. 106 // Throws: None. 107 //-- 108 const CMIUtilString & CMICmdArgValBase::GetName( void ) const 109 { 110 return m_strArgName; 111 } 112 113 //++ ------------------------------------------------------------------------------------ 114 // Details: Retrieve the state flag of whether the argument was found in the command's 115 // argument / options string. 116 // Type: Method. 117 // Args: None. 118 // Return: True - Argument found. 119 // False - Argument not found. 120 // Throws: None. 121 //-- 122 bool CMICmdArgValBase::GetFound( void ) const 123 { 124 return m_bFound; 125 } 126 127 //++ ------------------------------------------------------------------------------------ 128 // Details: Retrieve the state flag indicating whether the value was obtained from the 129 // text arguments string and is valid. 130 // Type: Method. 131 // Args: None. 132 // Return: True - Argument valid. 133 // False - Argument not valid. 134 // Throws: None. 135 //-- 136 bool CMICmdArgValBase::GetValid( void ) const 137 { 138 return m_bValid; 139 } 140 141 //++ ------------------------------------------------------------------------------------ 142 // Details: Retrieve the state flag indicating whether *this argument is a mandatory 143 // argument for the command or is optional to be present. 144 // Type: Method. 145 // Args: None. 146 // Return: True - Mandatory. 147 // False - Optional. 148 // Throws: None. 149 //-- 150 bool CMICmdArgValBase::GetIsMandatory( void ) const 151 { 152 return m_bMandatory; 153 } 154 155 //++ ------------------------------------------------------------------------------------ 156 // Details: Parse the command's argument options string and try to extract the value *this 157 // argument is looking for. 158 // Type: Overrideable. 159 // Args: vArgContext - (RW) The command's argument options string. 160 // Return: MIstatus::success - Functional succeeded. 161 // MIstatus::failure - Functional failed. 162 // Throws: None. 163 //-- 164 bool CMICmdArgValBase::Validate( CMICmdArgContext & vwArgContext ) 165 { 166 MIunused( vwArgContext ); 167 168 // Override to implement 169 170 return MIstatus::failure; 171 }