cmDebuggerVariablesManager.cxx 928 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmDebuggerVariablesManager.h"
  4. #include <utility>
  5. #include <cm3p/cppdap/protocol.h>
  6. #include <cm3p/cppdap/types.h>
  7. namespace cmDebugger {
  8. void cmDebuggerVariablesManager::RegisterHandler(
  9. int64_t id,
  10. std::function<dap::array<dap::Variable>(dap::VariablesRequest const&)>
  11. handler)
  12. {
  13. VariablesHandlers[id] = std::move(handler);
  14. }
  15. void cmDebuggerVariablesManager::UnregisterHandler(int64_t id)
  16. {
  17. VariablesHandlers.erase(id);
  18. }
  19. dap::array<dap::Variable> cmDebuggerVariablesManager::HandleVariablesRequest(
  20. dap::VariablesRequest const& request)
  21. {
  22. auto it = VariablesHandlers.find(request.variablesReference);
  23. if (it != VariablesHandlers.end()) {
  24. return it->second(request);
  25. }
  26. return dap::array<dap::Variable>();
  27. }
  28. } // namespace cmDebugger