ES-DE/es-core/src/MameNames.h
Leon Styhre 56ccba81d1 Removed all instances of hardcoded application directory entries
Also changed some source file headers
2023-12-15 18:33:02 +01:00

66 lines
1.7 KiB
C++

// SPDX-License-Identifier: MIT
//
// ES-DE
// MameNames.h
//
// Provides expanded game names based on short MAME name arguments. Also contains
// functions to check whether a passed argument is a MAME BIOS or a MAME device.
// The data sources are stored as the files mamebioses.xml, mamedevices.xml and mamenames.xml.
//
#ifndef ES_CORE_MAMENAMES_H
#define ES_CORE_MAMENAMES_H
#include "Settings.h"
#include "utils/StringUtil.h"
#include <algorithm>
#include <string>
#include <unordered_map>
#include <vector>
// Expand MAME names to full game names and lookup device and BIOS entries.
class MameNames
{
public:
static MameNames& getInstance();
std::string getRealName(const std::string& mameName)
{
std::string name = mNamePairs[mameName];
if (name == "")
return mameName;
else
return name;
}
std::string getCleanName(const std::string& mameName)
{
static const bool stripInfo {Settings::getInstance()->getBool("MAMENameStripExtraInfo")};
if (stripInfo)
return Utils::String::removeParenthesis(getRealName(mameName));
else
return getRealName(mameName);
}
const bool isBios(const std::string& biosName)
{
return std::find(mMameBioses.cbegin(), mMameBioses.cend(), biosName) != mMameBioses.cend();
}
const bool isDevice(const std::string& deviceName)
{
return std::find(mMameDevices.cbegin(), mMameDevices.cend(), deviceName) !=
mMameDevices.cend();
}
private:
MameNames();
std::unordered_map<std::string, std::string> mNamePairs;
std::vector<std::string> mMameBioses;
std::vector<std::string> mMameDevices;
};
#endif // ES_CORE_MAMENAMES_H