-
-
Notifications
You must be signed in to change notification settings - Fork 164
Expand file tree
/
Copy pathvariables.hpp
More file actions
67 lines (52 loc) · 1.78 KB
/
variables.hpp
File metadata and controls
67 lines (52 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/.
*
* The original code is copyright (c) 2022, open.mp team and contributors.
*/
#pragma once
#include <component.hpp>
#include <player.hpp>
#include <types.hpp>
#include <values.hpp>
enum VariableType
{
VariableType_None,
VariableType_Int,
VariableType_String,
VariableType_Float
};
struct IVariableStorageBase
{
/// Set a variable to a string
virtual void setString(StringView key, StringView value) = 0;
/// Get a variable as a string
virtual const StringView getString(StringView key) const = 0;
/// Set a variable to an int
virtual void setInt(StringView key, int value) = 0;
/// Get a variable as an int
virtual int getInt(StringView key) const = 0;
/// Set a variable to a float
virtual void setFloat(StringView key, float value) = 0;
/// Get a variable as a float
virtual float getFloat(StringView key) const = 0;
/// Get a variable's type
virtual VariableType getType(StringView key) const = 0;
/// Erase a variable by setting its type to None and freeing its memory if it's a string
virtual bool erase(StringView key) = 0;
/// Get variable name (key) by index
virtual bool getKeyAtIndex(int index, StringView& key) const = 0;
/// Get variables map size
virtual int size() const = 0;
};
static const UID VariablesComponent_UID = UID(0x75e121848bc01fa2);
struct IVariablesComponent : public IComponent, public IVariableStorageBase
{
PROVIDE_UID(VariablesComponent_UID);
};
static const UID PlayerVariableData_UID = UID(0x12debbc8a3bd23ad);
struct IPlayerVariableData : public IExtension, public IVariableStorageBase
{
PROVIDE_EXT_UID(PlayerVariableData_UID);
};