1 //===-- OptionValueFormat.cpp -----------------------------------*- 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 #include "lldb/Interpreter/OptionValueFormat.h"
12 #include "lldb/DataFormatters/FormatManager.h"
13 #include "lldb/Interpreter/OptionArgParser.h"
14 #include "lldb/Utility/Stream.h"
17 using namespace lldb_private;
19 void OptionValueFormat::DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
21 if (dump_mask & eDumpOptionType)
22 strm.Printf("(%s)", GetTypeAsCString());
23 if (dump_mask & eDumpOptionValue) {
24 if (dump_mask & eDumpOptionType)
25 strm.PutCString(" = ");
26 strm.PutCString(FormatManager::GetFormatAsCString(m_current_value));
30 Status OptionValueFormat::SetValueFromString(llvm::StringRef value,
31 VarSetOperationType op) {
34 case eVarSetOperationClear:
39 case eVarSetOperationReplace:
40 case eVarSetOperationAssign: {
42 error = OptionArgParser::ToFormat(value.str().c_str(), new_format, nullptr);
43 if (error.Success()) {
44 m_value_was_set = true;
45 m_current_value = new_format;
50 case eVarSetOperationInsertBefore:
51 case eVarSetOperationInsertAfter:
52 case eVarSetOperationRemove:
53 case eVarSetOperationAppend:
54 case eVarSetOperationInvalid:
55 error = OptionValue::SetValueFromString(value, op);
61 lldb::OptionValueSP OptionValueFormat::DeepCopy() const {
62 return OptionValueSP(new OptionValueFormat(*this));