Botcraft
1.21.4
Loading...
Searching...
No Matches
Identifier.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include "
protocolCraft/NetworkType.hpp
"
4
5
namespace
ProtocolCraft
6
{
7
class
Identifier
:
public
NetworkType
8
{
9
SERIALIZED_FIELD_WITHOUT_GETTER_SETTER
(RawString, std::string);
10
11
DECLARE_READ_WRITE_SERIALIZE
;
12
13
public
:
14
bool
operator <
(
const
Identifier
& rhs)
const
15
{
16
return
GetName
() < rhs.
GetName
() ||
17
(
GetName
() == rhs.
GetName
() &&
GetNamespace
() < rhs.
GetNamespace
());
18
}
19
20
std::string
GetName
()
const
21
{
22
const
size_t
split = RawString.find(
':'
);
23
return
split == std::string::npos ? RawString : RawString.substr(split + 1);
24
}
25
26
auto
&
SetName
(
const
std::string& name)
27
{
28
const
std::string namespace_ =
GetNamespace
();
29
RawString = namespace_.empty() ? name : (namespace_ +
':'
+ name);
30
return
*
this
;
31
}
32
33
std::string
GetNamespace
()
const
34
{
35
const
size_t
split = RawString.find(
':'
);
36
return
split == std::string::npos ?
""
: RawString.substr(0, split);
37
}
38
39
auto
&
SetNamespace
(
const
std::string& namespace_)
40
{
41
const
std::string name =
GetName
();
42
RawString = namespace_.empty() ? name : (namespace_ +
':'
+ name);
43
return
*
this
;
44
}
45
46
std::string
GetFull
()
const
47
{
48
if
(
GetNamespace
().empty())
49
{
50
return
"minecraft:"
+
GetName
();
51
}
52
else
53
{
54
return
RawString;
55
}
56
}
57
58
auto
&
SetRawString
(
const
std::string& raw)
59
{
60
RawString = raw;
61
return
*
this
;
62
}
63
};
64
}
// ProtocolCraft
NetworkType.hpp
ProtocolCraft::Identifier
Definition
Identifier.hpp:8
ProtocolCraft::Identifier::operator<
bool operator<(const Identifier &rhs) const
Definition
Identifier.hpp:14
ProtocolCraft::Identifier::GetFull
std::string GetFull() const
Definition
Identifier.hpp:46
ProtocolCraft::Identifier::SetNamespace
auto & SetNamespace(const std::string &namespace_)
Definition
Identifier.hpp:39
ProtocolCraft::Identifier::SetRawString
auto & SetRawString(const std::string &raw)
Definition
Identifier.hpp:58
ProtocolCraft::Identifier::DECLARE_READ_WRITE_SERIALIZE
DECLARE_READ_WRITE_SERIALIZE
Definition
Identifier.hpp:11
ProtocolCraft::Identifier::GetNamespace
std::string GetNamespace() const
Definition
Identifier.hpp:33
ProtocolCraft::Identifier::SetName
auto & SetName(const std::string &name)
Definition
Identifier.hpp:26
ProtocolCraft::Identifier::GetName
std::string GetName() const
Definition
Identifier.hpp:20
ProtocolCraft::Identifier::SERIALIZED_FIELD_WITHOUT_GETTER_SETTER
SERIALIZED_FIELD_WITHOUT_GETTER_SETTER(RawString, std::string)
ProtocolCraft::NetworkType
Definition
NetworkType.hpp:11
ProtocolCraft
Definition
ItemUtilities.hpp:8
protocolCraft
include
protocolCraft
Types
Identifier.hpp
Generated by
1.9.8