1 //===-- MICmdArgValBase.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 //===----------------------------------------------------------------------===//
12 // Other libraries and framework includes
14 #include "MICmdArgValBase.h"
15 #include "MICmdArgContext.h"
16 #include "MIUtilString.h"
19 //------------------------------------------------------------------------------------
20 // Details: CMICmdArgValBase constructor.
26 CMICmdArgValBase::CMICmdArgValBase()
27 : m_bFound(false), m_bValid(false), m_bMandatory(false), m_bHandled(false),
28 m_bIsMissingOptions(false) {}
31 //------------------------------------------------------------------------------------
32 // Details: CMICmdArgValBase constructor.
34 // Args: vrArgName - (R) Argument's name to search by.
35 // vbMandatory - (R) True = Yes must be present, false = optional
37 // vbHandleByCmd - (R) True = Command processes *this option, false =
42 CMICmdArgValBase::CMICmdArgValBase(const CMIUtilString &vrArgName,
43 const bool vbMandatory,
44 const bool vbHandleByCmd)
45 : m_bFound(false), m_bValid(false), m_bMandatory(vbMandatory),
46 m_strArgName(vrArgName), m_bHandled(vbHandleByCmd),
47 m_bIsMissingOptions(false) {}
50 //------------------------------------------------------------------------------------
51 // Details: Retrieve the state flag of whether the argument is handled by the
56 // Return: True - Command needs more information.
57 // False - All information is present as expected.
60 bool CMICmdArgValBase::GetIsMissingOptions() const {
61 return m_bIsMissingOptions;
65 //------------------------------------------------------------------------------------
66 // Details: Retrieve the state flag of whether the argument is handled by the
71 // Return: True - Command handles *this argument or option.
72 // False - Not handled (argument specified but ignored).
75 bool CMICmdArgValBase::GetIsHandledByCmd() const { return m_bHandled; }
78 //------------------------------------------------------------------------------------
79 // Details: Retrieve the name of *this argument.
82 // Return: CMIUtilString & - Return the text name.
85 const CMIUtilString &CMICmdArgValBase::GetName() const { return m_strArgName; }
88 //------------------------------------------------------------------------------------
89 // Details: Retrieve the state flag of whether the argument was found in the
91 // argument / options string.
94 // Return: True - Argument found.
95 // False - Argument not found.
98 bool CMICmdArgValBase::GetFound() const { return m_bFound; }
101 //------------------------------------------------------------------------------------
102 // Details: Retrieve the state flag indicating whether the value was obtained
104 // text arguments string and is valid.
107 // Return: True - Argument valid.
108 // False - Argument not valid.
111 bool CMICmdArgValBase::GetValid() const { return m_bValid; }
114 //------------------------------------------------------------------------------------
115 // Details: Retrieve the state flag indicating whether *this argument is a
117 // argument for the command or is optional to be present.
120 // Return: True - Mandatory.
124 bool CMICmdArgValBase::GetIsMandatory() const { return m_bMandatory; }
127 //------------------------------------------------------------------------------------
128 // Details: Parse the command's argument options string and try to extract the
130 // argument is looking for.
131 // Type: Overrideable.
132 // Args: vArgContext - (RW) The command's argument options string.
133 // Return: MIstatus::success - Functional succeeded.
134 // MIstatus::failure - Functional failed.
137 bool CMICmdArgValBase::Validate(CMICmdArgContext &vwArgContext) {
138 MIunused(vwArgContext);
140 // Override to implement
142 return MIstatus::failure;