Debian Codegraph @

include/mps/private/system/abstract-input-stream.h

raw
1 /*
2 * This file is part of MPSolve 3.2.2
3 *
4 * Copyright (C) 2001-2020, Dipartimento di Matematica "L. Tonelli", Pisa.
5 * License: http://www.gnu.org/licenses/gpl.html GPL version 3 or higher
6 *
7 * Authors:
8 * Leonardo Robol <[email protected]>
9 */
10
11 /**
12 * @file
13 * @brief Abstract input stream used to parse files.
14 *
15 * The implementation is C++ but C API is provided.
16 */
17
18 #ifndef MPS_ABSTRACT_INPUT_STREAM_H_
19 #define MPS_ABSTRACT_INPUT_STREAM_H_
20
21 /* C compatibility layer */
22 MPS_BEGIN_DECLS
23 /**
24 * @brief This is a C wrapper around the C++ implementation of
25 * {@link AbstractInputStream}.
26 */
27 struct mps_abstract_input_stream;
28
29 /**
30 * @brief C wrapper around {@link AbstractInputStream}.
31 */
32 typedef struct mps_abstract_input_stream mps_abstract_input_stream;
33
34 /**
35 * @brief Wrapper around {@link AbstractInputStream::readline()}.
36 */
37 size_t mps_abstract_input_stream_readline (mps_abstract_input_stream * stream,
38 char ** buffer, size_t * length);
39
40 /**
41 * @brief Wrapper around {@link AbstractInputStream::eof()}.
42 */
43 mps_boolean mps_abstract_input_stream_eof (mps_abstract_input_stream * stream);
44
45 /**
46 * @brief Wrapper around {@link AbstractInputStream::getchar()}.
47 */
48 int mps_abstract_input_stream_getchar (mps_abstract_input_stream * stream);
49
50 MPS_END_DECLS
51
52 /* The following is C++ only */
53 #ifdef __cplusplus
54
55 namespace mps {
56 /**
57 * @brief Abstract class that represent a generic input stream that can
58 * be used by MPSolve to read polynomial files and/or descriptions.
59 *
60 * @seealso {@link MemoryFileStream}, {@link FileInputStream}
61 */
62 class AbstractInputStream {
63 public:
64
65 virtual ~AbstractInputStream() = 0;
66
67 /**
68 * @brief Return a new line of the stream or NULL if we are at
69 * the end.
70 *
71 * @return A pointer to a newly allocated line or NULL.
72 */
73 virtual size_t readline (char ** buffer, size_t * length) = 0;
74
75 /**
76 * @brief Check if we are at the end of the stream.
77 *
78 * @return true if we are at the end of the stream.
79 */
80 virtual bool eof () = 0;
81
82 /**
83 * @brief Obtain a single character.
84 *
85 * @return A new character read from the stream.
86 */
87 virtual int getchar () = 0;
88 };
89 }
90
91 #endif /* __cplusplus */
92
93 #endif /* MPS_ABSTRACT_INPUT_STREAM_H_ */