dolphin/Source/Core/Core/CheatCodes.h
Pierre Bourdon e149ad4f0a
treewide: convert GPLv2+ license info to SPDX tags
SPDX standardizes how source code conveys its copyright and licensing
information. See https://spdx.github.io/spdx-spec/1-rationale/ . SPDX
tags are adopted in many large projects, including things like the Linux
kernel.
2021-07-05 04:35:56 +02:00

38 lines
959 B
C++

// Copyright 2020 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <string>
#include <vector>
#include "Common/IniFile.h"
template <typename T>
void ReadEnabledOrDisabled(const IniFile& ini, const std::string& section, bool enabled,
std::vector<T>* codes)
{
std::vector<std::string> lines;
ini.GetLines(section, &lines, false);
for (const std::string& line : lines)
{
if (line.empty() || line[0] != '$')
continue;
for (T& code : *codes)
{
// Exclude the initial '$' from the comparison.
if (line.compare(1, std::string::npos, code.name) == 0)
code.enabled = enabled;
}
}
}
template <typename T>
void ReadEnabledAndDisabled(const IniFile& ini, const std::string& section, std::vector<T>* codes)
{
ReadEnabledOrDisabled(ini, section + "_Enabled", true, codes);
ReadEnabledOrDisabled(ini, section + "_Disabled", false, codes);
}