Codechange: use std::string for text file name resolution

This commit is contained in:
Rubidium
2023-05-05 00:04:52 +02:00
committed by rubidium42
parent 0b72297d57
commit 877349c13d
15 changed files with 56 additions and 58 deletions

View File

@@ -49,11 +49,11 @@ bool ContentInfo::IsValid() const
/**
* Search a textfile file next to this file in the content list.
* @param type The type of the textfile to search for.
* @return The filename for the textfile, \c nullptr otherwise.
* @return The filename for the textfile.
*/
const char *ContentInfo::GetTextfile(TextfileType type) const
std::optional<std::string> ContentInfo::GetTextfile(TextfileType type) const
{
if (this->state == INVALID) return nullptr;
if (this->state == INVALID) return std::nullopt;
const char *tmp;
switch (this->type) {
default: NOT_REACHED();
@@ -88,7 +88,7 @@ const char *ContentInfo::GetTextfile(TextfileType type) const
tmp = FindScenario(this, true);
break;
}
if (tmp == nullptr) return nullptr;
if (tmp == nullptr) return std::nullopt;
return ::GetTextfile(type, GetContentInfoSubDir(this->type), tmp);
}

View File

@@ -12,6 +12,8 @@
#ifndef NETWORK_CORE_TCP_CONTENT_TYPE_H
#define NETWORK_CORE_TCP_CONTENT_TYPE_H
#include <optional>
/** The values in the enum are important; they are used as database 'keys' */
enum ContentType {
CONTENT_TYPE_BEGIN = 1, ///< Helper to mark the begin of the types
@@ -75,7 +77,7 @@ struct ContentInfo {
bool IsSelected() const;
bool IsValid() const;
const char *GetTextfile(TextfileType type) const;
std::optional<std::string> GetTextfile(TextfileType type) const;
};
#endif /* NETWORK_CORE_TCP_CONTENT_TYPE_H */