mirror of
https://github.com/RPCS3/rpcs3
synced 2024-09-06 08:30:06 +00:00
cfg: simplify get_nodes
This commit is contained in:
parent
cb9e7358d2
commit
2c05e9719d
|
@ -22,15 +22,15 @@ namespace cfg
|
|||
_base::_base(type _type, node* owner, const std::string& name, bool dynamic)
|
||||
: m_type(_type), m_dynamic(dynamic), m_name(name)
|
||||
{
|
||||
for (const auto& pair : owner->m_nodes)
|
||||
for (const auto& node : owner->m_nodes)
|
||||
{
|
||||
if (pair.first == name)
|
||||
if (node->get_name() == name)
|
||||
{
|
||||
cfg_log.fatal("Node already exists: %s", name);
|
||||
}
|
||||
}
|
||||
|
||||
owner->m_nodes.emplace_back(name, this);
|
||||
owner->m_nodes.emplace_back(this);
|
||||
}
|
||||
|
||||
bool _base::from_string(const std::string&, bool)
|
||||
|
@ -218,11 +218,11 @@ void cfg::encode(YAML::Emitter& out, const cfg::_base& rhs)
|
|||
case type::node:
|
||||
{
|
||||
out << YAML::BeginMap;
|
||||
for (const auto& np : static_cast<const node&>(rhs).get_nodes())
|
||||
for (const auto& node : static_cast<const node&>(rhs).get_nodes())
|
||||
{
|
||||
out << YAML::Key << np.first;
|
||||
out << YAML::Key << node->get_name();
|
||||
out << YAML::Value;
|
||||
encode(out, *np.second);
|
||||
encode(out, *node);
|
||||
}
|
||||
|
||||
out << YAML::EndMap;
|
||||
|
@ -281,11 +281,11 @@ void cfg::decode(const YAML::Node& data, cfg::_base& rhs, bool dynamic)
|
|||
if (!pair.first.IsScalar()) continue;
|
||||
|
||||
// Find the key among existing nodes
|
||||
for (const auto& _pair : static_cast<node&>(rhs).get_nodes())
|
||||
for (const auto& node : static_cast<node&>(rhs).get_nodes())
|
||||
{
|
||||
if (_pair.first == pair.first.Scalar())
|
||||
if (node->get_name() == pair.first.Scalar())
|
||||
{
|
||||
decode(pair.second, *_pair.second, dynamic);
|
||||
decode(pair.second, *node, dynamic);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -366,7 +366,7 @@ void cfg::node::from_default()
|
|||
{
|
||||
for (auto& node : m_nodes)
|
||||
{
|
||||
node.second->from_default();
|
||||
node->from_default();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ namespace cfg
|
|||
// Config tree node which contains another nodes
|
||||
class node : public _base
|
||||
{
|
||||
std::vector<std::pair<std::string, _base*>> m_nodes;
|
||||
std::vector<_base*> m_nodes;
|
||||
|
||||
friend class _base;
|
||||
|
||||
|
|
|
@ -105,9 +105,9 @@ bool evdev_joystick_handler::Init()
|
|||
|
||||
for (const auto& node : m_pos_axis_config.get_nodes())
|
||||
{
|
||||
if (*static_cast<cfg::_bool*>(node.second))
|
||||
if (*static_cast<cfg::_bool*>(node))
|
||||
{
|
||||
const auto name = node.first;
|
||||
const auto name = node->get_name();
|
||||
const int code = libevdev_event_code_from_name(EV_ABS, name.c_str());
|
||||
if (code < 0)
|
||||
evdev_log.error("Failed to read axis name from %s. [code = %d] [name = %s]", m_pos_axis_config.cfg_name, code, name);
|
||||
|
|
|
@ -12,11 +12,11 @@ namespace cfg_adapter
|
|||
{
|
||||
if (root.get_type() == cfg::type::node)
|
||||
{
|
||||
for (const auto& pair : static_cast<cfg::node&>(root).get_nodes())
|
||||
for (const auto& node : static_cast<cfg::node&>(root).get_nodes())
|
||||
{
|
||||
if (pair.first == name)
|
||||
if (node->get_name() == name)
|
||||
{
|
||||
return *pair.second;
|
||||
return *node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -196,9 +196,9 @@ void emu_settings::ValidateSettings()
|
|||
|
||||
if (cfg_base && cfg_base->get_type() == cfg::type::node)
|
||||
{
|
||||
for (const auto& [name, node] : static_cast<const cfg::node*>(cfg_base)->get_nodes())
|
||||
for (const auto& node : static_cast<const cfg::node*>(cfg_base)->get_nodes())
|
||||
{
|
||||
if (name == keys[level])
|
||||
if (node->get_name() == keys[level])
|
||||
{
|
||||
cfg_node = node;
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue