samp_sdk/omp/generated/config.rs
1//! `IConfig` — generated by `cargo xtask gen-omp` from `core.hpp`.
2//! Implemented by `Config` in the server's `omp-server`.
3//!
4//! Do not edit: change `xtask/omp-wrappers.toml` or the generator and
5//! regenerate. Slots are clang's layout of the header for each ABI, checked
6//! against the official binaries by `cargo xtask check-abi --generated`.
7
8#![allow(unused_imports)]
9
10use crate::omp::containers::{FlatSet, HybridString, Pair, Span};
11use crate::omp::types::{
12 Colour, GTAQuat, Hours, Microseconds, Milliseconds, Minutes, Seconds, StringView, TimePoint,
13 UID, Vector2, Vector3, Vector4, WorldTimePoint,
14};
15use crate::omp::vtable::{call_vtable_small_struct, opaque, slots, virtual_fns};
16use crate::omp::*;
17
18opaque! {
19 /// Opaque handle for `IConfig*`.
20 pub IConfig;
21}
22
23slots! {
24 /// `const StringView IConfig::getString(StringView)`
25 SLOT_GET_STRING: usize = 6, 5;
26 /// `int * IConfig::getInt(StringView)`
27 SLOT_GET_INT: usize = 7, 6;
28 /// `float * IConfig::getFloat(StringView)`
29 SLOT_GET_FLOAT: usize = 8, 7;
30 /// `size_t IConfig::getStrings(StringView, Span<StringView>)`
31 SLOT_GET_STRINGS: usize = 9, 8;
32 /// `size_t IConfig::getStringsCount(StringView)`
33 SLOT_GET_STRINGS_COUNT: usize = 10, 9;
34 /// `ConfigOptionType IConfig::getType(StringView)`
35 SLOT_GET_TYPE: usize = 11, 10;
36 /// `size_t IConfig::getBansCount()`
37 SLOT_GET_BANS_COUNT: usize = 12, 11;
38 /// `const BanEntry & IConfig::getBan(size_t)`
39 SLOT_GET_BAN: usize = 13, 12;
40 /// `void IConfig::addBan(const BanEntry &)`
41 SLOT_ADD_BAN: usize = 14, 13;
42 /// `void IConfig::removeBan(size_t)`
43 SLOT_REMOVE_BAN_AT: usize = 15, 15;
44 /// `void IConfig::removeBan(const BanEntry &)`
45 SLOT_REMOVE_BAN: usize = 16, 14;
46 /// `void IConfig::writeBans()`
47 SLOT_WRITE_BANS: usize = 17, 16;
48 /// `void IConfig::reloadBans()`
49 SLOT_RELOAD_BANS: usize = 18, 17;
50 /// `void IConfig::clearBans()`
51 SLOT_CLEAR_BANS: usize = 19, 18;
52 /// `bool IConfig::isBanned(const BanEntry &)`
53 SLOT_IS_BANNED: usize = 20, 19;
54 /// `Pair<bool, StringView> IConfig::getNameFromAlias(StringView)`
55 SLOT_GET_NAME_FROM_ALIAS: usize = 21, 20;
56 /// `void IConfig::enumOptions(OptionEnumeratorCallback &)`
57 SLOT_ENUM_OPTIONS: usize = 22, 21;
58 /// `bool * IConfig::getBool(StringView)`
59 SLOT_GET_BOOL: usize = 23, 22;
60}
61
62virtual_fns! {
63 /// `int * IConfig::getInt(StringView)`.
64 ///
65 /// # Safety
66 /// `config` must be a live `IConfig`.
67 #[must_use]
68 pub fn config_int(
69 config: IConfig,
70 key: StringView,
71 ) -> *mut i32 = [0, SLOT_GET_INT] or std::ptr::null_mut();
72
73 /// `float * IConfig::getFloat(StringView)`.
74 ///
75 /// # Safety
76 /// `config` must be a live `IConfig`.
77 #[must_use]
78 pub fn config_float(
79 config: IConfig,
80 key: StringView,
81 ) -> *mut f32 = [0, SLOT_GET_FLOAT] or std::ptr::null_mut();
82
83 /// `size_t IConfig::getStrings(StringView, Span<StringView>)`.
84 ///
85 /// # Safety
86 /// `config` must be a live `IConfig`.
87 #[must_use]
88 pub fn config_strings(
89 config: IConfig,
90 key: StringView,
91 output: Span<StringView>,
92 ) -> usize = [0, SLOT_GET_STRINGS] or 0;
93
94 /// `size_t IConfig::getStringsCount(StringView)`.
95 ///
96 /// # Safety
97 /// `config` must be a live `IConfig`.
98 #[must_use]
99 pub fn config_strings_count(
100 config: IConfig,
101 key: StringView,
102 ) -> usize = [0, SLOT_GET_STRINGS_COUNT] or 0;
103
104 /// `ConfigOptionType IConfig::getType(StringView)`.
105 ///
106 /// # Safety
107 /// `config` must be a live `IConfig`.
108 #[must_use]
109 pub fn config_type(config: IConfig, key: StringView) -> i32 = [0, SLOT_GET_TYPE] or 0;
110
111 /// `size_t IConfig::getBansCount()`.
112 ///
113 /// # Safety
114 /// `config` must be a live `IConfig`.
115 #[must_use]
116 pub fn config_bans_count(config: IConfig) -> usize = [0, SLOT_GET_BANS_COUNT] or 0;
117
118 /// `const BanEntry & IConfig::getBan(size_t)`.
119 ///
120 /// # Safety
121 /// `config` must be a live `IConfig`.
122 #[must_use]
123 pub fn config_ban(
124 config: IConfig,
125 index: usize,
126 ) -> *const BanEntry = [0, SLOT_GET_BAN] or std::ptr::null();
127
128 /// `void IConfig::addBan(const BanEntry &)`.
129 ///
130 /// # Safety
131 /// `config` must be a live `IConfig`.
132 pub fn config_add_ban(config: IConfig, entry: &BanEntry) = [0, SLOT_ADD_BAN];
133
134 /// `void IConfig::removeBan(size_t)`.
135 ///
136 /// # Safety
137 /// `config` must be a live `IConfig`.
138 pub fn config_remove_ban_at(config: IConfig, index: usize) = [0, SLOT_REMOVE_BAN_AT];
139
140 /// `void IConfig::removeBan(const BanEntry &)`.
141 ///
142 /// # Safety
143 /// `config` must be a live `IConfig`.
144 pub fn config_remove_ban(config: IConfig, entry: &BanEntry) = [0, SLOT_REMOVE_BAN];
145
146 /// `void IConfig::writeBans()`.
147 ///
148 /// # Safety
149 /// `config` must be a live `IConfig`.
150 pub fn config_write_bans(config: IConfig) = [0, SLOT_WRITE_BANS];
151
152 /// `void IConfig::reloadBans()`.
153 ///
154 /// # Safety
155 /// `config` must be a live `IConfig`.
156 pub fn config_reload_bans(config: IConfig) = [0, SLOT_RELOAD_BANS];
157
158 /// `void IConfig::clearBans()`.
159 ///
160 /// # Safety
161 /// `config` must be a live `IConfig`.
162 pub fn config_clear_bans(config: IConfig) = [0, SLOT_CLEAR_BANS];
163
164 /// `bool IConfig::isBanned(const BanEntry &)`.
165 ///
166 /// # Safety
167 /// `config` must be a live `IConfig`.
168 #[must_use]
169 pub fn config_is_banned(
170 config: IConfig,
171 entry: &BanEntry,
172 ) -> bool = [0, SLOT_IS_BANNED] or false;
173
174 /// `void IConfig::enumOptions(OptionEnumeratorCallback &)`.
175 ///
176 /// # Safety
177 /// `config` must be a live `IConfig`.
178 pub fn config_enum_options(
179 config: IConfig,
180 callback: *mut OptionEnumeratorCallback,
181 ) = [0, SLOT_ENUM_OPTIONS];
182
183 /// `bool * IConfig::getBool(StringView)`.
184 ///
185 /// # Safety
186 /// `config` must be a live `IConfig`.
187 #[must_use]
188 pub fn config_bool(
189 config: IConfig,
190 key: StringView,
191 ) -> *mut bool = [0, SLOT_GET_BOOL] or std::ptr::null_mut();
192}
193
194/// `const StringView IConfig::getString(StringView)`.
195///
196/// # Safety
197/// `config` must be a live `IConfig`.
198#[must_use]
199pub unsafe fn config_string(config: *mut IConfig, key: StringView) -> Option<String> {
200 let view = call_vtable_small_struct!(
201 config.cast::<u8>(),
202 0,
203 SLOT_GET_STRING,
204 StringView,
205 StringView::EMPTY,
206 (StringView)(key)
207 )?;
208 unsafe { view.to_owned_string() }
209}
210
211/// `Pair<bool, StringView> IConfig::getNameFromAlias(StringView)`.
212///
213/// # Safety
214/// `config` must be a live `IConfig`.
215#[must_use]
216pub unsafe fn config_name_from_alias(
217 config: *mut IConfig,
218 alias: StringView,
219) -> Option<Pair<bool, StringView>> {
220 call_vtable_small_struct!(config.cast::<u8>(), 0, SLOT_GET_NAME_FROM_ALIAS, Pair<bool, StringView>, unsafe { std::mem::zeroed::<Pair<bool, StringView>>() }, (StringView) (alias))
221}