~ubuntu-branches/ubuntu/wily/afnix/wily

« back to all changes in this revision

Viewing changes to src/lib/std/shl/obj/Input.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Anibal Monsalve Salazar
  • Date: 2011-03-16 21:31:18 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110316213118-gk4k3ez3e5d2huna
Tags: 2.0.0-1
* QA upload.
* New upstream release
* Debian source format is 3.0 (quilt)
* Fix debhelper-but-no-misc-depends
* Fix ancient-standards-version
* Fix package-contains-linda-override
* debhelper compatibility is 7
* Fix dh-clean-k-is-deprecated

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// ---------------------------------------------------------------------------
2
 
// - Input.hpp                                                               -
3
 
// - standard object library - input stream base class definition            -
4
 
// ---------------------------------------------------------------------------
5
 
// - This program is free software;  you can redistribute it  and/or  modify -
6
 
// - it provided that this copyright notice is kept intact.                  -
7
 
// -                                                                         -
8
 
// - This program  is  distributed in  the hope  that it will be useful, but -
9
 
// - without  any  warranty;  without  even   the   implied    warranty   of -
10
 
// - merchantability or fitness for a particular purpose.  In no event shall -
11
 
// - the copyright holder be liable for any  direct, indirect, incidental or -
12
 
// - special damages arising in any way out of the use of this software.     -
13
 
// ---------------------------------------------------------------------------
14
 
// - copyright (c) 1999-2007 amaury darsch                                   -
15
 
// ---------------------------------------------------------------------------
16
 
 
17
 
#ifndef  AFNIX_INPUT_HPP
18
 
#define  AFNIX_INPUT_HPP
19
 
 
20
 
#ifndef  AFNIX_STREAM_HPP
21
 
#include "Stream.hpp"
22
 
#endif
23
 
 
24
 
#ifndef  AFNIX_BUFFER_HPP
25
 
#include "Buffer.hpp"
26
 
#endif
27
 
 
28
 
namespace afnix {
29
 
 
30
 
  /// The input stream class is a base class which provides a read method for
31
 
  /// character in a generic way. Various classes are derived from it, like 
32
 
  /// the InputTerm or InputFile. The class implements a buffer which provides
33
 
  /// a generic pushback method. When the read method is invoked, the character
34
 
  /// is placed in the buffer.
35
 
  /// @author amaury darsch
36
 
 
37
 
  class Input : public Stream {
38
 
  protected:
39
 
    /// the local buffer
40
 
    mutable Buffer d_buffer;
41
 
 
42
 
  public:
43
 
    /// @return the stream descriptor
44
 
    virtual int getsid (void) const;
45
 
 
46
 
    /// @return the next available character
47
 
    virtual char read (void) =0;
48
 
 
49
 
    /// @return the next character in byte mode
50
 
    virtual t_quad rbyte (void);
51
 
 
52
 
    /// @return the next character in utf8 mode
53
 
    virtual t_quad rutf8 (void);
54
 
 
55
 
    /// @return the next available unicode character
56
 
    virtual t_quad rduc (void);
57
 
 
58
 
    /// @return a buffer of character
59
 
    /// @param size the number of character to read
60
 
    virtual Buffer* read (const long size);
61
 
 
62
 
    /// @return the next available line
63
 
    virtual String readln (void);
64
 
 
65
 
    /// @return true if we are at the eof
66
 
    virtual bool iseof (void) const =0;
67
 
 
68
 
    /// check if we can read a character
69
 
    /// @param tout the timeout value
70
 
    virtual bool valid (const long tout) const =0;
71
 
 
72
 
    /// push back a character in the input stream.
73
 
    /// @param value the character to push back
74
 
    virtual void pushback (const char value);
75
 
 
76
 
    /// pushback a c-string
77
 
    /// @param s the string to pushback
78
 
    virtual void pushback (const char* s);
79
 
 
80
 
    /// pushback a c-string by size
81
 
    /// @param s    the string to pushback
82
 
    /// @param size the string size
83
 
    virtual void pushback (const char* s, const long size);
84
 
 
85
 
    /// pushback a string on this input stream
86
 
    virtual void pushback (const String& value);
87
 
 
88
 
    /// @return the size of the input buffer
89
 
    virtual long buflen (void) const;
90
 
 
91
 
    /// flush the input stream until a certain character is found
92
 
    /// @param value the blocking character
93
 
    virtual void flush (const char value);
94
 
 
95
 
    /// flush the input stream until a certain character is found
96
 
    /// @param value the blocking character
97
 
    virtual void flush (const t_quad value);
98
 
 
99
 
  public:
100
 
    /// @return true if the given quark is defined
101
 
    bool isquark (const long quark, const bool hflg) const;
102
 
 
103
 
    /// apply this object with a set of arguments and a quark
104
 
    /// @param robj  the current runnable
105
 
    /// @param nset  the current nameset    
106
 
    /// @param quark the quark to apply these arguments
107
 
    /// @param argv  the arguments  to apply
108
 
    Object* apply (Runnable* robj, Nameset* nset, const long quark,
109
 
                   Vector* argv);
110
 
  };
111
 
}
112
 
 
113
 
#endif