ES-DE/es-core/src/MameNames.h

62 lines
1.6 KiB
C
Raw Normal View History

// SPDX-License-Identifier: MIT
//
// EmulationStation Desktop Edition
// 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 in the .emulationstation/resources directory
// as the files mamebioses.xml, mamedevices.xml and mamenames.xml.
//
#ifndef ES_CORE_MAMENAMES_H
#define ES_CORE_MAMENAMES_H
2021-11-17 20:32:40 +00:00
#include "utils/StringUtil.h"
#include <algorithm>
#include <string>
2021-11-17 20:38:27 +00:00
#include <unordered_map>
#include <vector>
2021-11-17 20:32:40 +00:00
// Expand MAME names to full game names and lookup device and BIOS entries.
class MameNames
{
public:
2021-11-17 20:32:40 +00:00
static MameNames& getInstance();
std::string getRealName(const std::string& mameName)
{
2021-11-17 20:32:40 +00:00
std::string name = mNamePairs[mameName];
if (name == "")
return mameName;
else
return name;
}
2021-11-17 20:32:40 +00:00
std::string getCleanName(const std::string& mameName)
{
2021-11-17 20:32:40 +00:00
return Utils::String::removeParenthesis(getRealName(mameName));
}
2021-11-17 20:32:40 +00:00
const bool isBios(const std::string& biosName)
{
return std::find(mMameBioses.cbegin(), mMameBioses.cend(), biosName) != mMameBioses.cend();
}
2021-11-17 20:32:40 +00:00
const bool isDevice(const std::string& deviceName)
{
return std::find(mMameDevices.cbegin(), mMameDevices.cend(), deviceName) !=
mMameDevices.cend();
}
2021-11-17 20:32:40 +00:00
private:
MameNames();
2021-11-17 20:32:40 +00:00
std::unordered_map<std::string, std::string> mNamePairs;
std::vector<std::string> mMameBioses;
std::vector<std::string> mMameDevices;
};
#endif // ES_CORE_MAMENAMES_H