OptionValueFormat.cpp revision 254721
1254721Semaste//===-- OptionValueFormat.cpp -----------------------------------*- C++ -*-===// 2254721Semaste// 3254721Semaste// The LLVM Compiler Infrastructure 4254721Semaste// 5254721Semaste// This file is distributed under the University of Illinois Open Source 6254721Semaste// License. See LICENSE.TXT for details. 7254721Semaste// 8254721Semaste//===----------------------------------------------------------------------===// 9254721Semaste 10254721Semaste#include "lldb/lldb-python.h" 11254721Semaste 12254721Semaste#include "lldb/Interpreter/OptionValueFormat.h" 13254721Semaste 14254721Semaste// C Includes 15254721Semaste// C++ Includes 16254721Semaste// Other libraries and framework includes 17254721Semaste// Project includes 18254721Semaste#include "lldb/Core/Stream.h" 19254721Semaste#include "lldb/DataFormatters/FormatManager.h" 20254721Semaste#include "lldb/Interpreter/Args.h" 21254721Semaste 22254721Semasteusing namespace lldb; 23254721Semasteusing namespace lldb_private; 24254721Semaste 25254721Semastevoid 26254721SemasteOptionValueFormat::DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) 27254721Semaste{ 28254721Semaste if (dump_mask & eDumpOptionType) 29254721Semaste strm.Printf ("(%s)", GetTypeAsCString ()); 30254721Semaste if (dump_mask & eDumpOptionValue) 31254721Semaste { 32254721Semaste if (dump_mask & eDumpOptionType) 33254721Semaste strm.PutCString (" = "); 34254721Semaste strm.PutCString (FormatManager::GetFormatAsCString (m_current_value)); 35254721Semaste } 36254721Semaste} 37254721Semaste 38254721SemasteError 39254721SemasteOptionValueFormat::SetValueFromCString (const char *value_cstr, VarSetOperationType op) 40254721Semaste{ 41254721Semaste Error error; 42254721Semaste switch (op) 43254721Semaste { 44254721Semaste case eVarSetOperationClear: 45254721Semaste Clear(); 46254721Semaste break; 47254721Semaste 48254721Semaste case eVarSetOperationReplace: 49254721Semaste case eVarSetOperationAssign: 50254721Semaste { 51254721Semaste Format new_format; 52254721Semaste error = Args::StringToFormat (value_cstr, new_format, NULL); 53254721Semaste if (error.Success()) 54254721Semaste { 55254721Semaste m_value_was_set = true; 56254721Semaste m_current_value = new_format; 57254721Semaste } 58254721Semaste } 59254721Semaste break; 60254721Semaste 61254721Semaste case eVarSetOperationInsertBefore: 62254721Semaste case eVarSetOperationInsertAfter: 63254721Semaste case eVarSetOperationRemove: 64254721Semaste case eVarSetOperationAppend: 65254721Semaste case eVarSetOperationInvalid: 66254721Semaste error = OptionValue::SetValueFromCString (value_cstr, op); 67254721Semaste break; 68254721Semaste } 69254721Semaste return error; 70254721Semaste} 71254721Semaste 72254721Semaste 73254721Semastelldb::OptionValueSP 74254721SemasteOptionValueFormat::DeepCopy () const 75254721Semaste{ 76254721Semaste return OptionValueSP(new OptionValueFormat(*this)); 77254721Semaste} 78254721Semaste 79