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