-
Notifications
You must be signed in to change notification settings - Fork 0
/
namedstarsystem.h
60 lines (53 loc) · 1.1 KB
/
namedstarsystem.h
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
#pragma once
#include <QString>
#include <QVariant>
#include <string>
#include "utils/json.hpp"
#include "utils/cm_ctors.h"
#include "point.h"
#include "edsmwrapper.h"
struct NamedStarSystem
{
public:
Point p;
QString name;
bool blank{true};
public:
NamedStarSystem() = default;
DEFAULT_COPYMOVE(NamedStarSystem);
static NamedStarSystem fromJsonInfo(const nlohmann::json& src)
{
NamedStarSystem r;
try
{
r.p = Point::fromJson(src);
r.name = QString::fromStdString(EDSMWrapper::valueFromJson<std::string>(src, "name"));
r.blank = false;
}
catch (...)
{
}
return r;
}
operator const QString& () const noexcept
{
return name;
}
operator const QVariant () const noexcept
{
return name;
}
operator Point& () noexcept
{
return p;
}
operator const Point& () const noexcept
{
return p;
}
bool operator ==(const QString& v) const noexcept
{
return v == name;
}
};
TEST_MOVE_NOEX(NamedStarSystem);