ClickHouse/src/Common/SettingsChanges.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

50 lines
1.2 KiB
C++
Raw Normal View History

2020-07-22 12:02:47 +00:00
#include <Common/SettingsChanges.h>
namespace DB
{
namespace
{
SettingChange * find(SettingsChanges & changes, std::string_view name)
2020-07-22 12:02:47 +00:00
{
auto it = std::find_if(changes.begin(), changes.end(), [&name](const SettingChange & change) { return change.name == name; });
if (it == changes.end())
return nullptr;
return &*it;
}
const SettingChange * find(const SettingsChanges & changes, std::string_view name)
2020-07-22 12:02:47 +00:00
{
auto it = std::find_if(changes.begin(), changes.end(), [&name](const SettingChange & change) { return change.name == name; });
if (it == changes.end())
return nullptr;
return &*it;
}
}
bool SettingsChanges::tryGet(std::string_view name, Field & out_value) const
2020-07-22 12:02:47 +00:00
{
const auto * change = find(*this, name);
if (!change)
return false;
out_value = change->value;
return true;
}
const Field * SettingsChanges::tryGet(std::string_view name) const
2020-07-22 12:02:47 +00:00
{
const auto * change = find(*this, name);
if (!change)
return nullptr;
return &change->value;
}
Field * SettingsChanges::tryGet(std::string_view name)
2020-07-22 12:02:47 +00:00
{
auto * change = find(*this, name);
if (!change)
return nullptr;
return &change->value;
}
}