move to std optional

This commit is contained in:
David Markowitz
2023-07-25 19:45:22 -07:00
parent dc526aeec1
commit ff173dffce
7 changed files with 18 additions and 24 deletions

View File

@@ -53,13 +53,8 @@ void CDZoneTableTable::LoadValuesFromDatabase() {
}
//! Queries the table with a zoneID to find.
const CDZoneTable* CDZoneTableTable::Query(unsigned int zoneID) {
const std::optional<CDZoneTable> CDZoneTableTable::Query(unsigned int zoneID) {
const auto& iter = m_Entries.find(zoneID);
if (iter != m_Entries.end()) {
return &iter->second;
}
return nullptr;
return iter != m_Entries.end() ? std::make_optional(iter->second) : std::nullopt;
}

View File

@@ -1,8 +1,9 @@
#pragma once
// Custom Classes
#include "CDTable.h"
#include <optional>
struct CDZoneTable {
unsigned int zoneID; //!< The Zone ID of the object
unsigned int locStatus; //!< The Locale Status(?)
@@ -41,5 +42,5 @@ public:
void LoadValuesFromDatabase();
// Queries the table with a zoneID to find.
const CDZoneTable* Query(unsigned int zoneID);
const std::optional<CDZoneTable> Query(unsigned int zoneID);
};