2015-07-21 21:09:39 +08:00
|
|
|
//===-- MICmnMIResultRecord.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.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-07-21 20:39:58 +08:00
|
|
|
// Third Party Headers:
|
|
|
|
#include <assert.h>
|
|
|
|
|
2014-05-16 18:51:01 +08:00
|
|
|
// In-house headers:
|
|
|
|
#include "MICmnMIResultRecord.h"
|
|
|
|
#include "MICmnResources.h"
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
//++
|
|
|
|
//------------------------------------------------------------------------------------
|
2015-07-21 19:30:39 +08:00
|
|
|
// Details: Map a result class to the corresponding string.
|
|
|
|
// Args: veType - (R) A MI result class enumeration.
|
|
|
|
// Return: const char* - The string corresponding to the result class.
|
|
|
|
// Throws: None.
|
|
|
|
//--
|
2016-09-07 04:57:50 +08:00
|
|
|
static const char *
|
|
|
|
MapResultClassToResultClassText(CMICmnMIResultRecord::ResultClass_e veType) {
|
|
|
|
switch (veType) {
|
|
|
|
case CMICmnMIResultRecord::eResultClass_Done:
|
|
|
|
return "done";
|
|
|
|
case CMICmnMIResultRecord::eResultClass_Running:
|
|
|
|
return "running";
|
|
|
|
case CMICmnMIResultRecord::eResultClass_Connected:
|
|
|
|
return "connected";
|
|
|
|
case CMICmnMIResultRecord::eResultClass_Error:
|
|
|
|
return "error";
|
|
|
|
case CMICmnMIResultRecord::eResultClass_Exit:
|
|
|
|
return "exit";
|
|
|
|
}
|
|
|
|
assert(false && "unknown CMICmnMIResultRecord::ResultClass_e");
|
|
|
|
return NULL;
|
2015-07-21 19:30:39 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
//++
|
|
|
|
//------------------------------------------------------------------------------------
|
|
|
|
// Details: Build the result record's mandatory data part. The part up to the
|
|
|
|
// first
|
|
|
|
// (additional) result i.e. result-record ==> [ token ] "^"
|
|
|
|
// result-class.
|
2015-07-21 19:30:39 +08:00
|
|
|
// Args: vrToken - (R) The command's transaction ID or token.
|
|
|
|
// veType - (R) A MI result class enumeration.
|
|
|
|
// Return: CMIUtilString & - MI result record mandatory data
|
|
|
|
// Throws: None.
|
|
|
|
//--
|
|
|
|
static const CMIUtilString
|
2016-09-07 04:57:50 +08:00
|
|
|
BuildResultRecord(const CMIUtilString &vrToken,
|
|
|
|
CMICmnMIResultRecord::ResultClass_e veType) {
|
|
|
|
const char *pStrResultRecord = MapResultClassToResultClassText(veType);
|
|
|
|
return CMIUtilString::Format("%s^%s", vrToken.c_str(), pStrResultRecord);
|
2015-07-21 19:30:39 +08:00
|
|
|
}
|
2014-05-16 18:51:01 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
//++
|
|
|
|
//------------------------------------------------------------------------------------
|
2014-11-18 02:06:21 +08:00
|
|
|
// Details: CMICmnMIResultRecord constructor.
|
|
|
|
// Type: Method.
|
|
|
|
// Args: None.
|
|
|
|
// Return: None.
|
|
|
|
// Throws: None.
|
2014-05-16 18:51:01 +08:00
|
|
|
//--
|
2015-07-21 19:30:39 +08:00
|
|
|
CMICmnMIResultRecord::CMICmnMIResultRecord()
|
2016-09-07 04:57:50 +08:00
|
|
|
: m_strResultRecord(MIRSRC(IDS_CMD_ERR_CMD_RUN_BUT_NO_ACTION)) {}
|
2014-05-16 18:51:01 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
//++
|
|
|
|
//------------------------------------------------------------------------------------
|
2014-11-18 02:06:21 +08:00
|
|
|
// Details: CMICmnMIResultRecord constructor.
|
|
|
|
// Type: Method.
|
|
|
|
// Args: vrToken - (R) The command's transaction ID or token.
|
|
|
|
// veType - (R) A MI result class enumeration.
|
|
|
|
// Return: None.
|
|
|
|
// Throws: None.
|
2014-05-16 18:51:01 +08:00
|
|
|
//--
|
2016-09-07 04:57:50 +08:00
|
|
|
CMICmnMIResultRecord::CMICmnMIResultRecord(const CMIUtilString &vrToken,
|
|
|
|
ResultClass_e veType)
|
|
|
|
: m_strResultRecord(BuildResultRecord(vrToken, veType)) {}
|
2014-05-16 18:51:01 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
//++
|
|
|
|
//------------------------------------------------------------------------------------
|
2014-11-18 02:06:21 +08:00
|
|
|
// Details: CMICmnMIResultRecord constructor.
|
|
|
|
// Type: Method.
|
|
|
|
// Args: vrToken - (R) The command's transaction ID or token.
|
|
|
|
// veType - (R) A MI result class enumeration.
|
|
|
|
// vMIResult - (R) A MI result object.
|
|
|
|
// Return: None.
|
|
|
|
// Throws: None.
|
2014-05-16 18:51:01 +08:00
|
|
|
//--
|
2016-09-07 04:57:50 +08:00
|
|
|
CMICmnMIResultRecord::CMICmnMIResultRecord(const CMIUtilString &vrToken,
|
|
|
|
ResultClass_e veType,
|
|
|
|
const CMICmnMIValueResult &vValue)
|
|
|
|
: m_strResultRecord(BuildResultRecord(vrToken, veType)) {
|
|
|
|
Add(vValue);
|
2014-05-16 18:51:01 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
//++
|
|
|
|
//------------------------------------------------------------------------------------
|
2014-11-18 02:06:21 +08:00
|
|
|
// Details: CMICmnMIResultRecord destructor.
|
|
|
|
// Type: Overrideable.
|
|
|
|
// Args: None.
|
|
|
|
// Return: None.
|
|
|
|
// Throws: None.
|
2014-05-16 18:51:01 +08:00
|
|
|
//--
|
2016-09-07 04:57:50 +08:00
|
|
|
CMICmnMIResultRecord::~CMICmnMIResultRecord() {}
|
2014-05-16 18:51:01 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
//++
|
|
|
|
//------------------------------------------------------------------------------------
|
|
|
|
// Details: Return the MI result record as a string. The string is a direct
|
|
|
|
// result of
|
|
|
|
// work done on *this result record so if not enough data is added then
|
|
|
|
// it is
|
|
|
|
// possible to return a malformed result record. If nothing has been
|
|
|
|
// set or
|
|
|
|
// added to *this MI result record object then text "<Invalid>" will be
|
|
|
|
// returned.
|
2014-11-18 02:06:21 +08:00
|
|
|
// Type: Method.
|
|
|
|
// Args: None.
|
|
|
|
// Return: CMIUtilString & - MI output text.
|
|
|
|
// Throws: None.
|
2014-05-16 18:51:01 +08:00
|
|
|
//--
|
2016-09-07 04:57:50 +08:00
|
|
|
const CMIUtilString &CMICmnMIResultRecord::GetString() const {
|
|
|
|
return m_strResultRecord;
|
2014-05-16 18:51:01 +08:00
|
|
|
}
|
2014-11-18 02:06:21 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
//++
|
|
|
|
//------------------------------------------------------------------------------------
|
2014-11-18 02:06:21 +08:00
|
|
|
// Details: Add to *this result record additional information.
|
|
|
|
// Type: Method.
|
|
|
|
// Args: vMIValue - (R) A MI value derived object.
|
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
|
|
|
//--
|
2016-09-07 04:57:50 +08:00
|
|
|
void CMICmnMIResultRecord::Add(const CMICmnMIValue &vMIValue) {
|
|
|
|
m_strResultRecord += ",";
|
|
|
|
m_strResultRecord += vMIValue.GetString();
|
2014-05-16 18:51:01 +08:00
|
|
|
}
|