51 lines · c
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLDB_TOOLS_LLDB_DAP_CLIENTLAUNCHER_H10#define LLDB_TOOLS_LLDB_DAP_CLIENTLAUNCHER_H11 12#include "llvm/ADT/StringRef.h"13#include "llvm/Support/Error.h"14#include <vector>15 16namespace lldb_dap {17 18class ClientLauncher {19public:20 enum Client {21 VSCode,22 VSCodeURL,23 };24 25 virtual ~ClientLauncher() = default;26 virtual llvm::Error Launch(const std::vector<llvm::StringRef> args) = 0;27 28 static std::optional<Client> GetClientFrom(llvm::StringRef str);29 static std::unique_ptr<ClientLauncher> GetLauncher(Client client);30};31 32class VSCodeLauncher : public ClientLauncher {33public:34 using ClientLauncher::ClientLauncher;35 36 llvm::Error Launch(const std::vector<llvm::StringRef> args) override;37 38 std::string GetLaunchURL(const std::vector<llvm::StringRef> args) const;39 static std::string URLEncode(llvm::StringRef str);40};41 42class VSCodeURLPrinter : public VSCodeLauncher {43 using VSCodeLauncher::VSCodeLauncher;44 45 llvm::Error Launch(const std::vector<llvm::StringRef> args) override;46};47 48} // namespace lldb_dap49 50#endif51