]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/memory-stream.hh
Run grand-replace (issue 3765)
[lilypond.git] / flower / include / memory-stream.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2005--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef MEMORY_STREAM_HH
21 #define MEMORY_STREAM_HH
22
23 #include <cstdio>
24 #include <unistd.h>
25 using namespace std;
26
27 #include "libc-extension.hh"
28 #include "file-cookie.hh"
29
30 class Memory_out_stream
31 {
32   char *buffer_;
33   ssize_t size_;
34   int buffer_blocks_;
35   FILE *file_;
36
37   static lily_cookie_io_functions_t functions_;
38   static const int block_size_;
39
40 public:
41   static ssize_t reader (void *, char *, size_t);
42   static ssize_t writer (void *, char const *, size_t);
43   static ssize_t seeker (void *, off64_t *, size_t);
44   static ssize_t cleaner (void *);
45
46   Memory_out_stream ();
47   ~Memory_out_stream ();
48   FILE *get_file () const;
49   char const *get_string () const;
50   ssize_t get_length () const;
51 };
52
53 #endif /* MEMORY_STREAM_HH */