Index: tools/lldb-mi/MICmnMIResultRecord.h =================================================================== --- tools/lldb-mi/MICmnMIResultRecord.h +++ tools/lldb-mi/MICmnMIResultRecord.h @@ -60,15 +60,11 @@ eResultClass_count // Always the last one }; - // Typedefs: - public: - typedef std::map MapResultClassToResultClassText_t; - // Methods: public: /* ctor */ CMICmnMIResultRecord(void); - /* ctor */ CMICmnMIResultRecord(const CMIUtilString &vrToken, const ResultClass_e veType); - /* ctor */ CMICmnMIResultRecord(const CMIUtilString &vrToken, const ResultClass_e veType, const CMICmnMIValueResult &vValue); + /* ctor */ CMICmnMIResultRecord(const CMIUtilString &vrToken, ResultClass_e veType); + /* ctor */ CMICmnMIResultRecord(const CMIUtilString &vrToken, ResultClass_e veType, const CMICmnMIValueResult &vValue); // const CMIUtilString &GetString(void) const; bool Add(const CMICmnMIValue &vMIValue); @@ -78,17 +74,7 @@ // From CMICmnBase /* dtor */ ~CMICmnMIResultRecord(void) override; - // Methods: - private: - bool BuildResultRecord(void); - // Attributes: private: - static const CMIUtilString ms_constStrResultRecordHat; - static MapResultClassToResultClassText_t ms_constMapResultClassToResultClassText; - // - CMIUtilString m_strResultRecordToken; - ResultClass_e m_eResultRecordResultClass; CMIUtilString m_strResultRecord; // Holds the text version of the result record to date - CMICmnMIValueResult m_partResult; }; Index: tools/lldb-mi/MICmnMIResultRecord.cpp =================================================================== --- tools/lldb-mi/MICmnMIResultRecord.cpp +++ tools/lldb-mi/MICmnMIResultRecord.cpp @@ -11,14 +11,29 @@ #include "MICmnMIResultRecord.h" #include "MICmnResources.h" -// Instantiations: -CMICmnMIResultRecord::MapResultClassToResultClassText_t ms_MapResultClassToResultClassText = { - {CMICmnMIResultRecord::eResultClass_Done, "done"}, - {CMICmnMIResultRecord::eResultClass_Running, "running"}, - {CMICmnMIResultRecord::eResultClass_Connected, "connected"}, - {CMICmnMIResultRecord::eResultClass_Error, "error"}, - {CMICmnMIResultRecord::eResultClass_Exit, "exit"}}; -const CMIUtilString CMICmnMIResultRecord::ms_constStrResultRecordHat("^"); +const char* s_MapResultClassToResultClassText[] = { + "done", + "running", + "connected", + "error", + "exit" +}; + +//++ ------------------------------------------------------------------------------------ +// Details: Build the result record's mandatory data part. The part up to the first +// (additional) result i.e. result-record ==> [ token ] "^" result-class. +// Type: Method. +// Args: vrToken - (R) The command's transaction ID or token. +// veType - A MI result class enumeration. +// Return: CMIUtilString & - MI result record mandatory data +// Throws: None. +//-- +static const CMIUtilString +BuildResultRecord(const CMIUtilString &vrToken, CMICmnMIResultRecord::ResultClass_e veType) +{ + const char *pStrResultRecord = s_MapResultClassToResultClassText[veType]; + return CMIUtilString::Format("%s^%s", vrToken.c_str(), pStrResultRecord); +} //++ ------------------------------------------------------------------------------------ // Details: CMICmnMIResultRecord constructor. @@ -36,35 +51,28 @@ // Details: CMICmnMIResultRecord constructor. // Type: Method. // Args: vrToken - (R) The command's transaction ID or token. -// veType - (R) A MI result class enumeration. +// veType - A MI result class enumeration. // Return: None. // Throws: None. //-- -CMICmnMIResultRecord::CMICmnMIResultRecord(const CMIUtilString &vrToken, const ResultClass_e veType) - : m_strResultRecordToken(vrToken) - , m_eResultRecordResultClass(veType) - , m_strResultRecord(MIRSRC(IDS_CMD_ERR_CMD_RUN_BUT_NO_ACTION)) +CMICmnMIResultRecord::CMICmnMIResultRecord(const CMIUtilString &vrToken, ResultClass_e veType) + : m_strResultRecord(BuildResultRecord(vrToken, veType)) { - BuildResultRecord(); } //++ ------------------------------------------------------------------------------------ // Details: CMICmnMIResultRecord constructor. // Type: Method. // Args: vrToken - (R) The command's transaction ID or token. -// veType - (R) A MI result class enumeration. +// veType - A MI result class enumeration. // vMIResult - (R) A MI result object. // Return: None. // Throws: None. //-- -CMICmnMIResultRecord::CMICmnMIResultRecord(const CMIUtilString &vrToken, const ResultClass_e veType, const CMICmnMIValueResult &vValue) - : m_strResultRecordToken(vrToken) - , m_eResultRecordResultClass(veType) - , m_strResultRecord(MIRSRC(IDS_CMD_ERR_CMD_RUN_BUT_NO_ACTION)) - , m_partResult(vValue) +CMICmnMIResultRecord::CMICmnMIResultRecord(const CMIUtilString &vrToken, ResultClass_e veType, const CMICmnMIValueResult &vValue) + : m_strResultRecord(BuildResultRecord(vrToken, veType)) { - BuildResultRecord(); - Add(m_partResult); + Add(vValue); } //++ ------------------------------------------------------------------------------------ @@ -95,26 +103,6 @@ } //++ ------------------------------------------------------------------------------------ -// Details: Build the result record's mandatory data part. The part up to the first -// (additional) result i.e. result-record ==> [ token ] "^" result-class. -// Type: Method. -// Args: None. -// Return: MIstatus::success - Functional succeeded. -// MIstatus::failure - Functional failed. -// Throws: None. -//-- -bool -CMICmnMIResultRecord::BuildResultRecord(void) -{ - const char *pFormat = "%s%s%s"; - const CMIUtilString &rStrResultRecord(ms_MapResultClassToResultClassText[m_eResultRecordResultClass]); - m_strResultRecord = - CMIUtilString::Format(pFormat, m_strResultRecordToken.c_str(), ms_constStrResultRecordHat.c_str(), rStrResultRecord.c_str()); - - return MIstatus::success; -} - -//++ ------------------------------------------------------------------------------------ // Details: Add to *this result record additional information. // Type: Method. // Args: vMIValue - (R) A MI value derived object.