use range-v3 lib to drop spec version further

master
bqv 3 years ago
parent c0efb9f632
commit 1dc6c8bdf8
No known key found for this signature in database
GPG Key ID: 9E2FF3BDEBDFC910

3
.gitmodules vendored

@ -7,3 +7,6 @@
[submodule "deps/optional"] [submodule "deps/optional"]
path = deps/optional path = deps/optional
url = https://github.com/TartanLlama/optional url = https://github.com/TartanLlama/optional
[submodule "deps/range-v3"]
path = deps/range-v3
url = https://github.com/ericniebler/range-v3

1
deps/range-v3 vendored

@ -0,0 +1 @@
Subproject commit d800a032132512a54c291ce55a2a43e0460591c7

@ -8,7 +8,7 @@ FIND ?= find
CC = gcc CC = gcc
CXX = g++ CXX = g++
INCLUDES=-Ilibstrophe -Ideps -Ideps/optional/include -Ideps/fmt/include \ INCLUDES=-Ilibstrophe -Ideps -Ideps/optional/include -Ideps/range-v3/include -Ideps/fmt/include \
$(shell xml2-config --cflags) \ $(shell xml2-config --cflags) \
$(shell pkg-config --cflags gpgme) \ $(shell pkg-config --cflags gpgme) \
$(shell pkg-config --cflags libsignal-protocol-c) $(shell pkg-config --cflags libsignal-protocol-c)
@ -174,11 +174,11 @@ depend: $(SRCS) $(HDRS)
echo > ./.depend echo > ./.depend
for src in $(SRCS) ; do \ for src in $(SRCS) ; do \
if [[ $$src == *.cpp ]]; then \ if [[ $$src == *.cpp ]]; then \
$(CXX) $(CPPFLAGS) -MM -MMD -MP -MF - \ g++ $(CPPFLAGS) -MM -MMD -MP -MF - \
-MT .$${src/.cpp/.o} $$src >> ./.depend ; \ -MT .$${src/.cpp/.o} $$src >> ./.depend || true ; \
elif [[ $$src == *.c ]]; then \ elif [[ $$src == *.c ]]; then \
$(CC) $(CFLAGS) -MM -MMD -MP -MF - \ gcc $(CFLAGS) -MM -MMD -MP -MF - \
-MT .$${src/.c/.o} $$src >> ./.depend ; \ -MT .$${src/.c/.o} $$src >> ./.depend || true ; \
fi \ fi \
done done
sed -i 's/\.\([a-z]*\/\)/\1./' .depend sed -i 's/\.\([a-z]*\/\)/\1./' .depend

