mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-18 21:51:57 +00:00
51 lines
1.3 KiB
C++
51 lines
1.3 KiB
C++
|
#include <Common/SettingsChanges.h>
|
||
|
|
||
|
|
||
|
namespace DB
|
||
|
{
|
||
|
namespace
|
||
|
{
|
||
|
SettingChange * find(SettingsChanges & changes, const std::string_view & name)
|
||
|
{
|
||
|
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, const std::string_view & name)
|
||
|
{
|
||
|
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(const std::string_view & name, Field & out_value) const
|
||
|
{
|
||
|
const auto * change = find(*this, name);
|
||
|
if (!change)
|
||
|
return false;
|
||
|
out_value = change->value;
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
const Field * SettingsChanges::tryGet(const std::string_view & name) const
|
||
|
{
|
||
|
const auto * change = find(*this, name);
|
||
|
if (!change)
|
||
|
return nullptr;
|
||
|
return &change->value;
|
||
|
}
|
||
|
|
||
|
Field * SettingsChanges::tryGet(const std::string_view & name)
|
||
|
{
|
||
|
auto * change = find(*this, name);
|
||
|
if (!change)
|
||
|
return nullptr;
|
||
|
return &change->value;
|
||
|
}
|
||
|
|
||
|
}
|