4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program 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 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #ifndef XCSOAR_IO_SOURCE_HPP
25 #define XCSOAR_IO_SOURCE_HPP
32 * A data source. This object provides a buffer, which may be
33 * modified in-place by the caller, to do zero-copy parsing.
39 * A portion of this object's buffer. The first item is the start
40 * of the buffer, and the second item is the number of available
51 Range(T
*_data
, unsigned _length
):data(_data
), length(_length
) {}
54 bool IsEmpty() const {
63 * Returns words from this source. After you have used them, call
64 * the method consume(). This method Invalidates any range returned
67 * This object will always return as many words as possible; calling
68 * read() subsequently (without consume()) will not get you more
69 * data. An empty range marks the end of the stream.
71 virtual Range
Read() = 0;
74 * Marks words as "consumed". The buffer returned by read() is not
75 * yet Invalidated, and may be used until the next read() call is
78 virtual void Consume(unsigned n
) = 0;
81 * Determins the size of the file. Returns -1 if the size is
85 virtual long GetSize() const {
90 * Determins the current position within the file. Returns -1 if
94 virtual long Tell() const {