Skip to content

Commit

Permalink
Correction of 5860
Browse files Browse the repository at this point in the history
  • Loading branch information
alabuzhev committed Jul 30, 2021
1 parent fcb765f commit 4f5e13c
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 11 deletions.
5 changes: 5 additions & 0 deletions far/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
--------------------------------------------------------------------------------
drkns 30.07.2021 02:27:00 +0100 - build 5861

1. Correction of 5860.

--------------------------------------------------------------------------------
drkns 29.07.2021 23:04:52 +0100 - build 5860

Expand Down
25 changes: 25 additions & 0 deletions far/common/string_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,4 +657,29 @@ constexpr auto make_string_view(T const Begin, T const End) noexcept
return std::basic_string_view<char_type>{ Size ? &*Begin : nullptr, Size };
}

class lvalue_string_view
{
public:
lvalue_string_view() = default;

lvalue_string_view(string_view const Str):
m_Str(Str)
{
}

lvalue_string_view(string const& Str):
m_Str(Str)
{}

lvalue_string_view(string&& Str) = delete;

operator string_view() const
{
return m_Str;
}

private:
string_view m_Str;
};

#endif // STRING_UTILS_HPP_DE39ECEB_2377_44CB_AF4B_FA5BEA09C8C8
16 changes: 7 additions & 9 deletions far/configdb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Common:
#include "common/bytes_view.hpp"
#include "common/enumerator.hpp"
#include "common/keep_alive.hpp"
#include "common/noncopyable.hpp"
#include "common/string_utils.hpp"

// External:

Expand Down Expand Up @@ -98,16 +98,14 @@ class GeneralConfig : public representable, virtual public transactional

virtual void DeleteValue(string_view Key, string_view Name) = 0;

template<typename T, typename key_type>
template<typename T>
[[nodiscard]]
auto ValuesEnumerator(key_type&& Key) const
auto ValuesEnumerator(lvalue_string_view const Key) const
{
static_assert(std::is_convertible_v<key_type, string_view>);

using value_type = std::pair<string, T>;
return make_inline_enumerator<value_type>([this, Key = keep_alive(FWD(Key))](const bool Reset, value_type& Value)
return make_inline_enumerator<value_type>([=, this](const bool Reset, value_type& Value)
{
return EnumValues(Key.get(), Reset, Value.first, Value.second);
return EnumValues(Key, Reset, Value.first, Value.second);
},
[this]
{
Expand Down Expand Up @@ -451,10 +449,10 @@ class HistoryConfig: public representable, virtual public transactional
};

[[nodiscard]]
auto Enumerator(unsigned int const HistoryType, string_view const HistoryName, string_view const ItemName = {}, bool const Reverse = false)
auto Enumerator(unsigned int const HistoryType, lvalue_string_view const HistoryName, lvalue_string_view const ItemName = {}, bool const Reverse = false)
{
using value_type = enum_data;
return make_inline_enumerator<value_type>([&](const bool Reset, value_type& Value)
return make_inline_enumerator<value_type>([=, this](const bool Reset, value_type& Value)
{
return Enum(Reset, HistoryType, HistoryName, ItemName, Value.Id, Value.Name, Value.Type, Value.Lock, Value.Time, Value.Uuid, Value.File, Value.Data, Reverse);
},
Expand Down
4 changes: 3 additions & 1 deletion far/keybar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,9 @@ void KeyBar::SetCustomLabels(KEYBARAREA Area)
CustomArea = Area;
ClearKeyTitles(true);

for (const auto& [Name, Value]: ConfigProvider().GeneralCfg()->ValuesEnumerator<string>(concat(L"KeyBarLabels."sv, strLanguage, L'.', Names[Area])))
const auto LabelsKey = concat(L"KeyBarLabels."sv, strLanguage, L'.', Names[Area]);

for (const auto& [Name, Value]: ConfigProvider().GeneralCfg()->ValuesEnumerator<string>(LabelsKey))
{
const auto Key = KeyNameToKey(Name);
if (!Key)
Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5860
5861

0 comments on commit 4f5e13c

Please sign in to comment.