GCC 4.3.x fixes for cabman and sysreg
[reactos.git] / reactos / tools / sysreg / pipe_reader.h
1 #ifndef PIPE_READER_H__
2 #define PIPE_READER_H__
3
4 /* $Id$
5 *
6 * PROJECT: System regression tool for ReactOS
7 * LICENSE: GPL - See COPYING in the top level directory
8 * FILE: tools/sysreg/conf_parser.h
9 * PURPOSE: file reading support
10 * PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at)
11 */
12
13
14
15 #include "user_types.h"
16 #include "data_source.h"
17 #include <cstdio>
18 #include <iostream>
19 #include <cassert>
20 #include <cstdlib>
21 #include <cstring>
22 #include <limits.h>
23
24 namespace System_
25 {
26 //---------------------------------------------------------------------------------------
27 ///
28 /// class PipeReader
29 ///
30 /// Description: this class implements a pipe reader. It uses _popen to perform opening of
31 /// pipe / _pclose
32
33 class PipeReader : public DataSource
34 {
35 public:
36
37 //---------------------------------------------------------------------------------------
38 ///
39 /// PipeReader
40 ///
41 /// Description: constructor of class PipeReader
42
43 PipeReader();
44
45 //---------------------------------------------------------------------------------------
46 ///
47 /// virtual ~PipeReader
48 ///
49 /// Description: destructor of class PipeReader
50
51 virtual ~PipeReader();
52
53 //---------------------------------------------------------------------------------------
54 ///
55 /// openPipe
56 ///
57 /// Description: this function attempts to open a pipe. If an pipe is already open or
58 /// it fails to open a pipe, the function returns false
59 ///
60 /// @param PipeCmd command of the pipe to open
61 /// @param AccessMode on how to open the pipe
62 /// accepted modes are t ... text mode - not compatible with b
63 /// b ... binary mode - not compatible with t
64 /// r ... allows reading from the pipe
65 /// w ... allows writing to the pipe
66 /// @return bool
67
68 virtual bool openSource(const string & PipeCmd);
69
70 //---------------------------------------------------------------------------------------
71 ///
72 /// closePipe
73 ///
74 /// Description: closes a pipe. Returns true on success
75 ///
76 /// @return bool
77
78 virtual bool closeSource();
79
80 //---------------------------------------------------------------------------------------
81 ///
82 /// readPipe
83 ///
84 /// Description: attempts to read from the pipe. Returns true on success. If it returns
85 /// false, call PipeReader::isEoF() to determine if the pipe should be closed
86 ///
87 /// @param Buffer to be written to
88 /// @return string::size_type
89
90 bool readSource(std::vector<string> & lines);
91
92 //---------------------------------------------------------------------------------------
93 ///
94 /// isEof
95 ///
96 /// Description: returns true if the pipe has reached end of file. The caller should call
97 /// closePipe if this function returns true
98
99 virtual bool isSourceOpen();
100
101 protected:
102 FILE * m_File;
103
104 }; // end of class PipeReader
105
106 } // end of namespace System_
107
108
109
110 #endif /* end of PIPE_READER_H__ */