CorsixTH engine (the C++ part)
Open source implementation of Theme Hospital
Loading...
Searching...
No Matches
th.h
Go to the documentation of this file.
1/*
2Copyright (c) 2009 Peter "Corsix" Cawley
3
4Permission is hereby granted, free of charge, to any person obtaining a copy of
5this software and associated documentation files (the "Software"), to deal in
6the Software without restriction, including without limitation the rights to
7use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8of the Software, and to permit persons to whom the Software is furnished to do
9so, subject to the following conditions:
10
11The above copyright notice and this permission notice shall be included in all
12copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20SOFTWARE.
21*/
22
23#ifndef CORSIX_TH_TH_H_
24#define CORSIX_TH_TH_H_
25#include "config.h"
26
27#include <vector>
28
30class link_list {
31 public:
33 virtual ~link_list();
34
35 link_list* prev{nullptr};
36 link_list* next{nullptr};
37
38 void remove_from_list();
39};
40
45 public:
53 th_string_list(const uint8_t* data, size_t length);
54
55 // Delete default constructors and assignment operators. They
56 // can be implemented properly later if they are needed but
57 // for now they are unneeded so it is safer to remove them.
58 th_string_list() = delete;
63 ~th_string_list() = default;
64
66 size_t get_section_count() const;
67
69 size_t get_section_size(size_t section) const;
70
72
78 const char* get_string(size_t section, size_t index) const;
79
80 private:
82 std::vector<std::vector<const char*>> sections;
83
85 std::vector<uint8_t> string_buffer;
86};
87
95inline uint32_t bytes_to_uint32_le(const uint8_t* bytes) {
96 uint32_t res = bytes[3];
97 res <<= 8;
98 res |= bytes[2];
99 res <<= 8;
100 res |= bytes[1];
101 res <<= 8;
102 res |= bytes[0];
103
104 return res;
105}
106
114inline uint16_t bytes_to_uint16_le(const uint8_t* bytes) {
115 uint16_t res = bytes[1];
116 res <<= 8;
117 res |= bytes[0];
118
119 return res;
120}
121
122#endif // CORSIX_TH_TH_H_
Theme Hospital localised string list.
Definition th.h:44
th_string_list()=delete
size_t get_section_size(size_t section) const
Get the number of strings in a section of the string list.
Definition th.cpp:223
size_t get_section_count() const
Get the number of sections in the string list.
Definition th.cpp:221
th_string_list && operator=(th_string_list &&)=delete
~th_string_list()=default
th_string_list(const th_string_list &)=delete
const char * get_string(size_t section, size_t index) const
Get a string from the string list.
Definition th.cpp:227
th_string_list & operator=(const th_string_list &)=delete
th_string_list(th_string_list &&)=delete
uint16_t bytes_to_uint16_le(const uint8_t *bytes)
Definition th.h:114
uint32_t bytes_to_uint32_le(const uint8_t *bytes)
Definition th.h:95