commonlibsse_ng\re\s/
SettingCollectionMap.rs

1//! # SettingCollectionMap
2//!
3//! This module defines the `SettingCollectionMap<T>` struct, representing a collection of settings
4//! with case-insensitive string keys. It inherits from `SettingCollection<T>` and overrides
5//! the relevant virtual functions.
6
7use crate::re::BSTCaseInsensitiveStringMap::BSTCaseInsensitiveStringMap;
8use crate::re::Setting::Setting;
9use crate::re::SettingCollection::SettingCollection;
10
11/// Represents a map-based collection of settings.
12///
13/// Inherits from `SettingCollection<T>`.
14///
15/// # Memory Layout:
16/// - `sub_key`: Sub-key array (0x104)
17/// - `handle`: Handle pointer (0x110)
18/// - `settings`: Case-insensitive map of settings (0x118)
19#[repr(C)]
20#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
21pub struct SettingCollectionMap<T> {
22    /// Base `SettingCollection<T>` struct.
23    pub __base: SettingCollection<T>,
24
25    /// Map of case-insensitive strings to settings.
26    pub settings: BSTCaseInsensitiveStringMap<*mut T>,
27}
28const _: () = {
29    assert!(core::mem::offset_of!(SettingCollectionMap::<Setting>, __base) == 0x00);
30    assert!(core::mem::offset_of!(SettingCollectionMap::<Setting>, settings) == 0x118);
31    assert!(core::mem::size_of::<SettingCollectionMap::<Setting>>() == 0x140);
32};
33
34/// The virtual function table for `SettingCollectionMap<T>`.
35///
36/// This struct defines function pointers to simulate the C++ virtual functions.
37#[repr(C)]
38pub struct SettingCollectionMapVtbl<T> {
39    /// Destructor function pointer.
40    pub CxxDrop: fn(this: &mut SettingCollectionMap<T>),
41
42    /// Function pointer for inserting a setting.
43    pub InsertSetting: fn(this: &mut SettingCollectionMap<T>, setting: &mut T),
44
45    /// Function pointer for removing a setting.
46    pub RemoveSetting: fn(this: &mut SettingCollectionMap<T>, setting: &mut T),
47
48    /// Function pointer for writing all settings.
49    pub WriteAllSettings: fn(this: &mut SettingCollectionMap<T>),
50
51    /// Function pointer for reading all settings.
52    pub ReadAllSettings: fn(this: &mut SettingCollectionMap<T>),
53}
54
55impl<T> Default for SettingCollectionMapVtbl<T> {
56    #[inline]
57    fn default() -> Self {
58        Self::new()
59    }
60}
61
62impl<T> SettingCollectionMapVtbl<T> {
63    /// Creates a new default virtual table with stubbed functions.
64    #[inline]
65    pub const fn new() -> Self {
66        const fn CxxDrop<T>(_this: &mut SettingCollectionMap<T>) {}
67
68        const fn InsertSetting<T>(_this: &mut SettingCollectionMap<T>, _setting: &mut T) {}
69
70        const fn RemoveSetting<T>(_this: &mut SettingCollectionMap<T>, _setting: &mut T) {}
71
72        const fn WriteAllSettings<T>(_this: &mut SettingCollectionMap<T>) {}
73
74        const fn ReadAllSettings<T>(_this: &mut SettingCollectionMap<T>) {}
75
76        Self { CxxDrop, InsertSetting, RemoveSetting, WriteAllSettings, ReadAllSettings }
77    }
78}