MCPcopy Create free account
hub / github.com/RobLoach/raylib-cpp / FileText

Class FileText

include/FileText.hpp:12–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10namespace raylib {
11
12class FileText {
13public:
14 FileText() = default;
15 FileText(const FileText&) = delete;
16 FileText(FileText&& other) noexcept : data(other.data), length(other.length) {
17 other.data = nullptr;
18 other.length = 0;
19 }
20 FileText& operator=(const FileText&) = delete;
21 FileText& operator=(FileText&& other) noexcept {
22 std::swap(data, other.data);
23 std::swap(length, other.length);
24 return *this;
25 }
26 ~FileText() { Unload(); }
27
28 explicit FileText(const std::string& fileName) { Load(fileName); }
29
30 GETTER(const char*, Data, data)
31 GETTER(unsigned int, Length, length)
32
33 RLCPP_NODISCARD const char* c_str() const { return data; }
34
35 RLCPP_NODISCARD std::string ToString() const { return data; }
36 explicit operator std::string() const { return data; }
37
38 void Load(const std::string& fileName) { Load(fileName.c_str()); }
39 void Load(const char* fileName) {
40 data = ::LoadFileText(fileName);
41 length = ::TextLength(data);
42 }
43
44 void Unload() {
45 if (data != nullptr) {
46 ::UnloadFileText(data);
47 data = nullptr;
48 length = 0;
49 }
50 }
51private:
52 char* data{nullptr};
53 unsigned int length{0};
54};
55
56} // namespace raylib
57

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected