1 //===-- OptionValueString.h --------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_OptionValueString_h_
11 #define liblldb_OptionValueString_h_
17 // Other libraries and framework includes
19 #include "lldb/Core/Flags.h"
20 #include "lldb/Interpreter/OptionValue.h"
22 namespace lldb_private {
24 class OptionValueString : public OptionValue
28 typedef Error (*ValidatorCallback) (const char* string,
33 eOptionEncodeCharacterEscapeSequences = (1u << 0)
36 OptionValueString () :
46 OptionValueString (ValidatorCallback validator,
52 m_validator(validator),
53 m_validator_baton(baton)
57 OptionValueString (const char *value) :
65 if (value && value[0])
67 m_current_value.assign (value);
68 m_default_value.assign (value);
72 OptionValueString (const char *current_value,
73 const char *default_value) :
81 if (current_value && current_value[0])
82 m_current_value.assign (current_value);
83 if (default_value && default_value[0])
84 m_default_value.assign (default_value);
87 OptionValueString (const char *value,
88 ValidatorCallback validator,
94 m_validator(validator),
95 m_validator_baton(baton)
97 if (value && value[0])
99 m_current_value.assign (value);
100 m_default_value.assign (value);
104 OptionValueString (const char *current_value,
105 const char *default_value,
106 ValidatorCallback validator,
107 void* baton = NULL) :
112 m_validator(validator),
113 m_validator_baton(baton)
115 if (current_value && current_value[0])
116 m_current_value.assign (current_value);
117 if (default_value && default_value[0])
118 m_default_value.assign (default_value);
126 //---------------------------------------------------------------------
127 // Virtual subclass pure virtual overrides
128 //---------------------------------------------------------------------
130 virtual OptionValue::Type
137 DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask);
140 SetValueFromCString (const char *value,
141 VarSetOperationType op = eVarSetOperationAssign);
146 m_current_value = m_default_value;
147 m_value_was_set = false;
151 virtual lldb::OptionValueSP
154 //---------------------------------------------------------------------
155 // Subclass specific functions
156 //---------------------------------------------------------------------
171 operator = (const char *value)
173 SetCurrentValue(value);
174 return m_current_value.c_str();
178 GetCurrentValue() const
180 return m_current_value.c_str();
184 GetDefaultValue() const
186 return m_default_value.c_str();
190 SetCurrentValue (const char *value);
193 AppendToCurrentValue (const char *value);
196 SetDefaultValue (const char *value)
198 if (value && value[0])
199 m_default_value.assign (value);
201 m_default_value.clear();
205 IsCurrentValueEmpty () const
207 return m_current_value.empty();
211 IsDefaultValueEmpty () const
213 return m_default_value.empty();
218 std::string m_current_value;
219 std::string m_default_value;
221 ValidatorCallback m_validator;
222 void* m_validator_baton;
225 } // namespace lldb_private
227 #endif // liblldb_OptionValueString_h_