2015-07-21 21:09:39 +08:00
|
|
|
//===-- MICmnMIValueResult.cpp ----------------------------------*- C++ -*-===//
|
2014-05-16 18:51:01 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// In-house headers:
|
|
|
|
#include "MICmnMIValueResult.h"
|
|
|
|
#include "MICmnResources.h"
|
|
|
|
|
|
|
|
// Instantiations:
|
2014-11-18 02:06:21 +08:00
|
|
|
const CMIUtilString CMICmnMIValueResult::ms_constStrEqual("=");
|
2014-05-16 18:51:01 +08:00
|
|
|
|
|
|
|
//++ ------------------------------------------------------------------------------------
|
2014-11-18 02:06:21 +08:00
|
|
|
// Details: CMICmnMIValueResult constructor.
|
|
|
|
// Type: Method.
|
|
|
|
// Args: None.
|
|
|
|
// Return: None.
|
|
|
|
// Throws: None.
|
2014-05-16 18:51:01 +08:00
|
|
|
//--
|
2015-08-04 18:24:20 +08:00
|
|
|
CMICmnMIValueResult::CMICmnMIValueResult()
|
2014-11-18 02:06:21 +08:00
|
|
|
: m_bEmptyConstruction(true)
|
2014-05-16 18:51:01 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//++ ------------------------------------------------------------------------------------
|
2014-11-18 02:06:21 +08:00
|
|
|
// Details: CMICmnMIValueResult constructor.
|
|
|
|
// Type: Method.
|
|
|
|
// Args: vrVariable - (R) MI value's name.
|
|
|
|
// vrValue - (R) The MI value.
|
|
|
|
// Return: None.
|
|
|
|
// Throws: None.
|
2014-05-16 18:51:01 +08:00
|
|
|
//--
|
2014-11-18 02:06:21 +08:00
|
|
|
CMICmnMIValueResult::CMICmnMIValueResult(const CMIUtilString &vrVariable, const CMICmnMIValue &vrValue)
|
|
|
|
: m_strPartVariable(vrVariable)
|
|
|
|
, m_partMIValue(vrValue)
|
|
|
|
, m_bEmptyConstruction(false)
|
|
|
|
, m_bUseSpacing(false)
|
2014-05-16 18:51:01 +08:00
|
|
|
{
|
2014-11-18 02:06:21 +08:00
|
|
|
BuildResult();
|
2014-05-16 18:51:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//++ ------------------------------------------------------------------------------------
|
2014-11-18 02:06:21 +08:00
|
|
|
// Details: CMICmnMIValueResult constructor.
|
|
|
|
// Type: Method.
|
|
|
|
// Args: vrVariable - (R) MI value's name.
|
|
|
|
// vrValue - (R) The MI value.
|
2015-07-03 11:54:17 +08:00
|
|
|
// vbUseSpacing - (R) True = put space separators into the string, false = no spaces used.
|
2014-11-18 02:06:21 +08:00
|
|
|
// Return: None.
|
|
|
|
// Throws: None.
|
2014-05-16 18:51:01 +08:00
|
|
|
//--
|
2014-11-18 02:06:21 +08:00
|
|
|
CMICmnMIValueResult::CMICmnMIValueResult(const CMIUtilString &vrVariable, const CMICmnMIValue &vrValue, const bool vbUseSpacing)
|
|
|
|
: m_strPartVariable(vrVariable)
|
|
|
|
, m_partMIValue(vrValue)
|
|
|
|
, m_bEmptyConstruction(false)
|
|
|
|
, m_bUseSpacing(vbUseSpacing)
|
2014-05-16 18:51:01 +08:00
|
|
|
{
|
2014-11-18 02:06:21 +08:00
|
|
|
BuildResult();
|
2014-05-16 18:51:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//++ ------------------------------------------------------------------------------------
|
2014-11-18 02:06:21 +08:00
|
|
|
// Details: CMICmnMIValueResult destructor.
|
|
|
|
// Type: Overrideable.
|
|
|
|
// Args: None.
|
|
|
|
// Return: None.
|
|
|
|
// Throws: None.
|
2014-05-16 18:51:01 +08:00
|
|
|
//--
|
2015-08-04 18:24:20 +08:00
|
|
|
CMICmnMIValueResult::~CMICmnMIValueResult()
|
2014-05-16 18:51:01 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//++ ------------------------------------------------------------------------------------
|
2014-11-18 02:06:21 +08:00
|
|
|
// Details: Build the MI value result string.
|
|
|
|
// Type: Method.
|
|
|
|
// Args: None.
|
2015-07-23 01:07:27 +08:00
|
|
|
// Return: None.
|
2014-11-18 02:06:21 +08:00
|
|
|
// Throws: None.
|
2014-05-16 18:51:01 +08:00
|
|
|
//--
|
2015-07-23 01:07:27 +08:00
|
|
|
void
|
2015-08-04 18:24:20 +08:00
|
|
|
CMICmnMIValueResult::BuildResult()
|
2014-05-16 18:51:01 +08:00
|
|
|
{
|
2015-07-03 21:45:34 +08:00
|
|
|
const char *pFormat = m_bUseSpacing ? "%s %s %s" : "%s%s%s";
|
2014-11-18 02:06:21 +08:00
|
|
|
m_strValue = CMIUtilString::Format(pFormat, m_strPartVariable.c_str(), ms_constStrEqual.c_str(), m_partMIValue.GetString().c_str());
|
2014-05-16 18:51:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//++ ------------------------------------------------------------------------------------
|
2014-11-18 02:06:21 +08:00
|
|
|
// Details: Build the MI value result string.
|
|
|
|
// Type: Method.
|
|
|
|
// Args: vrVariable - (R) MI value's name.
|
|
|
|
// vrValue - (R) The MI value.
|
2015-07-23 01:07:27 +08:00
|
|
|
// Return: None.
|
2014-11-18 02:06:21 +08:00
|
|
|
// Throws: None.
|
2014-05-16 18:51:01 +08:00
|
|
|
//--
|
2015-07-23 01:07:27 +08:00
|
|
|
void
|
2014-11-18 02:06:21 +08:00
|
|
|
CMICmnMIValueResult::BuildResult(const CMIUtilString &vVariable, const CMICmnMIValue &vValue)
|
2014-05-16 18:51:01 +08:00
|
|
|
{
|
2015-07-03 21:45:34 +08:00
|
|
|
const char *pFormat = m_bUseSpacing ? "%s, %s %s %s" : "%s,%s%s%s";
|
2014-11-18 02:06:21 +08:00
|
|
|
m_strValue =
|
|
|
|
CMIUtilString::Format(pFormat, m_strValue.c_str(), vVariable.c_str(), ms_constStrEqual.c_str(), vValue.GetString().c_str());
|
2014-05-16 18:51:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//++ ------------------------------------------------------------------------------------
|
2014-11-18 02:06:21 +08:00
|
|
|
// Details: Append another MI value object to *this MI value result.
|
|
|
|
// Type: Method.
|
|
|
|
// Args: vrVariable - (R) MI value's name.
|
|
|
|
// vrValue - (R) The MI value.
|
|
|
|
// Return: MIstatus::success - Functional succeeded.
|
|
|
|
// MIstatus::failure - Functional failed.
|
|
|
|
// Throws: None.
|
2014-05-16 18:51:01 +08:00
|
|
|
//--
|
2015-07-23 01:07:27 +08:00
|
|
|
void
|
2014-11-18 02:06:21 +08:00
|
|
|
CMICmnMIValueResult::Add(const CMIUtilString &vrVariable, const CMICmnMIValue &vrValue)
|
2014-05-16 18:51:01 +08:00
|
|
|
{
|
2014-11-18 02:06:21 +08:00
|
|
|
if (!m_bEmptyConstruction)
|
2015-07-23 01:07:27 +08:00
|
|
|
BuildResult(vrVariable, vrValue);
|
2014-11-18 02:06:21 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
m_bEmptyConstruction = false;
|
|
|
|
m_strPartVariable = vrVariable;
|
|
|
|
m_partMIValue = vrValue;
|
2015-07-23 01:07:27 +08:00
|
|
|
BuildResult();
|
2014-11-18 02:06:21 +08:00
|
|
|
}
|
2014-05-16 18:51:01 +08:00
|
|
|
}
|