Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXParseBuffer.h
1 /********************************************************************************
2 * *
3 * P a r s e - B u f f e r *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2013,2022 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXPARSEBUFFER_H
22 #define FXPARSEBUFFER_H
23 
24 namespace FX {
25 
26 
34 class FXAPI FXParseBuffer {
35 public:
36  enum Direction {
37  Stop = 0,
38  Save = 1,
39  Load = 2
40  };
41 protected:
42  FXchar *begptr; // Begin of buffer
43  FXchar *endptr; // End of buffer
44  FXchar *wptr; // Write pointer
45  FXchar *rptr; // Read pointer
46  FXchar *sptr; // Scan pointer
47  Direction dir; // Direction
48 protected:
49  FXbool need(FXival count);
50  FXbool emit(FXchar ch,FXint count);
51  FXbool emit(const FXchar* str,FXint count);
52 private:
54  FXParseBuffer &operator=(const FXParseBuffer&);
55 public:
56 
60  FXParseBuffer();
61 
68  FXParseBuffer(FXchar* buffer,FXuval sz=4096,Direction d=Load);
69 
71  FXbool open(FXchar* buffer=nullptr,FXuval sz=4096,Direction d=Load);
72 
74  Direction direction() const { return dir; }
75 
77  FXuval size() const { return endptr-begptr; }
78 
80  virtual FXival fill(FXival count);
81 
83  virtual FXival flush(FXival count);
84 
86  FXbool close();
87 
89  virtual ~FXParseBuffer();
90  };
91 
92 }
93 
94 #endif
Direction direction() const
Return current direction.
Definition: FXParseBuffer.h:74
Direction
Definition: FXParseBuffer.h:36
Definition: FX4Splitter.h:28
FXParseBuffer manages pointers to a buffer for various file format parsers.
Definition: FXParseBuffer.h:34
FXuval size() const
Return current buffer size.
Definition: FXParseBuffer.h:77

Copyright © 1997-2022 Jeroen van der Zijp