]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/tools/lldb-mi/MICmdArgValBase.h
Merge OpenSSL 1.0.1k.
[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 >
88 class CMICmdArgValBaseTemplate : public CMICmdArgValBase
89 {
90 // Methods:
91 public:
92         /* ctor */      CMICmdArgValBaseTemplate( void );
93         /* ctor */      CMICmdArgValBaseTemplate( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd );
94         //
95         const T &       GetValue( void ) const;
96
97 // Overrideable:
98 public:
99         /* dtor */ virtual ~CMICmdArgValBaseTemplate( void );
100
101 // Attributes:
102 protected:
103         T       m_argValue;
104 };
105
106 //++ ------------------------------------------------------------------------------------
107 // Details:     CMICmdArgValBaseTemplate constructor.
108 // Type:        Method.
109 // Args:        None.
110 // Return:      None.
111 // Throws:      None.
112 //--
113 template< class T >
114 CMICmdArgValBaseTemplate< T >::CMICmdArgValBaseTemplate( void )
115 {
116 }
117
118 //++ ------------------------------------------------------------------------------------
119 // Details:     CMICmdArgValBaseTemplate constructor.
120 // Type:        Method.
121 // Args:        vrArgName               - (R) Argument's name to search by.
122 //                      vbMandatory             - (R) True = Yes must be present, false = optional argument.
123 //                      vbHandleByCmd   - (R) True = Command processes *this option, false = not handled.
124 // Return:      None.
125 // Throws:      None.
126 //--
127 template< class T >
128 CMICmdArgValBaseTemplate< T >::CMICmdArgValBaseTemplate( const CMIUtilString & vrArgName, const bool vbMandatory, const bool vbHandleByCmd )
129 :       CMICmdArgValBase( vrArgName, vbMandatory, vbHandleByCmd )
130 {
131 }
132
133 //++ ------------------------------------------------------------------------------------
134 // Details:     CMICmdArgValBaseTemplate destructor.
135 // Type:        Overrideable.
136 // Args:        None.
137 // Return:      None.
138 // Throws:      None.
139 //--
140 template< class T >
141 CMICmdArgValBaseTemplate< T >::~CMICmdArgValBaseTemplate( void )
142 {
143 }
144
145 //++ ------------------------------------------------------------------------------------
146 // Details:     Retrieve the value the argument parsed from the command's argument / options
147 //                      text string.
148 // Type:        Method.
149 // Args:        None.
150 // Return:      Template type & - The arg value of *this object.
151 // Throws:      None.
152 //--
153 template< class T >
154 const T & CMICmdArgValBaseTemplate< T >::GetValue( void ) const
155 {
156         return m_argValue;
157 }