Skip to content
Snippets Groups Projects
Select Git revision
  • 517bd5f22beb3894e8146a348bae598c64334df1
  • master default
  • cmake_fixes
  • pulls/1772757862/750
  • copilot/fix-770
  • windows_ci_static
  • c_link
  • cpack
  • windows_ci
  • cert_pk_id
  • proxy_push_result
  • cnode_put_id
  • update-windows-build
  • proxy
  • resubscribe_on_token_change
  • actions
  • client_mode
  • llhttp
  • search_node_add
  • crypto_aes_gcm_argon2
  • ios_notifications
  • v3.4.0
  • v3.3.1
  • v3.3.1rc1
  • v3.3.1rc2
  • v3.3.0
  • v3.2.0
  • v3.1.11
  • v3.1.10
  • v3.1.9
  • v3.1.8.2
  • v3.1.8.1
  • v3.1.8
  • v3.1.7
  • v3.1.6
  • v3.1.5
  • v3.1.4
  • v3.1.3
  • v3.1.2
  • v3.1
  • v3.0.1
41 results

callbacks.cpp

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    callbacks.cpp 1.06 KiB
    #include "callbacks.h"
    
    namespace dht {
    
    
    GetCallbackSimple
    bindGetCb(GetCallbackRaw raw_cb, void* user_data)
    {
        if (not raw_cb) return {};
        return [=](const std::shared_ptr<Value>& value) {
            return raw_cb(value, user_data);
        };
    }
    
    GetCallback
    bindGetCb(GetCallbackSimple cb)
    {
        if (not cb) return {};
        return [=](const std::vector<std::shared_ptr<Value>>& values) {
            for (const auto& v : values)
                if (not cb(v))
                    return false;
            return true;
        };
    }
    
    ShutdownCallback
    bindShutdownCb(ShutdownCallbackRaw shutdown_cb_raw, void* user_data)
    {
        return [=]() { shutdown_cb_raw(user_data); };
    }
    
    DoneCallback
    bindDoneCb(DoneCallbackSimple donecb)
    {
        if (not donecb) return {};
        using namespace std::placeholders;
        return std::bind(donecb, _1);
    }
    
    DoneCallback
    bindDoneCb(DoneCallbackRaw raw_cb, void* user_data)
    {
        if (not raw_cb) return {};
        return [=](bool success, const std::vector<std::shared_ptr<Node>>& nodes) {
            raw_cb(success, (std::vector<std::shared_ptr<Node>>*)&nodes, user_data);
        };
    }
    
    }