File: ram_filebuf.hpp

package info (click to toggle)
libsdsl 2.1.1%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,020 kB
  • sloc: cpp: 42,286; makefile: 1,171; ansic: 318; sh: 201; python: 27
file content (56 lines) | stat: -rw-r--r-- 1,263 bytes parent folder | download | duplicates (16)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef INCLUDED_SDSL_RAM_FSTREAMBUF
#define INCLUDED_SDSL_RAM_FSTREAMBUF

#include <fstream>
#include <vector>
#include "ram_fs.hpp"

namespace sdsl
{

class ram_filebuf : public std::streambuf
{
    private:
        ram_fs::content_type* m_ram_file = nullptr;  // file handle
        void pbump64(std::ptrdiff_t);

    public:
        virtual ~ram_filebuf();

        ram_filebuf();
        ram_filebuf(std::vector<char>& ram_file);

        std::streambuf*
        open(const std::string s, std::ios_base::openmode mode);

        bool is_open();

        ram_filebuf*
        close();

        pos_type
        seekpos(pos_type sp,
                std::ios_base::openmode which = std::ios_base::in | std::ios_base::out) override;

        pos_type
        pubseekoff(off_type off, std::ios_base::seekdir way,
                   std::ios_base::openmode which = std::ios_base::in | std::ios_base::out);

        pos_type
        pubseekpos(pos_type sp,
                   std::ios_base::openmode which = std::ios_base::in | std::ios_base::out);


//    std::streamsize
//    xsputn(const char_type* s, std::streamsize n) override;

        int
        sync() override;

        int_type
        overflow(int_type c = traits_type::eof()) override;
};

}

#endif