-
Notifications
You must be signed in to change notification settings - Fork 0
/
source.h
47 lines (39 loc) · 933 Bytes
/
source.h
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
// Copyright (c) Mathieu Malaterre
// SPDX-License-Identifier: BSD-3-Clause
#pragma once
#include <cstdint>
#include <cstdio>
#include <string>
#include <vector>
namespace jlst {
class source
{
public:
source();
source(std::string const& filename);
~source();
int peek();
void rewind();
size_t read(void* ptr, size_t n);
std::string getline();
size_t size();
const std::string& get_filename() const
{
return filename_;
}
std::vector<uint8_t> read_bytes();
source(source&& s)
{
stream_ = s.stream_;
filename_ = s.filename_;
s.stream_ = nullptr;
s.filename_ = "";
}
private:
source(const source& s); // Copy constructor
source& operator=(const source& s); // Assignment operator
source& operator=(source&& s); // move assignement
FILE* stream_;
std::string filename_;
};
} // namespace jlst