1 //===-- OptionValueFormat.cpp -----------------------------------*- 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 #include "lldb/Interpreter/OptionValueFormat.h" 11 12 // C Includes 13 // C++ Includes 14 // Other libraries and framework includes 15 // Project includes 16 #include "lldb/Core/FormatManager.h" 17 #include "lldb/Core/Stream.h" 18 #include "lldb/Interpreter/Args.h" 19 20 using namespace lldb; 21 using namespace lldb_private; 22 23 void 24 OptionValueFormat::DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) 25 { 26 if (dump_mask & eDumpOptionType) 27 strm.Printf ("(%s)", GetTypeAsCString ()); 28 if (dump_mask & eDumpOptionValue) 29 { 30 if (dump_mask & eDumpOptionType) 31 strm.PutCString (" = "); 32 strm.PutCString (FormatManager::GetFormatAsCString (m_current_value)); 33 } 34 } 35 36 Error 37 OptionValueFormat::SetValueFromCString (const char *value_cstr, VarSetOperationType op) 38 { 39 Error error; 40 switch (op) 41 { 42 case eVarSetOperationClear: 43 Clear(); 44 break; 45 46 case eVarSetOperationReplace: 47 case eVarSetOperationAssign: 48 { 49 Format new_format; 50 error = Args::StringToFormat (value_cstr, new_format, NULL); 51 if (error.Success()) 52 { 53 m_value_was_set = true; 54 m_current_value = new_format; 55 } 56 } 57 break; 58 59 case eVarSetOperationInsertBefore: 60 case eVarSetOperationInsertAfter: 61 case eVarSetOperationRemove: 62 case eVarSetOperationAppend: 63 case eVarSetOperationInvalid: 64 error = OptionValue::SetValueFromCString (value_cstr, op); 65 break; 66 } 67 return error; 68 } 69 70 71 lldb::OptionValueSP 72 OptionValueFormat::DeepCopy () const 73 { 74 return OptionValueSP(new OptionValueFormat(*this)); 75 } 76 77