dlgConfiguration: remove polar panel
[xcsoar.git] / src / IO / LineSplitter.hpp
blobb76decb2d1171d170c88ef6bfa0f83b7082e2166
1 /*
2 Copyright_License {
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_LINE_SOURCE_HPP
25 #define XCSOAR_IO_LINE_SOURCE_HPP
27 #include "LineReader.hpp"
28 #include "Source.hpp"
29 #include "Util/ReusableArray.hpp"
31 #include <utility>
33 /**
34 * An adapter for a Source object which reads line-by-line. It is
35 * limited to narrow characters, but may work with multi-byte
36 * characters. It assumes that lines are delimited by a linefeed
37 * character, and deletes carriage returns.
39 * The maximum length of a line is limited by the buffer size of the
40 * Source object.
42 class LineSplitter : public NLineReader {
43 protected:
44 Source<char> &source;
46 /**
47 * The remaining range of the buffer returned by the Source.
49 Source<char>::Range remaining;
51 /** a buffer for guaranteeing that the last line is
52 null-terminated */
53 ReusableArray<char> last;
55 public:
56 LineSplitter(Source<char> &_source)
57 :source(_source), remaining((char *)NULL, 0) {}
59 /**
60 * Discards the buffer that holds the data after the last line.
61 * This can be used to implement Source::Rewind(): after rewinding
62 * the Source object, the LineSplitter must forget the buffer.
64 void ResetBuffer() {
65 remaining.length = 0;
68 /* virtual methods from class NLineReader */
69 virtual char *ReadLine() override;
70 virtual long GetSize() const override;
71 virtual long Tell() const override;
74 #endif