]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/llvm/tools/lldb/include/lldb/Interpreter/OptionValueEnumeration.h
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / llvm / tools / lldb / include / lldb / Interpreter / OptionValueEnumeration.h
1 //===-- OptionValueEnumeration.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 #ifndef liblldb_OptionValueEnumeration_h_
11 #define liblldb_OptionValueEnumeration_h_
12
13 // C Includes
14 // C++ Includes
15 // Other libraries and framework includes
16 // Project includes
17 #include "lldb/Core/ConstString.h"
18 #include "lldb/Core/Error.h"
19 #include "lldb/Core/Stream.h"
20 #include "lldb/Core/StreamString.h"
21 #include "lldb/Core/UniqueCStringMap.h"
22 #include "lldb/Interpreter/OptionValue.h"
23
24 namespace lldb_private {
25
26
27 class OptionValueEnumeration : public OptionValue
28 {
29 public:
30     typedef int64_t enum_type;
31     struct EnumeratorInfo
32     {
33         enum_type value;
34         const char *description;
35     };
36     typedef UniqueCStringMap<EnumeratorInfo> EnumerationMap;
37     typedef EnumerationMap::Entry EnumerationMapEntry;
38
39     OptionValueEnumeration (const OptionEnumValueElement *enumerators, enum_type value);
40     
41     virtual
42     ~OptionValueEnumeration();
43     
44     //---------------------------------------------------------------------
45     // Virtual subclass pure virtual overrides
46     //---------------------------------------------------------------------
47     
48     virtual OptionValue::Type
49     GetType () const
50     {
51         return eTypeEnum;
52     }
53     
54     virtual void
55     DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask);
56     
57     virtual Error
58     SetValueFromCString (const char *value,
59                          VarSetOperationType op = eVarSetOperationAssign);
60     
61     virtual bool
62     Clear ()
63     {
64         m_current_value = m_default_value;
65         m_value_was_set = false;
66         return true;
67     }
68     
69     virtual lldb::OptionValueSP
70     DeepCopy () const;
71     
72     virtual size_t
73     AutoComplete (CommandInterpreter &interpreter,
74                   const char *s,
75                   int match_start_point,
76                   int max_return_elements,
77                   bool &word_complete,
78                   StringList &matches);
79
80     //---------------------------------------------------------------------
81     // Subclass specific functions
82     //---------------------------------------------------------------------
83     
84     enum_type
85     operator = (enum_type value)
86     {
87         m_current_value = value;
88         return m_current_value;
89     }
90     
91     enum_type
92     GetCurrentValue() const
93     {
94         return m_current_value;
95     }
96     
97     enum_type
98     GetDefaultValue() const
99     {
100         return m_default_value;
101     }
102     
103     void
104     SetCurrentValue (enum_type value)
105     {
106         m_current_value = value;
107     }
108     
109     void
110     SetDefaultValue (enum_type value)
111     {
112         m_default_value = value;
113     }
114     
115 protected:
116     void
117     SetEnumerations (const OptionEnumValueElement *enumerators);
118
119     enum_type m_current_value;
120     enum_type m_default_value;
121     EnumerationMap m_enumerations;
122 };
123
124 } // namespace lldb_private
125
126 #endif  // liblldb_OptionValueEnumeration_h_