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 83 CMICmdArgValBase::GetIsMissingOptions(void) const 84 { 85 return m_bIsMissingOptions; 86 } 87 88 //++ ------------------------------------------------------------------------------------ 89 // Details: Retrieve the state flag of whether the argument is handled by the command or 90 // not. 91 // Type: Method. 92 // Args: None. 93 // Return: True - Command handles *this argument or option. 94 // False - Not handled (argument specified but ignored). 95 // Throws: None. 96 //-- 97 bool 98 CMICmdArgValBase::GetIsHandledByCmd(void) const 99 { 100 return m_bHandled; 101 } 102 103 //++ ------------------------------------------------------------------------------------ 104 // Details: Retrieve the name of *this argument. 105 // Type: Method. 106 // Args: None. 107 // Return: CMIUtilString & - Return the text name. 108 // Throws: None. 109 //-- 110 const CMIUtilString & 111 CMICmdArgValBase::GetName(void) const 112 { 113 return m_strArgName; 114 } 115 116 //++ ------------------------------------------------------------------------------------ 117 // Details: Retrieve the state flag of whether the argument was found in the command's 118 // argument / options string. 119 // Type: Method. 120 // Args: None. 121 // Return: True - Argument found. 122 // False - Argument not found. 123 // Throws: None. 124 //-- 125 bool 126 CMICmdArgValBase::GetFound(void) const 127 { 128 return m_bFound; 129 } 130 131 //++ ------------------------------------------------------------------------------------ 132 // Details: Retrieve the state flag indicating whether the value was obtained from the 133 // text arguments string and is valid. 134 // Type: Method. 135 // Args: None. 136 // Return: True - Argument valid. 137 // False - Argument not valid. 138 // Throws: None. 139 //-- 140 bool 141 CMICmdArgValBase::GetValid(void) const 142 { 143 return m_bValid; 144 } 145 146 //++ ------------------------------------------------------------------------------------ 147 // Details: Retrieve the state flag indicating whether *this argument is a mandatory 148 // argument for the command or is optional to be present. 149 // Type: Method. 150 // Args: None. 151 // Return: True - Mandatory. 152 // False - Optional. 153 // Throws: None. 154 //-- 155 bool 156 CMICmdArgValBase::GetIsMandatory(void) const 157 { 158 return m_bMandatory; 159 } 160 161 //++ ------------------------------------------------------------------------------------ 162 // Details: Parse the command's argument options string and try to extract the value *this 163 // argument is looking for. 164 // Type: Overrideable. 165 // Args: vArgContext - (RW) The command's argument options string. 166 // Return: MIstatus::success - Functional succeeded. 167 // MIstatus::failure - Functional failed. 168 // Throws: None. 169 //-- 170 bool 171 CMICmdArgValBase::Validate(CMICmdArgContext &vwArgContext) 172 { 173 MIunused(vwArgContext); 174 175 // Override to implement 176 177 return MIstatus::failure; 178 } 179