Skip to content

util/xmlfile.h: API update #14032

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions src/devices/machine/laserdsc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1134,21 +1134,23 @@ void laserdisc_device::config_load(config_type cfg_type, config_level cfg_level,
if ((cfg_type != config_type::SYSTEM) || !parentnode)
return;

using namespace std::literals;

// iterate over overlay nodes
for (util::xml::data_node const *ldnode = parentnode->get_child("device"); ldnode != nullptr; ldnode = ldnode->get_next_sibling("device"))
for (util::xml::data_node const *ldnode = parentnode->get_child("device"sv); ldnode != nullptr; ldnode = ldnode->get_next_sibling("device"sv))
{
char const *const devtag = ldnode->get_attribute_string("tag", "");
if (strcmp(devtag, tag()) == 0)
std::string_view const devtag(ldnode->get_attribute_string("tag"sv));
if (devtag == tag())
{
// handle the overlay node
util::xml::data_node const *const overnode = ldnode->get_child("overlay");
util::xml::data_node const *const overnode = ldnode->get_child("overlay"sv);
if (overnode != nullptr)
{
// fetch positioning controls
m_overposx = overnode->get_attribute_float("hoffset", m_overposx);
m_overscalex = overnode->get_attribute_float("hstretch", m_overscalex);
m_overposy = overnode->get_attribute_float("voffset", m_overposy);
m_overscaley = overnode->get_attribute_float("vstretch", m_overscaley);
m_overposx = overnode->get_attribute_float("hoffset"sv, m_overposx);
m_overscalex = overnode->get_attribute_float("hstretch"sv, m_overscalex);
m_overposy = overnode->get_attribute_float("voffset"sv, m_overposy);
m_overscaley = overnode->get_attribute_float("vstretch"sv, m_overscaley);
}
}
}
Expand All @@ -1166,40 +1168,42 @@ void laserdisc_device::config_save(config_type cfg_type, util::xml::data_node *p
if (cfg_type != config_type::SYSTEM)
return;

using namespace std::literals;

// create a node
util::xml::data_node *const ldnode = parentnode->add_child("device", nullptr);
util::xml::data_node *const ldnode = parentnode->add_child("device"sv);
if (ldnode)
{
// output the basics
ldnode->set_attribute("tag", tag());
ldnode->set_attribute("tag"sv, tag());

// add an overlay node
util::xml::data_node *const overnode = ldnode->add_child("overlay", nullptr);
util::xml::data_node *const overnode = ldnode->add_child("overlay"sv);
bool changed = false;
if (overnode != nullptr)
{
// output the positioning controls
if (m_overposx != m_orig_config.m_overposx)
{
overnode->set_attribute_float("hoffset", m_overposx);
overnode->set_attribute_float("hoffset"sv, m_overposx);
changed = true;
}

if (m_overscalex != m_orig_config.m_overscalex)
{
overnode->set_attribute_float("hstretch", m_overscalex);
overnode->set_attribute_float("hstretch"sv, m_overscalex);
changed = true;
}

if (m_overposy != m_orig_config.m_overposy)
{
overnode->set_attribute_float("voffset", m_overposy);
overnode->set_attribute_float("voffset"sv, m_overposy);
changed = true;
}

if (m_overscaley != m_orig_config.m_overscaley)
{
overnode->set_attribute_float("vstretch", m_overscaley);
overnode->set_attribute_float("vstretch"sv, m_overscaley);
changed = true;
}
}
Expand Down
82 changes: 43 additions & 39 deletions src/emu/audio_effects/compressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,113 +21,117 @@ audio_effect_compressor::audio_effect_compressor(speaker_device *speaker, u32 sa

void audio_effect_compressor::config_load(util::xml::data_node const *ef_node)
{
if(ef_node->has_attribute("mode")) {
m_mode = ef_node->get_attribute_int("mode", 0);
using namespace std::literals;

if(ef_node->has_attribute("mode"sv)) {
m_mode = ef_node->get_attribute_int("mode"sv, 0);
m_isset_mode = true;
} else
reset_mode();

if(ef_node->has_attribute("attack")) {
m_attack = ef_node->get_attribute_float("attack", 0);
if(ef_node->has_attribute("attack"sv)) {
m_attack = ef_node->get_attribute_float("attack"sv, 0);
m_isset_attack = true;
} else
reset_attack();

if(ef_node->has_attribute("release")) {
m_release = ef_node->get_attribute_float("release", 0);
if(ef_node->has_attribute("release"sv)) {
m_release = ef_node->get_attribute_float("release"sv, 0);
m_isset_release = true;
} else
reset_release();

if(ef_node->has_attribute("ratio")) {
m_ratio = ef_node->get_attribute_float("ratio", 0);
if(ef_node->has_attribute("ratio"sv)) {
m_ratio = ef_node->get_attribute_float("ratio"sv, 0);
m_isset_ratio = true;
} else
reset_ratio();

if(ef_node->has_attribute("input_gain")) {
m_input_gain = ef_node->get_attribute_float("input_gain", 0);
if(ef_node->has_attribute("input_gain"sv)) {
m_input_gain = ef_node->get_attribute_float("input_gain"sv, 0);
m_isset_input_gain = true;
} else
reset_input_gain();

if(ef_node->has_attribute("output_gain")) {
m_output_gain = ef_node->get_attribute_float("output_gain", 0);
if(ef_node->has_attribute("output_gain"sv)) {
m_output_gain = ef_node->get_attribute_float("output_gain"sv, 0);
m_isset_output_gain = true;
} else
reset_output_gain();

if(ef_node->has_attribute("convexity")) {
m_convexity = ef_node->get_attribute_float("convexity", 0);
if(ef_node->has_attribute("convexity"sv)) {
m_convexity = ef_node->get_attribute_float("convexity"sv, 0);
m_isset_convexity = true;
} else
reset_convexity();

if(ef_node->has_attribute("threshold")) {
m_threshold = ef_node->get_attribute_float("threshold", 0);
if(ef_node->has_attribute("threshold"sv)) {
m_threshold = ef_node->get_attribute_float("threshold"sv, 0);
m_isset_threshold = true;
} else
reset_threshold();

if(ef_node->has_attribute("channel_link")) {
m_channel_link = ef_node->get_attribute_float("channel_link", 0);
if(ef_node->has_attribute("channel_link"sv)) {
m_channel_link = ef_node->get_attribute_float("channel_link"sv, 0);
m_isset_channel_link = true;
} else
reset_channel_link();

if(ef_node->has_attribute("feedback")) {
m_feedback = ef_node->get_attribute_float("feedback", 0);
if(ef_node->has_attribute("feedback"sv)) {
m_feedback = ef_node->get_attribute_float("feedback"sv, 0);
m_isset_feedback = true;
} else
reset_feedback();

if(ef_node->has_attribute("inertia")) {
m_inertia = ef_node->get_attribute_float("inertia", 0);
if(ef_node->has_attribute("inertia"sv)) {
m_inertia = ef_node->get_attribute_float("inertia"sv, 0);
m_isset_inertia = true;
} else
reset_inertia();

if(ef_node->has_attribute("inertia_decay")) {
m_inertia_decay = ef_node->get_attribute_float("inertia_decay", 0);
if(ef_node->has_attribute("inertia_decay"sv)) {
m_inertia_decay = ef_node->get_attribute_float("inertia_decay"sv, 0);
m_isset_inertia_decay = true;
} else
reset_inertia_decay();

if(ef_node->has_attribute("ceiling")) {
m_ceiling = ef_node->get_attribute_float("ceiling", 0);
if(ef_node->has_attribute("ceiling"sv)) {
m_ceiling = ef_node->get_attribute_float("ceiling"sv, 0);
m_isset_ceiling = true;
} else
reset_ceiling();
}

void audio_effect_compressor::config_save(util::xml::data_node *ef_node) const
{
using namespace std::literals;

if(m_isset_mode)
ef_node->set_attribute_int("mode", m_mode);
ef_node->set_attribute_int("mode"sv, m_mode);
if(m_isset_attack)
ef_node->set_attribute_float("attack", m_attack);
ef_node->set_attribute_float("attack"sv, m_attack);
if(m_isset_release)
ef_node->set_attribute_float("release", m_release);
ef_node->set_attribute_float("release"sv, m_release);
if(m_isset_ratio)
ef_node->set_attribute_float("ratio", m_ratio);
ef_node->set_attribute_float("ratio"sv, m_ratio);
if(m_isset_input_gain)
ef_node->set_attribute_float("input_gain", m_input_gain);
ef_node->set_attribute_float("input_gain"sv, m_input_gain);
if(m_isset_output_gain)
ef_node->set_attribute_float("output_gain", m_output_gain);
ef_node->set_attribute_float("output_gain"sv, m_output_gain);
if(m_isset_convexity)
ef_node->set_attribute_float("convexity", m_convexity);
ef_node->set_attribute_float("convexity"sv, m_convexity);
if(m_isset_threshold)
ef_node->set_attribute_float("threshold", m_threshold);
ef_node->set_attribute_float("threshold"sv, m_threshold);
if(m_isset_channel_link)
ef_node->set_attribute_float("channel_link", m_channel_link);
ef_node->set_attribute_float("channel_link"sv, m_channel_link);
if(m_isset_feedback)
ef_node->set_attribute_float("feedback", m_feedback);
ef_node->set_attribute_float("feedback"sv, m_feedback);
if(m_isset_inertia)
ef_node->set_attribute_float("inertia", m_inertia);
ef_node->set_attribute_float("inertia"sv, m_inertia);
if(m_isset_inertia_decay)
ef_node->set_attribute_float("inertia_decay", m_inertia_decay);
ef_node->set_attribute_float("inertia_decay"sv, m_inertia_decay);
if(m_isset_ceiling)
ef_node->set_attribute_float("ceiling", m_ceiling);
ef_node->set_attribute_float("ceiling"sv, m_ceiling);
}

void audio_effect_compressor::default_changed()
Expand Down
39 changes: 21 additions & 18 deletions src/emu/audio_effects/eq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,39 +91,41 @@ void audio_effect_eq::reset_all()

void audio_effect_eq::config_load(util::xml::data_node const *ef_node)
{
if(ef_node->has_attribute("mode")) {
m_mode = ef_node->get_attribute_int("mode", 0);
using namespace std::literals;

if(ef_node->has_attribute("mode"sv)) {
m_mode = ef_node->get_attribute_int("mode"sv, 0);
m_isset_mode = true;
} else
reset_mode();

if(ef_node->has_attribute("low_shelf")) {
m_low_shelf = ef_node->get_attribute_int("low_shelf", 0);
if(ef_node->has_attribute("low_shelf"sv)) {
m_low_shelf = ef_node->get_attribute_int("low_shelf"sv, 0);
m_isset_low_shelf = true;
} else
reset_low_shelf();

if(ef_node->has_attribute("high_shelf")) {
m_high_shelf = ef_node->get_attribute_int("high_shelf", 0);
if(ef_node->has_attribute("high_shelf"sv)) {
m_high_shelf = ef_node->get_attribute_int("high_shelf"sv, 0);
m_isset_high_shelf = true;
} else
reset_high_shelf();

for(u32 band = 0; band != BANDS; band++) {
if(ef_node->has_attribute(util::string_format("f%d", band+1).c_str())) {
m_f[band] = ef_node->get_attribute_int(util::string_format("f%d", band+1).c_str(), 0);
if(ef_node->has_attribute(util::string_format("f%d", band+1))) {
m_f[band] = ef_node->get_attribute_int(util::string_format("f%d", band+1), 0);
m_isset_f[band] = true;
} else
reset_f(band);

if(ef_node->has_attribute(util::string_format("q%d", band+1).c_str())) {
m_q[band] = ef_node->get_attribute_float(util::string_format("q%d", band+1).c_str(), 0);
if(ef_node->has_attribute(util::string_format("q%d", band+1))) {
m_q[band] = ef_node->get_attribute_float(util::string_format("q%d", band+1), 0);
m_isset_q[band] = true;
} else
reset_q(band);

if(ef_node->has_attribute(util::string_format("db%d", band+1).c_str())) {
m_db[band] = ef_node->get_attribute_float(util::string_format("db%d", band+1).c_str(), 0);
if(ef_node->has_attribute(util::string_format("db%d", band+1))) {
m_db[band] = ef_node->get_attribute_float(util::string_format("db%d", band+1), 0);
m_isset_db[band] = true;
} else
reset_db(band);
Expand All @@ -135,19 +137,20 @@ void audio_effect_eq::config_load(util::xml::data_node const *ef_node)

void audio_effect_eq::config_save(util::xml::data_node *ef_node) const
{
using namespace std::literals;
if(m_isset_mode)
ef_node->set_attribute_int("mode", m_mode);
ef_node->set_attribute_int("mode"sv, m_mode);
if(m_isset_low_shelf)
ef_node->set_attribute_int("low_shelf", m_low_shelf);
ef_node->set_attribute_int("low_shelf"sv, m_low_shelf);
if(m_isset_high_shelf)
ef_node->set_attribute_int("high_shelf", m_high_shelf);
ef_node->set_attribute_int("high_shelf"sv, m_high_shelf);
for(u32 band = 0; band != BANDS; band++) {
if(m_isset_f[band])
ef_node->set_attribute_int(util::string_format("f%d", band+1).c_str(), m_f[band]);
ef_node->set_attribute_int(util::string_format("f%d", band+1), m_f[band]);
if(m_isset_q[band])
ef_node->set_attribute_float(util::string_format("q%d", band+1).c_str(), m_q[band]);
ef_node->set_attribute_float(util::string_format("q%d", band+1), m_q[band]);
if(m_isset_db[band])
ef_node->set_attribute_float(util::string_format("db%d", band+1).c_str(), m_db[band]);
ef_node->set_attribute_float(util::string_format("db%d", band+1), m_db[band]);
}
}

Expand Down
40 changes: 22 additions & 18 deletions src/emu/audio_effects/filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,38 +86,40 @@ void audio_effect_filter::reset_all()

void audio_effect_filter::config_load(util::xml::data_node const *ef_node)
{
if(ef_node->has_attribute("lowpass_active")) {
m_lowpass_active = ef_node->get_attribute_int("lowpass_active", 0);
using namespace std::literals;

if(ef_node->has_attribute("lowpass_active"sv)) {
m_lowpass_active = ef_node->get_attribute_int("lowpass_active"sv, 0);
m_isset_lowpass_active = true;
} else
reset_lowpass_active();

if(ef_node->has_attribute("fl")) {
m_fl = ef_node->get_attribute_int("fl", 0);
if(ef_node->has_attribute("fl"sv)) {
m_fl = ef_node->get_attribute_int("fl"sv, 0);
m_isset_fl = true;
} else
reset_fl();

if(ef_node->has_attribute("ql")) {
m_ql = ef_node->get_attribute_float("ql", 0);
if(ef_node->has_attribute("ql"sv)) {
m_ql = ef_node->get_attribute_float("ql"sv, 0);
m_isset_ql = true;
} else
reset_ql();

if(ef_node->has_attribute("highpass_active")) {
m_highpass_active = ef_node->get_attribute_int("highpass_active", 0);
if(ef_node->has_attribute("highpass_active"sv)) {
m_highpass_active = ef_node->get_attribute_int("highpass_active"sv, 0);
m_isset_highpass_active = true;
} else
reset_highpass_active();

if(ef_node->has_attribute("fh")) {
m_fh = ef_node->get_attribute_int("fh", 0);
if(ef_node->has_attribute("fh"sv)) {
m_fh = ef_node->get_attribute_int("fh"sv, 0);
m_isset_fh = true;
} else
reset_fh();

if(ef_node->has_attribute("qh")) {
m_qh = ef_node->get_attribute_float("qh", 0);
if(ef_node->has_attribute("qh"sv)) {
m_qh = ef_node->get_attribute_float("qh"sv, 0);
m_isset_qh = true;
} else
reset_qh();
Expand All @@ -128,18 +130,20 @@ void audio_effect_filter::config_load(util::xml::data_node const *ef_node)

void audio_effect_filter::config_save(util::xml::data_node *ef_node) const
{
using namespace std::literals;

if(m_isset_lowpass_active)
ef_node->set_attribute_int("lowpass_active", m_lowpass_active);
ef_node->set_attribute_int("lowpass_active"sv, m_lowpass_active);
if(m_isset_fl)
ef_node->set_attribute_int("fl", m_fl);
ef_node->set_attribute_int("fl"sv, m_fl);
if(m_isset_ql)
ef_node->set_attribute_float("ql", m_ql);
ef_node->set_attribute_float("ql"sv, m_ql);
if(m_isset_highpass_active)
ef_node->set_attribute_int("highpass_active", m_highpass_active);
ef_node->set_attribute_int("highpass_active"sv, m_highpass_active);
if(m_isset_fh)
ef_node->set_attribute_int("fh", m_fh);
ef_node->set_attribute_int("fh"sv, m_fh);
if(m_isset_qh)
ef_node->set_attribute_float("qh", m_qh);
ef_node->set_attribute_float("qh"sv, m_qh);
}

void audio_effect_filter::default_changed()
Expand Down
Loading
Loading