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