1 //===-- MICmdArgValBase.cpp -------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "MICmdArgValBase.h"
10 #include "MICmdArgContext.h"
11 #include "MIUtilString.h"
14 // Details: CMICmdArgValBase constructor.
20 CMICmdArgValBase::CMICmdArgValBase()
21 : m_bFound(false), m_bValid(false), m_bMandatory(false), m_bHandled(false),
22 m_bIsMissingOptions(false) {}
25 // Details: CMICmdArgValBase constructor.
27 // Args: vrArgName - (R) Argument's name to search by.
28 // vbMandatory - (R) True = Yes must be present, false = optional
30 // vbHandleByCmd - (R) True = Command processes *this option, false =
35 CMICmdArgValBase::CMICmdArgValBase(const CMIUtilString &vrArgName,
36 const bool vbMandatory,
37 const bool vbHandleByCmd)
38 : m_bFound(false), m_bValid(false), m_bMandatory(vbMandatory),
39 m_strArgName(vrArgName), m_bHandled(vbHandleByCmd),
40 m_bIsMissingOptions(false) {}
43 // Details: Retrieve the state flag of whether the argument is handled by the
48 // Return: True - Command needs more information.
49 // False - All information is present as expected.
52 bool CMICmdArgValBase::GetIsMissingOptions() const {
53 return m_bIsMissingOptions;
57 // Details: Retrieve the state flag of whether the argument is handled by the
62 // Return: True - Command handles *this argument or option.
63 // False - Not handled (argument specified but ignored).
66 bool CMICmdArgValBase::GetIsHandledByCmd() const { return m_bHandled; }
69 // Details: Retrieve the name of *this argument.
72 // Return: CMIUtilString & - Return the text name.
75 const CMIUtilString &CMICmdArgValBase::GetName() const { return m_strArgName; }
78 // Details: Retrieve the state flag of whether the argument was found in the
80 // argument / options string.
83 // Return: True - Argument found.
84 // False - Argument not found.
87 bool CMICmdArgValBase::GetFound() const { return m_bFound; }
90 // Details: Retrieve the state flag indicating whether the value was obtained
92 // text arguments string and is valid.
95 // Return: True - Argument valid.
96 // False - Argument not valid.
99 bool CMICmdArgValBase::GetValid() const { return m_bValid; }
102 // Details: Retrieve the state flag indicating whether *this argument is a
104 // argument for the command or is optional to be present.
107 // Return: True - Mandatory.
111 bool CMICmdArgValBase::GetIsMandatory() const { return m_bMandatory; }
114 // Details: Parse the command's argument options string and try to extract the
116 // argument is looking for.
117 // Type: Overrideable.
118 // Args: vArgContext - (RW) The command's argument options string.
119 // Return: MIstatus::success - Functional succeeded.
120 // MIstatus::failure - Functional failed.
123 bool CMICmdArgValBase::Validate(CMICmdArgContext &vwArgContext) {
124 MIunused(vwArgContext);
126 // Override to implement
128 return MIstatus::failure;