-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEPair.cpp
49 lines (42 loc) · 1.37 KB
/
EPair.cpp
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
#include "pre.h"
#include "strlib.h"
#include "config.h"
#include "EPair.h"
std::map<std::string, EPairType> EPair::defaultTypes;
bool EPair::IsTarget() const { return (flags == EPairFlags::TARGET); }
bool EPair::IsTargetName() const { return (flags == EPairFlags::TARGETNAME); }
void EPair::UpdateFlags()
{
// check for all the ways an entity can have an incoming target reference,
// which so far thankfully all start with 'targetname'
// in extended mode, any 'targetname' w/suffix is a valid target destination
// in non-extended mode, only 'targetname' is valid
if (g_project.extTargets ? strlib::StartsWith(key, "targetname") : (key == "targetname"))
{
flags = EPairFlags::TARGETNAME;
return;
}
// check for all the ways an entity can have an outgoing target reference
// (target/target2/3/4/killtarget/whatever silly ones dumptruck added)
// in extended mode, any kv with 'target' in it is a valid target source
// (not 'targetname'! but we already checked for it)
// in non-extended mode, only 'target' is valid
if (g_project.extTargets ? strlib::Contains(key, "target") : (key == "target"))
{
flags = EPairFlags::TARGET;
}
}
void EPair::Set(const std::string& k, const std::string& v)
{
SetKey(k);
SetValue(v);
}
void EPair::SetKey(const std::string& k)
{
assert(!k.empty());
key = k;
UpdateFlags();
}
void EPair::SetValue(const std::string& v) {
value = v;
}