mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-04 00:36:14 +00:00
42 lines
1.1 KiB
C++
42 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <nlohmann/json.hpp>
|
|
#include <string>
|
|
|
|
using json = nlohmann::json;
|
|
|
|
class TVehicleData final {
|
|
public:
|
|
TVehicleData(int ID, const std::string& Data);
|
|
~TVehicleData();
|
|
// We cannot delete this, since vector needs to be able to copy when it resizes.
|
|
// Deleting this causes some wacky template errors which are hard to decipher,
|
|
// and end up making no sense, so let's just leave the copy ctor.
|
|
// TVehicleData(const TVehicleData&) = delete;
|
|
|
|
[[nodiscard]] bool IsInvalid() const { return mID == -1; }
|
|
[[nodiscard]] int ID() const { return mID; }
|
|
|
|
[[nodiscard]] std::string Data() const { return mData; }
|
|
void SetData(const std::string& Data) { mData = Data; }
|
|
|
|
bool operator==(const TVehicleData& v) const { return mID == v.mID; }
|
|
|
|
const json& Json() const;
|
|
|
|
private:
|
|
int mID { -1 };
|
|
std::string mData;
|
|
json mJson;
|
|
};
|
|
|
|
// TODO: unused now, remove?
|
|
namespace std {
|
|
template <>
|
|
struct hash<TVehicleData> {
|
|
std::size_t operator()(const TVehicleData& s) const noexcept {
|
|
return s.ID();
|
|
}
|
|
};
|
|
}
|