1 //===-- MIDriverBase.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 //===----------------------------------------------------------------------===//
10 // Third party headers:
11 #include "lldb/API/SBBroadcaster.h"
12 #include "lldb/API/SBEvent.h"
15 #include "MIDriverBase.h"
18 //------------------------------------------------------------------------------------
19 // Details: CMIDriverBase constructor.
25 CMIDriverBase::CMIDriverBase()
26 : m_pDriverFallThru(nullptr), m_pDriverParent(nullptr), m_bExitApp(false) {}
29 //------------------------------------------------------------------------------------
30 // Details: CMIDriverBase destructor.
31 // Type: Overrideable.
36 CMIDriverBase::~CMIDriverBase() { m_pDriverFallThru = NULL; }
39 //------------------------------------------------------------------------------------
40 // Details: This function allows *this driver to call on another driver to
42 // should this driver not be able to handle the client data input.
43 // Type: Overrideable.
44 // Check the error message if the function returns a failure.
46 // Args: vCmd - (R) Command instruction to interpret.
47 // vwErrMsg - (W) Error description on command failing.
48 // Return: MIstatus::success - Command succeeded.
49 // MIstatus::failure - Command failed.
52 bool CMIDriverBase::DoFallThruToAnotherDriver(const CMIUtilString &vCmd,
53 CMIUtilString &vwErrMsg) {
54 // Do nothing - override and implement. Use m_pDriverFallThru.
55 return MIstatus::success;
59 //------------------------------------------------------------------------------------
60 // Details: This function allows *this driver to call on another driver to
62 // should this driver not be able to handle the client data input.
63 // Type: Overrideable.
64 // Args: vrOtherDriver - (R) Reference to another driver object.
65 // Return: MIstatus::success - Functional succeeded.
66 // MIstatus::failure - Functional failed.
69 bool CMIDriverBase::SetDriverToFallThruTo(const CMIDriverBase &vrOtherDriver) {
70 MIunused(vrOtherDriver);
72 // Do nothing - override and implement. Set m_pDriverFallThru.
74 return MIstatus::success;
78 //------------------------------------------------------------------------------------
79 // Details: This function allows *this driver to call functionality on the
81 // ask for information for example.
82 // Type: Overrideable.
83 // Args: vrOtherDriver - (R) Reference to another driver object.
84 // Return: MIstatus::success - Functional succeeded.
85 // MIstatus::failure - Functional failed.
88 bool CMIDriverBase::SetDriverParent(const CMIDriverBase &vrOtherDriver) {
89 MIunused(vrOtherDriver);
91 // Do nothing - override and implement. Set m_pDriverParent.
93 return MIstatus::success;
97 //------------------------------------------------------------------------------------
98 // Details: Retrieve the parent driver to *this driver if one assigned. If
100 // is the pass through driver that the parent driver passes work to.
103 // Return: CMIDriverBase * - Pointer to a driver object.
104 // - NULL = there is not parent to *this driver.
107 CMIDriverBase *CMIDriverBase::GetDriversParent() const {
108 return m_pDriverParent;
112 //------------------------------------------------------------------------------------
113 // Details: Retrieve the pointer to the other fall through driver *this driver
118 // Return: CMIDriverBase * - Pointer to other driver.
119 // - NULL if no driver set.
122 CMIDriverBase *CMIDriverBase::GetDriverToFallThruTo() const {
123 return m_pDriverFallThru;
127 //------------------------------------------------------------------------------------
128 // Details: *this driver provides a file stream to other drivers on which *this
130 // write's out to and they read as expected input. *this driver is
132 // through commands to the (child) pass through assigned driver.
133 // Type: Overrideable.
135 // Return: FILE * - Pointer to stream.
138 FILE *CMIDriverBase::GetStdin() const {
139 // Do nothing - override and implement
144 //------------------------------------------------------------------------------------
145 // Details: *this driver provides a file stream to other pass through assigned
147 // so they know what to write to.
148 // Type: Overrideable.
150 // Return: FILE * - Pointer to stream.
153 FILE *CMIDriverBase::GetStdout() const {
154 // Do nothing - override and implement
159 //------------------------------------------------------------------------------------
160 // Details: *this driver provides a error file stream to other pass through
162 // so they know what to write to.
163 // Type: Overrideable.
165 // Return: FILE * - Pointer to stream.
168 FILE *CMIDriverBase::GetStderr() const {
169 // Do nothing - override and implement
174 //------------------------------------------------------------------------------------
175 // Details: Set the MI Driver's exit application flag. The application checks
177 // after every stdin line is read so the exit may not be instantaneous.
178 // If vbForceExit is false the MI Driver queries its state and
180 // should exit or continue operating depending on that running state.
181 // Type: Overrideable.
182 // Args: vbForceExit - (R) True = Do not query, set state to exit, false =
183 // query if can/should exit right now.
187 void CMIDriverBase::SetExitApplicationFlag(const bool vbForceExit) {
188 MIunused(vbForceExit);
190 // Do nothing - override and implement