1 //===-- MICmnMIOutOfBandRecord.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 // File: MICmnMIOutOfBandRecord.h
13 // Overview: CMICmnMIOutOfBandRecord implementation.
15 // Environment: Compilers: Visual C++ 12.
16 // gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
17 // Libraries: See MIReadmetxt.
23 #include "MICmnMIOutOfBandRecord.h"
24 #include "MICmnResources.h"
27 CMICmnMIOutOfBandRecord::MapOutOfBandToOutOfBandText_t ms_MapOutOfBandToOutOfBandText =
29 { CMICmnMIOutOfBandRecord::eOutOfBand_Running, "running" },
30 { CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, "stopped" },
31 { CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointCreated, "breakpoint-created" },
32 { CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, "breakpoint-modified" },
33 { CMICmnMIOutOfBandRecord::eOutOfBand_Thread, "" }, // "" Meant to be empty
34 { CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupAdded, "thread-group-added" },
35 { CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupExited, "thread-group-exited" },
36 { CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupRemoved, "thread-group-removed" },
37 { CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted, "thread-group-started" },
38 { CMICmnMIOutOfBandRecord::eOutOfBand_ThreadCreated, "thread-created" },
39 { CMICmnMIOutOfBandRecord::eOutOfBand_ThreadExited, "thread-exited" },
40 { CMICmnMIOutOfBandRecord::eOutOfBand_ThreadSelected, "thread-selected" }
42 CMICmnMIOutOfBandRecord::MapOutOfBandToOutOfBandText_t ms_constMapAsyncRecordTextToToken =
44 { CMICmnMIOutOfBandRecord::eOutOfBand_Running, "*" },
45 { CMICmnMIOutOfBandRecord::eOutOfBand_Stopped, "*" },
46 { CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointCreated, "=" },
47 { CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, "=" },
48 { CMICmnMIOutOfBandRecord::eOutOfBand_Thread, "@" },
49 { CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupAdded, "=" },
50 { CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupExited, "=" },
51 { CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupRemoved, "=" },
52 { CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted, "=" },
53 { CMICmnMIOutOfBandRecord::eOutOfBand_ThreadCreated, "=" },
54 { CMICmnMIOutOfBandRecord::eOutOfBand_ThreadExited, "=" },
55 { CMICmnMIOutOfBandRecord::eOutOfBand_ThreadSelected, "=" }
58 //++ ------------------------------------------------------------------------------------
59 // Details: CMICmnMIOutOfBandRecord constructor.
65 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord( void )
66 : m_strAsyncRecord( MIRSRC( IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION ) )
70 //++ ------------------------------------------------------------------------------------
71 // Details: CMICmnMIOutOfBandRecord constructor.
73 // Args: veType - (R) A MI Out-of-Bound enumeration.
77 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord( const OutOfBand_e veType )
78 : m_eResultAsyncRecordClass( veType )
79 , m_strAsyncRecord( MIRSRC( IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION ) )
84 //++ ------------------------------------------------------------------------------------
85 // Details: CMICmnMIOutOfBandRecord constructor.
87 // Args: veType - (R) A MI Out-of-Bound enumeration.
88 // vMIResult - (R) A MI result object.
92 CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord( const OutOfBand_e veType, const CMICmnMIValueResult & vValue )
93 : m_eResultAsyncRecordClass( veType )
94 , m_strAsyncRecord( MIRSRC( IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION ) )
95 , m_partResult( vValue )
101 //++ ------------------------------------------------------------------------------------
102 // Details: CMICmnMIOutOfBandRecord destructor.
103 // Type: Overrideable.
108 CMICmnMIOutOfBandRecord::~CMICmnMIOutOfBandRecord( void )
112 //++ ------------------------------------------------------------------------------------
113 // Details: Return the MI Out-of-band record as a string. The string is a direct result of
114 // work done on *this Out-of-band record so if not enough data is added then it is
115 // possible to return a malformed Out-of-band record. If nothing has been set or
116 // added to *this MI Out-of-band record object then text "<Invalid>" will be returned.
119 // Return: CMIUtilString & - MI output text.
122 const CMIUtilString & CMICmnMIOutOfBandRecord::GetString( void ) const
124 return m_strAsyncRecord;
127 //++ ------------------------------------------------------------------------------------
128 // Details: Build the Out-of-band record's mandatory data part. The part up to the first
129 // (additional) result i.e. async-record ==> "*" type.
132 // Return: MIstatus::success - Functional succeeded.
133 // MIstatus::failure - Functional failed.
136 bool CMICmnMIOutOfBandRecord::BuildAsyncRecord( void )
138 const MIchar * pFormat = "%s%s";
139 const CMIUtilString & rStrAsyncRecord( ms_MapOutOfBandToOutOfBandText[ m_eResultAsyncRecordClass ] );
140 const CMIUtilString & rStrToken( ms_constMapAsyncRecordTextToToken[ m_eResultAsyncRecordClass ] );
141 m_strAsyncRecord = CMIUtilString::Format( pFormat, rStrToken.c_str(), rStrAsyncRecord.c_str() );
143 return MIstatus::success;
146 //++ ------------------------------------------------------------------------------------
147 // Details: Add to *this Out-of-band record additional information.
149 // Args: vMIValue - (R) A MI value derived object.
150 // Return: MIstatus::success - Functional succeeded.
151 // MIstatus::failure - Functional failed.
154 bool CMICmnMIOutOfBandRecord::Add( const CMICmnMIValue & vMIValue )
156 m_strAsyncRecord += ",";
157 m_strAsyncRecord += vMIValue.GetString();
159 return MIstatus::success;