Major redesign. All input is handled through XML. Raw input data is first
[gnucomo.git] / src / gcm_input / message_buffer.h
1
2 /**************************************************************************
3 **  (c) Copyright 2002, Andromeda Technology & Automation
4 ** This is free software; you can redistribute it and/or modify it under the
5 ** terms of the GNU General Public License, see the file COPYING.
6 ***************************************************************************
7 ** MODULE INFORMATION *
8 ***********************
9 **      FILE NAME      : message_buffer.h
10 **      SYSTEM NAME    : 
11 **      VERSION NUMBER : $Revision: 1.1 $
12 **
13 **  DESCRIPTION      :  Classes to for buffering the input stream
14 **
15 **  EXPORTED OBJECTS : 
16 **  LOCAL    OBJECTS : 
17 **  MODULES  USED    :
18 ***************************************************************************
19 **  ADMINISTRATIVE INFORMATION *
20 ********************************
21 **      ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
22 **      CREATION DATE   : Sep 16, 2002
23 **      LAST UPDATE     : Aug 06, 2003
24 **      MODIFICATIONS   : 
25 **************************************************************************/
26
27 /*****************************
28    $Log: message_buffer.h,v $
29    Revision 1.1  2003-12-04 10:38:09  arjen
30    Major redesign. All input is handled through XML. Raw input data is first
31    transformed into an XML document for further processing.
32    A collection of polymorphic classes handle the transformation of various
33    input formats into XML.
34    Classifying input data is done with a finite improbability calculation.
35
36 *****************************/
37
38 /* static const char *RCSID = "$Id: message_buffer.h,v 1.1 2003-12-04 10:38:09 arjen Exp $"; */
39
40 #include <iostream>
41 #include <list>
42 #include <AXE/String.h>
43
44
45 /*
46 ///////////////////////////////////////////////////////////////////////////
47 //  NAME           : message_buffer
48 //  BASECLASS      : 
49 //  MEMBERS        :
50 //  OPERATORS      :
51 //  METHODS        : from()
52 //                   rewind()
53 //
54 //  DESCRIPTION    : 
55 //
56 //  RELATIONS      :
57 //  SEE ALSO       :
58 //  LAST MODIFIED  : Nov 04, 2002
59 ///////////////////////////////////////////////////////////////////////////
60 */
61
62 class message_buffer
63 {
64    std::istream       *input;
65    std::list<String>  buffer;
66
67    std::list<String>::iterator   next_line;
68
69 public:
70
71    message_buffer()
72    {
73       input = 0;
74       next_line = buffer.begin();
75    }
76
77    message_buffer(std::istream *in)
78    {
79       input = in;
80       next_line = buffer.begin();
81    }
82
83    void from(std::istream *in)
84    {
85       input = in;
86    }
87
88    friend bool operator >> (message_buffer &, String &);
89
90    void rewind()
91    {
92       next_line = buffer.begin();
93    }
94
95    void operator ++()
96    {
97       if (next_line != buffer.end())
98       {
99          next_line++;
100       }
101    }
102
103    void operator --()
104    {
105       if (next_line != buffer.begin())
106       {
107          next_line--;
108       }
109    }
110 };
111