~reviczky/luatex/texlive-bin-git

« back to all changes in this revision

Viewing changes to texk/dvisvgm/dvisvgm-1.8.1/src/VectorStream.h

  • Committer: Adam Reviczky
  • Date: 2015-04-26 22:40:47 UTC
  • Revision ID: adam.reviczky@kclalumni.net-20150426224047-i2p26n3wqphupq6z
TeX Live 2015 import (rev. 37052)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*************************************************************************
2
 
** VectorStream.h                                                       **
3
 
**                                                                      **
4
 
** This file is part of dvisvgm -- the DVI to SVG converter             **
5
 
** Copyright (C) 2005-2014 Martin Gieseking <martin.gieseking@uos.de>   **
6
 
**                                                                      **
7
 
** This program is free software; you can redistribute it and/or        **
8
 
** modify it under the terms of the GNU General Public License as       **
9
 
** published by the Free Software Foundation; either version 3 of       **
10
 
** the License, or (at your option) any later version.                  **
11
 
**                                                                      **
12
 
** This program is distributed in the hope that it will be useful, but  **
13
 
** WITHOUT ANY WARRANTY; without even the implied warranty of           **
14
 
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the         **
15
 
** GNU General Public License for more details.                         **
16
 
**                                                                      **
17
 
** You should have received a copy of the GNU General Public License    **
18
 
** along with this program; if not, see <http://www.gnu.org/licenses/>. **
19
 
*************************************************************************/
20
 
 
21
 
#ifndef DVISVGM_VECTORSTREAM_H
22
 
#define DVISVGM_VECTORSTREAM_H
23
 
 
24
 
#include <istream>
25
 
#include <vector>
26
 
 
27
 
 
28
 
template <typename T>
29
 
struct VectorStreamBuffer : public std::streambuf
30
 
{
31
 
        VectorStreamBuffer (std::vector<T> &source) {
32
 
                setg((char*)&source[0], (char*)&source[0], (char*)&source[0]+source.size());
33
 
        }
34
 
};
35
 
 
36
 
 
37
 
template <typename T>
38
 
class VectorInputStream : public std::istream
39
 
{
40
 
        public:
41
 
                VectorInputStream (std::vector<T> &source) : std::istream(&_buf), _buf(source) {}
42
 
        private:
43
 
                VectorStreamBuffer<T> _buf;
44
 
};
45
 
 
46
 
#endif