mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Rename string_equal_charptr to operator==(const std::string&, const char*)
Much prettier and more idiomatic as well as being a lot less typing.
This commit is contained in:
parent
0106176436
commit
c63db36a60
@ -33,6 +33,11 @@ auto constexpr stream_max = std::numeric_limits<std::streamsize>::max();
|
||||
GncOptionDB::GncOptionDB() : m_default_section{std::nullopt} {}
|
||||
|
||||
GncOptionDB::GncOptionDB(QofBook* book) : GncOptionDB() {}
|
||||
static bool
|
||||
operator==(const std::string& str, const char* cstr)
|
||||
{
|
||||
return strcmp(str.c_str(), cstr) == 0;
|
||||
}
|
||||
|
||||
void
|
||||
GncOptionDB::save_to_book(QofBook* book, bool do_clear) const
|
||||
@ -377,23 +382,14 @@ unquote_scheme_string(const std::string& str)
|
||||
return str;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
string_equal_charptr(const std::string& str, const char* chars)
|
||||
{
|
||||
if (!chars || str.empty() || strlen(chars) != str.size())
|
||||
return false;
|
||||
return strcmp(str.c_str(), chars) == 0;
|
||||
}
|
||||
|
||||
static std::optional<std::reference_wrapper<const SchemeId>>
|
||||
find_form(const SchemeId& toplevel, IdentType type, const char* name)
|
||||
{
|
||||
if (toplevel.m_type == type &&
|
||||
string_equal_charptr(toplevel.m_name.c_str(), name))
|
||||
if (toplevel.m_type == type && toplevel.m_name == name)
|
||||
return std::ref(toplevel);
|
||||
for (const auto& id : toplevel.m_ids)
|
||||
{
|
||||
if (id.m_type == type && string_equal_charptr(id.m_name.c_str(), name))
|
||||
if (id.m_type == type && id.m_name == name)
|
||||
return std::ref(id);
|
||||
auto child{find_form(id, type, name)};
|
||||
if (child)
|
||||
|
Loading…
Reference in New Issue
Block a user