]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/tools/lldb-mi/MICmnMIValueResult.cpp
Update llvm, clang and lldb to 3.7.0 release.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / tools / lldb-mi / MICmnMIValueResult.cpp
1 //===-- Platform.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 // In-house headers:
11 #include "MICmnMIValueResult.h"
12 #include "MICmnResources.h"
13
14 // Instantiations:
15 const CMIUtilString CMICmnMIValueResult::ms_constStrEqual("=");
16
17 //++ ------------------------------------------------------------------------------------
18 // Details: CMICmnMIValueResult constructor.
19 // Type:    Method.
20 // Args:    None.
21 // Return:  None.
22 // Throws:  None.
23 //--
24 CMICmnMIValueResult::CMICmnMIValueResult(void)
25     : m_bEmptyConstruction(true)
26 {
27 }
28
29 //++ ------------------------------------------------------------------------------------
30 // Details: CMICmnMIValueResult constructor.
31 // Type:    Method.
32 // Args:    vrVariable  - (R) MI value's name.
33 //          vrValue     - (R) The MI value.
34 // Return:  None.
35 // Throws:  None.
36 //--
37 CMICmnMIValueResult::CMICmnMIValueResult(const CMIUtilString &vrVariable, const CMICmnMIValue &vrValue)
38     : m_strPartVariable(vrVariable)
39     , m_partMIValue(vrValue)
40     , m_bEmptyConstruction(false)
41     , m_bUseSpacing(false)
42 {
43     BuildResult();
44 }
45
46 //++ ------------------------------------------------------------------------------------
47 // Details: CMICmnMIValueResult constructor.
48 // Type:    Method.
49 // Args:    vrVariable      - (R) MI value's name.
50 //          vrValue         - (R) The MI value.
51 //          vbUseSpacing    - (R) True = put space separators into the string, false = no spaces used.
52 // Return:  None.
53 // Throws:  None.
54 //--
55 CMICmnMIValueResult::CMICmnMIValueResult(const CMIUtilString &vrVariable, const CMICmnMIValue &vrValue, const bool vbUseSpacing)
56     : m_strPartVariable(vrVariable)
57     , m_partMIValue(vrValue)
58     , m_bEmptyConstruction(false)
59     , m_bUseSpacing(vbUseSpacing)
60 {
61     BuildResult();
62 }
63
64 //++ ------------------------------------------------------------------------------------
65 // Details: CMICmnMIValueResult destructor.
66 // Type:    Overrideable.
67 // Args:    None.
68 // Return:  None.
69 // Throws:  None.
70 //--
71 CMICmnMIValueResult::~CMICmnMIValueResult(void)
72 {
73 }
74
75 //++ ------------------------------------------------------------------------------------
76 // Details: Build the MI value result string.
77 // Type:    Method.
78 // Args:    None.
79 // Return:  MIstatus::success - Functional succeeded.
80 //          MIstatus::failure - Functional failed.
81 // Throws:  None.
82 //--
83 bool
84 CMICmnMIValueResult::BuildResult(void)
85 {
86     const char *pFormat = m_bUseSpacing ? "%s %s %s" : "%s%s%s";
87     m_strValue = CMIUtilString::Format(pFormat, m_strPartVariable.c_str(), ms_constStrEqual.c_str(), m_partMIValue.GetString().c_str());
88
89     return MIstatus::success;
90 }
91
92 //++ ------------------------------------------------------------------------------------
93 // Details: Build the MI value result string.
94 // Type:    Method.
95 // Args:    vrVariable  - (R) MI value's name.
96 //          vrValue     - (R) The MI value.
97 // Return:  MIstatus::success - Functional succeeded.
98 //          MIstatus::failure - Functional failed.
99 // Throws:  None.
100 //--
101 bool
102 CMICmnMIValueResult::BuildResult(const CMIUtilString &vVariable, const CMICmnMIValue &vValue)
103 {
104     const char *pFormat = m_bUseSpacing ? "%s, %s %s %s" : "%s,%s%s%s";
105     m_strValue =
106         CMIUtilString::Format(pFormat, m_strValue.c_str(), vVariable.c_str(), ms_constStrEqual.c_str(), vValue.GetString().c_str());
107
108     return MIstatus::success;
109 }
110
111 //++ ------------------------------------------------------------------------------------
112 // Details: Append another MI value object to *this MI value result.
113 // Type:    Method.
114 // Args:    vrVariable  - (R) MI value's name.
115 //          vrValue     - (R) The MI value.
116 // Return:  MIstatus::success - Functional succeeded.
117 //          MIstatus::failure - Functional failed.
118 // Throws:  None.
119 //--
120 bool
121 CMICmnMIValueResult::Add(const CMIUtilString &vrVariable, const CMICmnMIValue &vrValue)
122 {
123     if (!m_bEmptyConstruction)
124         return BuildResult(vrVariable, vrValue);
125     else
126     {
127         m_bEmptyConstruction = false;
128         m_strPartVariable = vrVariable;
129         m_partMIValue = vrValue;
130         return BuildResult();
131     }
132 }