1 //===-- MICmnMIValueResult.cpp ----------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 #include "MICmnMIValueResult.h"
12 #include "MICmnResources.h"
15 const CMIUtilString CMICmnMIValueResult::ms_constStrEqual("=");
18 //------------------------------------------------------------------------------------
19 // Details: CMICmnMIValueResult constructor.
25 CMICmnMIValueResult::CMICmnMIValueResult() : m_bEmptyConstruction(true) {}
28 //------------------------------------------------------------------------------------
29 // Details: CMICmnMIValueResult constructor.
31 // Args: vrVariable - (R) MI value's name.
32 // vrValue - (R) The MI value.
36 CMICmnMIValueResult::CMICmnMIValueResult(const CMIUtilString &vrVariable,
37 const CMICmnMIValue &vrValue)
38 : m_strPartVariable(vrVariable), m_partMIValue(vrValue),
39 m_bEmptyConstruction(false), m_bUseSpacing(false) {
44 //------------------------------------------------------------------------------------
45 // Details: CMICmnMIValueResult constructor.
47 // Args: vrVariable - (R) MI value's name.
48 // vrValue - (R) The MI value.
49 // vbUseSpacing - (R) True = put space separators into the string,
50 // false = no spaces used.
54 CMICmnMIValueResult::CMICmnMIValueResult(const CMIUtilString &vrVariable,
55 const CMICmnMIValue &vrValue,
56 const bool vbUseSpacing)
57 : m_strPartVariable(vrVariable), m_partMIValue(vrValue),
58 m_bEmptyConstruction(false), m_bUseSpacing(vbUseSpacing) {
63 //------------------------------------------------------------------------------------
64 // Details: CMICmnMIValueResult destructor.
65 // Type: Overrideable.
70 CMICmnMIValueResult::~CMICmnMIValueResult() {}
73 //------------------------------------------------------------------------------------
74 // Details: Build the MI value result string.
80 void CMICmnMIValueResult::BuildResult() {
81 const char *pFormat = m_bUseSpacing ? "%s %s %s" : "%s%s%s";
82 m_strValue = CMIUtilString::Format(pFormat, m_strPartVariable.c_str(),
83 ms_constStrEqual.c_str(),
84 m_partMIValue.GetString().c_str());
88 //------------------------------------------------------------------------------------
89 // Details: Build the MI value result string.
91 // Args: vrVariable - (R) MI value's name.
92 // vrValue - (R) The MI value.
96 void CMICmnMIValueResult::BuildResult(const CMIUtilString &vVariable,
97 const CMICmnMIValue &vValue) {
98 const char *pFormat = m_bUseSpacing ? "%s, %s %s %s" : "%s,%s%s%s";
99 m_strValue = CMIUtilString::Format(
100 pFormat, m_strValue.c_str(), vVariable.c_str(), ms_constStrEqual.c_str(),
101 vValue.GetString().c_str());
105 //------------------------------------------------------------------------------------
106 // Details: Append another MI value object to *this MI value result.
108 // Args: vrVariable - (R) MI value's name.
109 // vrValue - (R) The MI value.
110 // Return: MIstatus::success - Functional succeeded.
111 // MIstatus::failure - Functional failed.
114 void CMICmnMIValueResult::Add(const CMIUtilString &vrVariable,
115 const CMICmnMIValue &vrValue) {
116 if (!m_bEmptyConstruction)
117 BuildResult(vrVariable, vrValue);
119 m_bEmptyConstruction = false;
120 m_strPartVariable = vrVariable;
121 m_partMIValue = vrValue;