1 //===-- MICmnStreamStdin.h --------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
12 #include "MICmnBase.h"
13 #include "MIUtilSingletonBase.h"
14 #include "MIUtilString.h"
15 #include "MIUtilThreadBaseStd.h"
18 //============================================================================
19 // Details: MI common code class. Used to handle stream data from Stdin.
20 // Singleton class using the Visitor pattern. A driver using the
22 // provide can receive callbacks when a new line of data is received.
23 // Each line is determined by a carriage return.
26 class CMICmnStreamStdin : public CMICmnBase,
27 public MI::ISingleton<CMICmnStreamStdin> {
28 // Give singleton access to private constructors
29 friend MI::ISingleton<CMICmnStreamStdin>;
33 bool Initialize() override;
34 bool Shutdown() override;
36 const CMIUtilString &GetPrompt() const;
37 bool SetPrompt(const CMIUtilString &vNewPrompt);
38 void SetEnablePrompt(const bool vbYes);
39 bool GetEnablePrompt() const;
40 const char *ReadLine(CMIUtilString &vwErrMsg);
44 /* ctor */ CMICmnStreamStdin();
45 /* ctor */ CMICmnStreamStdin(const CMICmnStreamStdin &);
46 void operator=(const CMICmnStreamStdin &);
51 /* dtor */ ~CMICmnStreamStdin() override;
55 CMIUtilString m_strPromptCurrent; // Command line prompt as shown to the user
56 bool m_bShowPrompt; // True = Yes prompt is shown/output to the user (stdout),
58 static const int m_constBufferSize = 2048;