Tramway SDK
file.h
Go to the documentation of this file.
1// TRAMWAY DRIFT AND DUNGEON EXPLORATION SIMULATOR 2022
2// All rights reserved.
3
4#ifndef TRAM_SDK_FRAMEWORK_FILE_H
5#define TRAM_SDK_FRAMEWORK_FILE_H
6
7#include <string>
8
9#include <framework/core.h>
10#include <framework/uid.h>
11
12namespace tram {
13
14enum FileAccessMode : uint32_t {
18};
19
20class FileReader;
21class FileWriter;
22
23class File {
24public:
25 File (char const* path, uint32_t mode);
26 ~File();
27
28 bool is_open();
29 bool is_continue();
30
31 void write_int8(int8_t value);
32 void write_int16(int16_t value);
33 void write_int32(int32_t value);
34 void write_int64(int64_t value);
35
36 void write_uint8(uint8_t value);
37 void write_uint16(uint16_t value);
38 void write_uint32(uint32_t value);
39 void write_uint64(uint64_t value);
40
41 void write_float32(float value);
42 void write_float64(double value);
43
44 void write_name(name_t value);
45 void write_string(const char* value);
46 void write_newline();
47
48 int8_t read_int8();
49 int16_t read_int16();
50 int32_t read_int32();
51 int64_t read_int64();
52
53 uint8_t read_uint8();
54 uint16_t read_uint16();
55 uint32_t read_uint32();
56 uint64_t read_uint64();
57
58 float read_float32();
59 double read_float64();
60
62 std::string_view read_string();
63 std::string_view read_line();
64
65 void skip_linebreak();
66 void reset_flags();
67
68 std::string path;
69 uint32_t mode;
70
72
73 // cursors for writing
74 char* buffer = nullptr;
75 char* buffer_cursor = nullptr;
76 char* buffer_end = nullptr;
77
78 // cursors for reading
79 const char* cursor = nullptr;
80 const char* cursor_end = nullptr;
81
84};
85
86}
87
88#endif // TRAM_SDK_FRAMEWORK_FILE_H
Definition: file.h:23
int8_t read_int8()
Definition: file.cpp:209
const char * cursor
Definition: file.h:79
uint32_t read_uint32()
Definition: file.cpp:216
int32_t read_int32()
Definition: file.cpp:211
void write_int64(int64_t value)
Definition: file.cpp:195
bool is_open()
Definition: file.cpp:168
std::string_view read_string()
Definition: file.cpp:223
std::string path
Definition: file.h:68
void write_name(name_t value)
Definition: file.cpp:205
uint64_t read_uint64()
Definition: file.cpp:217
float read_float32()
Definition: file.cpp:219
char * buffer
Definition: file.h:74
uint8_t read_uint8()
Definition: file.cpp:214
void write_float64(double value)
Definition: file.cpp:203
void write_int16(int16_t value)
Definition: file.cpp:193
~File()
Definition: file.cpp:155
bool pause_next
Definition: file.h:71
void reset_flags()
Definition: file.cpp:228
int16_t read_int16()
Definition: file.cpp:210
char * buffer_end
Definition: file.h:76
bool is_continue()
Definition: file.cpp:180
uint16_t read_uint16()
Definition: file.cpp:215
void write_newline()
Definition: file.cpp:207
void write_int8(int8_t value)
Definition: file.cpp:192
void write_int32(int32_t value)
Definition: file.cpp:194
void write_uint32(uint32_t value)
Definition: file.cpp:199
FileWriter * disk_writer
Definition: file.h:83
char * buffer_cursor
Definition: file.h:75
std::string_view read_line()
Definition: file.cpp:224
void write_uint16(uint16_t value)
Definition: file.cpp:198
File(char const *path, uint32_t mode)
Definition: file.cpp:130
FileReader * disk_reader
Definition: file.h:82
void skip_linebreak()
Definition: file.cpp:226
void write_uint64(uint64_t value)
Definition: file.cpp:200
double read_float64()
Definition: file.cpp:220
void write_uint8(uint8_t value)
Definition: file.cpp:197
name_t read_name()
Definition: file.cpp:222
void write_string(const char *value)
Definition: file.cpp:206
uint32_t mode
Definition: file.h:69
void write_float32(float value)
Definition: file.cpp:202
const char * cursor_end
Definition: file.h:80
int64_t read_int64()
Definition: file.cpp:212
Definition: file.h:16
Definition: file.h:27
Definition: api.h:9
FileAccessMode
Definition: file.h:14
@ MODE_WRITE
Definition: file.h:16
@ MODE_PAUSE_LINE
Definition: file.h:17
@ MODE_READ
Definition: file.h:15
Definition: uid.h:11