Loading...
Searching...
No Matches
line_stream.hpp
1/*---------------------------------------------------------------------------*\
2 *
3 * bitpit
4 *
5 * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6 *
7 * -------------------------------------------------------------------------
8 * License
9 * This file is part of bitpit.
10 *
11 * bitpit is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU Lesser General Public License v3 (LGPL)
13 * as published by the Free Software Foundation.
14 *
15 * bitpit is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with bitpit. If not, see <http://www.gnu.org/licenses/>.
22 *
23\*---------------------------------------------------------------------------*/
24
25#ifndef __BITPIT_LINE_STREAM_HPP__
26#define __BITPIT_LINE_STREAM_HPP__
27
28#include <vector>
29#include <string>
30#include <fstream>
31#include <iostream>
32
33namespace bitpit {
34
35class LineBuffer : public std::streambuf {
36
37public:
38 int readLine(std::ifstream &fileHandle);
39 void copyLine(std::string *line) const;
40
41protected:
42 LineBuffer();
43
44private:
45 static const int CHUNK_SIZE = 1024;
46
47 std::vector<char> m_buffer;
48
49};
50
51class LineStream : protected LineBuffer, public std::istream {
52
53public:
54 LineStream();
55
56 int readLine(std::ifstream &fileHandle);
57
59
60};
61
62}
63
64#endif
LineBuffer defines a buffer for reading lines.
int readLine(std::ifstream &fileHandle)
void copyLine(std::string *line) const
LineStream defines a stream for reading lines.
int readLine(std::ifstream &fileHandle)
--- layout: doxygen_footer ---