Mercurial > foo_out_sdl
comparison foosdk/sdk/foobar2000/SDK/advconfig.cpp @ 1:20d02a178406 default tip
*: check in everything else
yay
| author | Paper <paper@tflc.us> |
|---|---|
| date | Mon, 05 Jan 2026 02:15:46 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:e9bb126753e7 | 1:20d02a178406 |
|---|---|
| 1 #include "foobar2000-sdk-pch.h" | |
| 2 #include "advconfig.h" | |
| 3 #include "advconfig_impl.h" | |
| 4 | |
| 5 bool advconfig_entry::is_branch() { | |
| 6 advconfig_branch::ptr branch; | |
| 7 return branch &= this; | |
| 8 } | |
| 9 | |
| 10 bool advconfig_entry::g_find(service_ptr_t<advconfig_entry>& out, const GUID & id) { | |
| 11 for (auto ptr : advconfig_entry::enumerate()) { | |
| 12 if (ptr->get_guid() == id) { out = ptr; return true; } | |
| 13 } | |
| 14 return false; | |
| 15 } | |
| 16 | |
| 17 t_uint32 advconfig_entry::get_preferences_flags_() { | |
| 18 { | |
| 19 advconfig_entry_string_v2::ptr ex; | |
| 20 if (service_query_t(ex)) return ex->get_preferences_flags(); | |
| 21 } | |
| 22 { | |
| 23 advconfig_entry_checkbox_v2::ptr ex; | |
| 24 if (service_query_t(ex)) return ex->get_preferences_flags(); | |
| 25 } | |
| 26 return 0; | |
| 27 } | |
| 28 | |
| 29 bool advconfig_entry_checkbox::get_default_state_() { | |
| 30 { | |
| 31 advconfig_entry_checkbox_v2::ptr ex; | |
| 32 if (service_query_t(ex)) return ex->get_default_state(); | |
| 33 } | |
| 34 | |
| 35 bool backup = get_state(); | |
| 36 reset(); | |
| 37 bool rv = get_state(); | |
| 38 set_state(backup); | |
| 39 return rv; | |
| 40 } | |
| 41 | |
| 42 void advconfig_entry_string::get_default_state_(pfc::string_base & out) { | |
| 43 { | |
| 44 advconfig_entry_string_v2::ptr ex; | |
| 45 if (service_query_t(ex)) {ex->get_default_state(out); return;} | |
| 46 } | |
| 47 pfc::string8 backup; | |
| 48 get_state(backup); | |
| 49 reset(); | |
| 50 get_state(out); | |
| 51 set_state(backup); | |
| 52 } | |
| 53 | |
| 54 | |
| 55 #if FOOBAR2000_TARGET_VERSION >= 81 | |
| 56 // advconfig_impl.h functionality | |
| 57 | |
| 58 void advconfig_entry_checkbox_impl::reset() { | |
| 59 fb2k::configStore::get()->deleteConfigBool(m_varName); | |
| 60 } | |
| 61 | |
| 62 void advconfig_entry_checkbox_impl::set_state(bool p_state) { | |
| 63 fb2k::configStore::get()->setConfigBool(m_varName, p_state); | |
| 64 } | |
| 65 | |
| 66 bool advconfig_entry_checkbox_impl::get_state_() const { | |
| 67 return fb2k::configStore::get()->getConfigBool(m_varName, m_initialstate); | |
| 68 } | |
| 69 | |
| 70 #ifdef FOOBAR2000_HAVE_CFG_VAR_LEGACY | |
| 71 void advconfig_entry_checkbox_impl::set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) { | |
| 72 (void)p_sizehint; | |
| 73 uint8_t v; | |
| 74 if (p_stream->read(&v, 1, p_abort) == 1) { | |
| 75 set_state(v != 0); | |
| 76 } | |
| 77 } | |
| 78 #endif | |
| 79 | |
| 80 void advconfig_entry_string_impl::reset() { | |
| 81 fb2k::configStore::get()->deleteConfigString(m_varName); | |
| 82 } | |
| 83 void advconfig_entry_string_impl::get_state(pfc::string_base& p_out) { | |
| 84 p_out = fb2k::configStore::get()->getConfigString(m_varName, m_initialstate)->c_str(); | |
| 85 } | |
| 86 void advconfig_entry_string_impl::set_state(const char* p_string, t_size p_length) { | |
| 87 pfc::string8 asdf; | |
| 88 if (p_length != SIZE_MAX) { | |
| 89 asdf.set_string(p_string, p_length); | |
| 90 p_string = asdf; | |
| 91 } | |
| 92 fb2k::configStore::get()->setConfigString(m_varName, p_string); | |
| 93 } | |
| 94 | |
| 95 #ifdef FOOBAR2000_HAVE_CFG_VAR_LEGACY | |
| 96 void advconfig_entry_string_impl::set_data_raw(stream_reader* p_stream, t_size p_sizehint, abort_callback& p_abort) { | |
| 97 (void)p_sizehint; | |
| 98 pfc::string8_fastalloc temp; | |
| 99 p_stream->read_string_raw(temp, p_abort); | |
| 100 this->set_state(temp); | |
| 101 } | |
| 102 #endif | |
| 103 | |
| 104 #endif // FOOBAR2000_TARGET_VERSION >= 81 |
