]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/tools/lldb-mi/MICmdArgValBase.h
Add ELF Tool Chain's brandelf(1) to contrib
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / tools / lldb-mi / MICmdArgValBase.h
1 //===-- Platform.h ----------------------------------------------*- 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.h
12 //
13 // Overview:    CMICmdArgValBase interface.
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 #pragma once
23
24 // In-house headers:
25 #include "MIUtilString.h"
26 #include "MICmdArgSet.h"
27
28 //++ ============================================================================
29 // Details: MI common code class. Command argument base class. Arguments objects
30 //          needing specialization derived from *this class. An argument knows
31 //          what type of argument it is and how it is to interpret the options
32 //          (context) string to find and validate a matching argument and so
33 //          extract a value from it.
34 //          Argument objects are added to the CMICmdArgSet container object.
35 //          Once added the container they belong to that contain and will be
36 //          deleted when the container goes out of scope. Allocate argument
37 //          objects on the heap and pass in to the Add().
38 //          Note the code is written such that a command will produce an error
39 //          should it be presented with arguments or options it does not understand.
40 //          A command can recognise an option or argument then ignore if it
41 //          wishes (a warning is sent to the MI's Log file). This is so it is
42 //          hardwired to fail and catch arguments or options that presented by
43 //          different driver clients.
44 //          Based on the Interpreter pattern.
45 // Gotchas: None.
46 // Authors: Illya Rudkin 14/04/2014.
47 // Changes: None.
48 //--
49 class CMICmdArgValBase : public CMICmdArgSet::IArg
50 {
51     // Methods:
52   public:
53     /* ctor */ CMICmdArgValBase(void);
54     /* ctor */ CMICmdArgValBase(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
55
56     // Overrideable:
57   public:
58     /* dtor */ virtual ~CMICmdArgValBase(void);
59
60     // Overridden:
61   public:
62     // From CMICmdArgSet::IArg
63     virtual bool GetFound(void) const;
64     virtual bool GetIsHandledByCmd(void) const;
65     virtual bool GetIsMandatory(void) const;
66     virtual bool GetIsMissingOptions(void) const;
67     virtual const CMIUtilString &GetName(void) const;
68     virtual bool GetValid(void) const;
69     virtual bool Validate(CMICmdArgContext &vwArgContext);
70
71     // Attributes:
72   protected:
73     bool m_bFound;     // True = yes found in arguments options text, false = not found
74     bool m_bValid;     // True = yes argument parsed and valid, false = not valid
75     bool m_bMandatory; // True = yes arg must be present, false = optional argument
76     CMIUtilString m_strArgName;
77     bool m_bHandled;          // True = Command processes *this option, false = not handled
78     bool m_bIsMissingOptions; // True = Command needs more information, false = ok
79 };
80
81 //++ ============================================================================
82 // Details: MI common code class. Templated command argument base class.
83 // Gotchas: None.
84 // Authors: Illya Rudkin 14/04/2014.
85 // Changes: None.
86 //--
87 template <class T> class CMICmdArgValBaseTemplate : public CMICmdArgValBase
88 {
89     // Methods:
90   public:
91     /* ctor */ CMICmdArgValBaseTemplate(void);
92     /* ctor */ CMICmdArgValBaseTemplate(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
93     //
94     const T &GetValue(void) const;
95
96     // Overrideable:
97   public:
98     /* dtor */ virtual ~CMICmdArgValBaseTemplate(void);
99
100     // Attributes:
101   protected:
102     T m_argValue;
103 };
104
105 //++ ------------------------------------------------------------------------------------
106 // Details: CMICmdArgValBaseTemplate constructor.
107 // Type:    Method.
108 // Args:    None.
109 // Return:  None.
110 // Throws:  None.
111 //--
112 template <class T> CMICmdArgValBaseTemplate<T>::CMICmdArgValBaseTemplate(void)
113 {
114 }
115
116 //++ ------------------------------------------------------------------------------------
117 // Details: CMICmdArgValBaseTemplate constructor.
118 // Type:    Method.
119 // Args:    vrArgName       - (R) Argument's name to search by.
120 //          vbMandatory     - (R) True = Yes must be present, false = optional argument.
121 //          vbHandleByCmd   - (R) True = Command processes *this option, false = not handled.
122 // Return:  None.
123 // Throws:  None.
124 //--
125 template <class T>
126 CMICmdArgValBaseTemplate<T>::CMICmdArgValBaseTemplate(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd)
127     : CMICmdArgValBase(vrArgName, vbMandatory, vbHandleByCmd)
128 {
129 }
130
131 //++ ------------------------------------------------------------------------------------
132 // Details: CMICmdArgValBaseTemplate destructor.
133 // Type:    Overrideable.
134 // Args:    None.
135 // Return:  None.
136 // Throws:  None.
137 //--
138 template <class T> CMICmdArgValBaseTemplate<T>::~CMICmdArgValBaseTemplate(void)
139 {
140 }
141
142 //++ ------------------------------------------------------------------------------------
143 // Details: Retrieve the value the argument parsed from the command's argument / options
144 //          text string.
145 // Type:    Method.
146 // Args:    None.
147 // Return:  Template type & - The arg value of *this object.
148 // Throws:  None.
149 //--
150 template <class T>
151 const T &
152 CMICmdArgValBaseTemplate<T>::GetValue(void) const
153 {
154     return m_argValue;
155 }