1 /*
2  * BasicTextualInputPort.h -
3  *
4  *   Copyright (c) 2008  Higepon(Taro Minowa)  <higepon@users.sourceforge.jp>
5  *
6  *   Redistribution and use in source and binary forms, with or without
7  *   modification, are permitted provided that the following conditions
8  *   are met:
9  *
10  *   1. Redistributions of source code must retain the above copyright
11  *      notice, this list of conditions and the following disclaimer.
12  *
13  *   2. Redistributions in binary form must reproduce the above copyright
14  *      notice, this list of conditions and the following disclaimer in the
15  *      documentation and/or other materials provided with the distribution.
16  *
17  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
23  *   TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24  *   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25  *   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26  *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27  *   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  *
29  *  $Id: BasicTextualInputPort.h 261 2008-07-25 06:16:44Z higepon $
30  */
31 
32 #ifndef SCHEME_TEXTUAL_INPUT_PORT_
33 #define SCHEME_TEXTUAL_INPUT_PORT_
34 
35 #include "Port.h"
36 
37 namespace scheme {
38 
39 class Codec;
40 class Transcoder;
41 class BinaryInputPort;
42 class Scanner;
43 class NumberScanner;
44 
45 class TextualInputPort : virtual public Port
46 {
47 public:
48     TextualInputPort();
49     virtual ~TextualInputPort();
50 
51     virtual ucs4char getChar() = 0;
52     virtual int getLineNo() const = 0;
53     virtual void unGetChar(ucs4char c) = 0;
54     virtual Transcoder* transcoder() const = 0;
55 
56     // template method pattern
57     virtual ucs4string getString(int n);
58     virtual ucs4string getStringAll();
59     virtual ucs4char lookaheadChar();
60     virtual Object getLine();
61     virtual void setError(Object error);
62     virtual Object error() const;
63     virtual Object getDatum(bool& errorOccured);
64     virtual Scanner* scanner() const;
65     virtual NumberScanner* numberScanner() const;
66     virtual bool hasPosition() const;
67     virtual bool hasSetPosition() const;
68     virtual Object position() const;
69     virtual bool setPosition(int64_t position);
70 
71     bool isStrictR6RsReaderMode() const;
72     void setStrictR6RsReaderMode();
73 
74 private:
75     Object error_;
76     Scanner* scanner_;
77     NumberScanner* numberScanner_;
78     bool isStrictR6RsReaderMode_;
79 };
80 
81 } // namespace scheme
82 
83 #endif // SCHEME_TEXTUAL_INPUT_PORT_
84