ZorbaStreamBuffer.h
Go to the documentation of this file.
1 /*
2  * Copyright 2006-2012 The FLWOR Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #ifndef API_ZORBA_STREAM_BUFFER_H
20 #define API_ZORBA_STREAM_BUFFER_H
21 
22 #include <streambuf>
23 #include <cstdio>
24 #include <cstdlib>
25 #include <vector>
26 #include "ZorbaStreamBuffer.h"
27 
28 
30  public std::streambuf
31 {
32 public:
33  ZorbaStreamBuffer(ZorbaIOStream &aStreamWrapper): bBegin(0), bEnd(0), bCurrent(0), buffer(0), streamWrapper(&aStreamWrapper) {};
34  virtual ~ZorbaStreamBuffer() {};
35 
36  // HELPER
37  // Function to return EOF character from other languages
38  static int getEOF();
39 
40  // INPUT
41  // Get character in the case of underflow
42  int underflow();
43  // Get character in the case of underflow and advance get pointer
44  int uflow();
45  // Put character back in the case of backup underflow
46  int pbackfail(int ch);
47  // Get number of characters available in the sequence
48  std::streamsize showmanyc();
49 
50  // OUTPUT
51  // Write sequence of characters <Inherited>
52  virtual std::streamsize xsputn ( const char * BYTE, std::streamsize len );
53  // Write character in the case of overflow
54  virtual int overflow ( int c = EOF );
55 
56 
57 
58 
59 private:
60  void checkBuffer();
61  // Copy contructor and assignment not allowed
63  ZorbaStreamBuffer &operator= (const ZorbaStreamBuffer &);
64 
65  //BUFFER
66  char * buffer;
67  char * bBegin;
68  char * bEnd;
69  char * bCurrent;
70  ZorbaIOStream *streamWrapper;
71 
72  char * cBuffer;
73 };
74 
75 #endif
ZorbaStreamBuffer(ZorbaIOStream &aStreamWrapper)
virtual int overflow(int c=EOF)
static int getEOF()
virtual std::streamsize xsputn(const char *BYTE, std::streamsize len)
virtual ~ZorbaStreamBuffer()
int pbackfail(int ch)
std::streamsize showmanyc()