cmDebuggerVariablesManager.cxx 944 B

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