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 #include "MICmdArgValBase.h"
11 #include "MICmdArgContext.h"
12 #include "MIUtilString.h"
13 
14 //++
15 //------------------------------------------------------------------------------------
16 // Details: CMICmdArgValBase constructor.
17 // Type:    Method.
18 // Args:    None.
19 // Return:  None.
20 // Throws:  None.
21 //--
22 CMICmdArgValBase::CMICmdArgValBase()
23     : m_bFound(false), m_bValid(false), m_bMandatory(false), m_bHandled(false),
24       m_bIsMissingOptions(false) {}
25 
26 //++
27 //------------------------------------------------------------------------------------
28 // Details: CMICmdArgValBase constructor.
29 // Type:    Method.
30 // Args:    vrArgName       - (R) Argument's name to search by.
31 //          vbMandatory     - (R) True = Yes must be present, false = optional
32 //          argument.
33 //          vbHandleByCmd   - (R) True = Command processes *this option, false =
34 //          not handled.
35 // Return:  None.
36 // Throws:  None.
37 //--
38 CMICmdArgValBase::CMICmdArgValBase(const CMIUtilString &vrArgName,
39                                    const bool vbMandatory,
40                                    const bool vbHandleByCmd)
41     : m_bFound(false), m_bValid(false), m_bMandatory(vbMandatory),
42       m_strArgName(vrArgName), m_bHandled(vbHandleByCmd),
43       m_bIsMissingOptions(false) {}
44 
45 //++
46 //------------------------------------------------------------------------------------
47 // Details: Retrieve the state flag of whether the argument is handled by the
48 // command or
49 //          not.
50 // Type:    Method.
51 // Args:    None.
52 // Return:  True - Command needs more information.
53 //          False - All information is present as expected.
54 // Throws:  None.
55 //--
56 bool CMICmdArgValBase::GetIsMissingOptions() const {
57   return m_bIsMissingOptions;
58 }
59 
60 //++
61 //------------------------------------------------------------------------------------
62 // Details: Retrieve the state flag of whether the argument is handled by the
63 // command or
64 //          not.
65 // Type:    Method.
66 // Args:    None.
67 // Return:  True - Command handles *this argument or option.
68 //          False - Not handled (argument specified but ignored).
69 // Throws:  None.
70 //--
71 bool CMICmdArgValBase::GetIsHandledByCmd() const { return m_bHandled; }
72 
73 //++
74 //------------------------------------------------------------------------------------
75 // Details: Retrieve the name of *this argument.
76 // Type:    Method.
77 // Args:    None.
78 // Return:  CMIUtilString & - Return the text name.
79 // Throws:  None.
80 //--
81 const CMIUtilString &CMICmdArgValBase::GetName() const { return m_strArgName; }
82 
83 //++
84 //------------------------------------------------------------------------------------
85 // Details: Retrieve the state flag of whether the argument was found in the
86 // command's
87 //          argument / options string.
88 // Type:    Method.
89 // Args:    None.
90 // Return:  True - Argument found.
91 //          False - Argument not found.
92 // Throws:  None.
93 //--
94 bool CMICmdArgValBase::GetFound() const { return m_bFound; }
95 
96 //++
97 //------------------------------------------------------------------------------------
98 // Details: Retrieve the state flag indicating whether the value was obtained
99 // from the
100 //          text arguments string and is valid.
101 // Type:    Method.
102 // Args:    None.
103 // Return:  True - Argument valid.
104 //          False - Argument not valid.
105 // Throws:  None.
106 //--
107 bool CMICmdArgValBase::GetValid() const { return m_bValid; }
108 
109 //++
110 //------------------------------------------------------------------------------------
111 // Details: Retrieve the state flag indicating whether *this argument is a
112 // mandatory
113 //          argument for the command or is optional to be present.
114 // Type:    Method.
115 // Args:    None.
116 // Return:  True - Mandatory.
117 //          False - Optional.
118 // Throws:  None.
119 //--
120 bool CMICmdArgValBase::GetIsMandatory() const { return m_bMandatory; }
121 
122 //++
123 //------------------------------------------------------------------------------------
124 // Details: Parse the command's argument options string and try to extract the
125 // value *this
126 //          argument is looking for.
127 // Type:    Overrideable.
128 // Args:    vArgContext - (RW) The command's argument options string.
129 // Return:  MIstatus::success - Functional succeeded.
130 //          MIstatus::failure - Functional failed.
131 // Throws:  None.
132 //--
133 bool CMICmdArgValBase::Validate(CMICmdArgContext &vwArgContext) {
134   MIunused(vwArgContext);
135 
136   // Override to implement
137 
138   return MIstatus::failure;
139 }
140