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"
14 // Other libraries and framework includes
16 #include "lldb/DataFormatters/FormatManager.h"
17 #include "lldb/Interpreter/Args.h"
18 #include "lldb/Utility/Stream.h"
21 using namespace lldb_private;
23 void OptionValueFormat::DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
25 if (dump_mask & eDumpOptionType)
26 strm.Printf("(%s)", GetTypeAsCString());
27 if (dump_mask & eDumpOptionValue) {
28 if (dump_mask & eDumpOptionType)
29 strm.PutCString(" = ");
30 strm.PutCString(FormatManager::GetFormatAsCString(m_current_value));
34 Status OptionValueFormat::SetValueFromString(llvm::StringRef value,
35 VarSetOperationType op) {
38 case eVarSetOperationClear:
43 case eVarSetOperationReplace:
44 case eVarSetOperationAssign: {
46 error = Args::StringToFormat(value.str().c_str(), new_format, nullptr);
47 if (error.Success()) {
48 m_value_was_set = true;
49 m_current_value = new_format;
54 case eVarSetOperationInsertBefore:
55 case eVarSetOperationInsertAfter:
56 case eVarSetOperationRemove:
57 case eVarSetOperationAppend:
58 case eVarSetOperationInvalid:
59 error = OptionValue::SetValueFromString(value, op);
65 lldb::OptionValueSP OptionValueFormat::DeepCopy() const {
66 return OptionValueSP(new OptionValueFormat(*this));