]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/tools/lldb-mi/MICmnStreamStdinWindows.h
Merge ^/head r274961 through r276342.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / tools / lldb-mi / MICmnStreamStdinWindows.h
1 //===-- MICmnStreamStdinWindows.h -------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 //++
11 // File:                MIUtilStreamStdin.h
12 //
13 // Overview:    CMICmnStreamStdinWindows interface.
14 //
15 // Environment: Compilers:      Visual C++ 12.
16 //                                                      gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
17 //                              Libraries:      See MIReadmetxt. 
18 //
19 // Copyright:   None.
20 //--
21
22 #pragma once
23
24 // In-house headers:
25 #include "MICmnBase.h"
26 #include "MICmnStreamStdin.h"
27 #include "MIUtilSingletonBase.h"
28
29 //++ ============================================================================
30 // Details:     MI common code class. Specific OS stdin handling implementation.
31 //                      CMICmnStreamStdin instance is set with stdin handler before using the
32 //                      the stream. An instance of this class must be set up and ready to give
33 //                      to the CMICmnStreamStdin before it initialises other CMICmnStreamStdin
34 //                      will give an error.
35 // Gotchas:     None.
36 // Authors:     Illya Rudkin 16/06/2014.
37 // Changes:     None.
38 //--
39 class CMICmnStreamStdinWindows
40 :       public CMICmnBase
41 ,       public CMICmnStreamStdin::IOSStdinHandler
42 ,       public MI::ISingleton< CMICmnStreamStdinWindows >
43 {
44         // Give singleton access to private constructors
45         friend MI::ISingleton< CMICmnStreamStdinWindows >;
46
47 // Methods:
48 public:
49         bool    Initialize( void );
50         bool    Shutdown( void );
51
52 // Overridden:
53 public:
54         // From CMICmnStreamStdin::IOSpecificReadStreamStdin
55         virtual bool                    InputAvailable( bool & vwbAvail );
56         virtual const MIchar *  ReadLine( CMIUtilString & vwErrMsg );
57         
58 // Methods:
59 private:
60         /* ctor */      CMICmnStreamStdinWindows( void );
61         /* ctor */      CMICmnStreamStdinWindows( const CMICmnStreamStdinWindows & );
62         void            operator=( const CMICmnStreamStdinWindows & );
63         //
64         bool    InputAvailableConsoleWin( bool & vwbAvail );
65         bool    InputAvailableApplication( bool & vwbAvail );
66         
67 // Overridden:
68 private:
69         // From CMICmnBase
70         /* dtor */ virtual ~CMICmnStreamStdinWindows( void );
71
72 // Attributes:
73 private:
74         const MIuint    m_constBufferSize;
75         FILE *                  m_pStdin;
76         MIchar *                m_pCmdBuffer;
77         MIchar *                m_pStdinBuffer;                         // Custom buffer to store std input
78         MIuint                  m_nBytesToBeRead;                       // Checks that ::fgets() is holding on to data while ::PeekNamedPipe() returns nothing which causes a problem
79         bool                    m_bRunningInConsoleWin;         // True = The application is being run in a Windows command line prompt window, false = by other means
80 };
81