@ -5,8 +5,6 @@
#include <fmt/core.h> #include <fmt/core.h>
#include <memory> #include <memory>
#include <numeric> #include <numeric>
#include <optional>
#include <ranges>
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <string_view> #include <string_view>
@ -17,6 +15,7 @@
#include <math.h> #include <math.h>
#include <limits.h> #include <limits.h>
#include <tl/optional.hpp> #include <tl/optional.hpp>
#include <range/v3/all.hpp>
#include <strophe.h> #include <strophe.h>
#include <weechat/weechat-plugin.h> #include <weechat/weechat-plugin.h>
@ -1614,9 +1613,9 @@ int dls_load_devicelist(signal_int_list **devicelist, const char *jid, t_omemo *
omemo->dbi.omemo.get(transaction, k_devicelist, v_devicelist); omemo->dbi.omemo.get(transaction, k_devicelist, v_devicelist);
auto devices = v_devicelist auto devices = v_devicelist
| std::ranges::views::split(';') | ranges::views::split(';')
| std::ranges::views::transform([](auto&& str) { | ranges::views::transform([](auto&& str) {
return std::stoul(std::string(&*str.begin(), std::ranges::distance(str))); return std::stoul(std::string(&*str.begin(), ranges::distance(str)));
}); });
*devicelist = signal_int_list_alloc(); *devicelist = signal_int_list_alloc();
@ -1718,9 +1717,9 @@ tl::optional<libsignal::pre_key_bundle> bks_load_bundle(struct signal_protocol_a
omemo->dbi.omemo.get(transaction, k_bundle_ik, v_bundle_ik); omemo->dbi.omemo.get(transaction, k_bundle_ik, v_bundle_ik);
auto r_bundle_pks = v_bundle_pk auto r_bundle_pks = v_bundle_pk
| std::ranges::views::split(';') | ranges::views::split(';')
| std::ranges::views::transform([](auto&& str) { | ranges::views::transform([](auto&& str) {
return std::string_view(&*str.begin(), std::ranges::distance(str)); return std::string_view(&*str.begin(), ranges::distance(str));
}); });
auto bundle_pks = std::vector<std::string>{r_bundle_pks.begin(), r_bundle_pks.begin()}; auto bundle_pks = std::vector<std::string>{r_bundle_pks.begin(), r_bundle_pks.begin()};
if (bundle_pks.size() > 0) if (bundle_pks.size() > 0)
@ -1739,9 +1738,9 @@ tl::optional<libsignal::pre_key_bundle> bks_load_bundle(struct signal_protocol_a
libsignal::public_key pre_key(key_buf, key_len, omemo->context); libsignal::public_key pre_key(key_buf, key_len, omemo->context);
auto r_bundle_sks = v_bundle_sk auto r_bundle_sks = v_bundle_sk
| std::ranges::views::split(';') | ranges::views::split(';')
| std::ranges::views::transform([](auto&& str) { | ranges::views::transform([](auto&& str) {
return std::string_view(&*str.begin(), std::ranges::distance(str)); return std::string_view(&*str.begin(), ranges::distance(str));
}); });
auto bundle_sks = std::vector<std::string>{r_bundle_sks.begin(), r_bundle_sks.begin()}; auto bundle_sks = std::vector<std::string>{r_bundle_sks.begin(), r_bundle_sks.begin()};
if (bundle_sks.size() > 0) if (bundle_sks.size() > 0)

@ -48,7 +48,7 @@ namespace libsignal {
template<typename Fun, Fun &func, typename... Args, template<typename Fun, Fun &func, typename... Args,
typename = std::enable_if_t<!std::is_same_v<int, std::invoke_result_t<Fun, pointer_type, Args...>>>> typename = std::enable_if_t<!std::is_same_v<int, std::invoke_result_t<Fun, pointer_type, Args...>>>>
inline std::invoke_result<Fun, pointer_type, Args...>::type inline typename std::invoke_result<Fun, pointer_type, Args...>::type
call(Args&&... args) { call(Args&&... args) {
return func(*this, std::forward<Args>(args)...); return func(*this, std::forward<Args>(args)...);
} }

@ -108,7 +108,12 @@ namespace xml {
} }
namespace stanza { namespace stanza {
template<class... Ts> struct overloaded : Ts... { using Ts::operator()...; }; template<class... Fs> struct overloaded : Fs... {
overloaded(const Fs& ...ts) : Fs{ts}... {}
overloaded(Fs&& ...ts) : Fs{ts}... {}
using Fs::operator()...;
};
template<class... Ts> overloaded(Ts&&...) -> overloaded<std::decay_t<Ts>...>;
extern std::string uuid(xmpp_ctx_t *context); extern std::string uuid(xmpp_ctx_t *context);
@ -150,7 +155,7 @@ namespace stanza {
[&](spec& child) { [&](spec& child) {
xmpp_stanza_add_child(stanza, child.build(context).get()); xmpp_stanza_add_child(stanza, child.build(context).get());
}, },
[&](std::string s) { [&](std::string& s) {
auto child = xmpp_stanza_new(context); auto child = xmpp_stanza_new(context);
xmpp_stanza_set_text(child, s.data()); xmpp_stanza_set_text(child, s.data());
xmpp_stanza_add_child(stanza, child); xmpp_stanza_add_child(stanza, child);

Loading…
Cancel
Save