]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/lldb/tools/lldb-mi/MICmnStreamStdin.h
Move all sources from the llvm project into contrib/llvm-project.
[FreeBSD/FreeBSD.git] / contrib / llvm-project / lldb / tools / lldb-mi / MICmnStreamStdin.h
1 //===-- MICmnStreamStdin.h --------------------------------------*- C++ -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8
9 #pragma once
10
11 // In-house headers:
12 #include "MICmnBase.h"
13 #include "MIUtilSingletonBase.h"
14 #include "MIUtilString.h"
15 #include "MIUtilThreadBaseStd.h"
16
17 //++
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
21 //          interface
22 //          provide can receive callbacks when a new line of data is received.
23 //          Each line is determined by a carriage return.
24 //          A singleton class.
25 //--
26 class CMICmnStreamStdin : public CMICmnBase,
27                           public MI::ISingleton<CMICmnStreamStdin> {
28   // Give singleton access to private constructors
29   friend MI::ISingleton<CMICmnStreamStdin>;
30
31   // Methods:
32 public:
33   bool Initialize() override;
34   bool Shutdown() override;
35   //
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);
41
42   // Methods:
43 private:
44   /* ctor */ CMICmnStreamStdin();
45   /* ctor */ CMICmnStreamStdin(const CMICmnStreamStdin &);
46   void operator=(const CMICmnStreamStdin &);
47
48   // Overridden:
49 private:
50   // From CMICmnBase
51   /* dtor */ ~CMICmnStreamStdin() override;
52
53   // Attributes:
54 private:
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),
57                       // false = no prompt
58   static const int m_constBufferSize = 2048;
59   char *m_pCmdBuffer;
60 };