]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Interpreter/CommandAlias.h
Merge clang 7.0.1 and several follow-up changes
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Interpreter / CommandAlias.h
1 //===-- CommandAlias.h -----------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef liblldb_CommandAlias_h_
11 #define liblldb_CommandAlias_h_
12
13 // C Includes
14 // C++ Includes
15 #include <memory>
16
17 // Other libraries and framework includes
18 // Project includes
19 #include "lldb/Interpreter/CommandObject.h"
20 #include "lldb/Utility/Args.h"
21 #include "lldb/Utility/CompletionRequest.h"
22 #include "lldb/lldb-forward.h"
23
24 namespace lldb_private {
25 class CommandAlias : public CommandObject {
26 public:
27   typedef std::unique_ptr<CommandAlias> UniquePointer;
28
29   CommandAlias(CommandInterpreter &interpreter, lldb::CommandObjectSP cmd_sp,
30                llvm::StringRef options_args, llvm::StringRef name,
31                llvm::StringRef help = llvm::StringRef(),
32                llvm::StringRef syntax = llvm::StringRef(), uint32_t flags = 0);
33
34   void GetAliasExpansion(StreamString &help_string) const;
35
36   bool IsValid() const { return m_underlying_command_sp && m_option_args_sp; }
37
38   explicit operator bool() const { return IsValid(); }
39
40   bool WantsRawCommandString() override;
41
42   bool WantsCompletion() override;
43
44   int HandleCompletion(CompletionRequest &request) override;
45
46   int HandleArgumentCompletion(
47       CompletionRequest &request,
48       OptionElementVector &opt_element_vector) override;
49
50   Options *GetOptions() override;
51
52   bool IsAlias() override { return true; }
53
54   bool IsDashDashCommand() override;
55
56   llvm::StringRef GetHelp() override;
57
58   llvm::StringRef GetHelpLong() override;
59
60   void SetHelp(llvm::StringRef str) override;
61
62   void SetHelpLong(llvm::StringRef str) override;
63
64   bool Execute(const char *args_string, CommandReturnObject &result) override;
65
66   lldb::CommandObjectSP GetUnderlyingCommand() {
67     return m_underlying_command_sp;
68   }
69   OptionArgVectorSP GetOptionArguments() const { return m_option_args_sp; }
70   const char *GetOptionString() { return m_option_string.c_str(); }
71
72   // this takes an alias - potentially nested (i.e. an alias to an alias) and
73   // expands it all the way to a non-alias command
74   std::pair<lldb::CommandObjectSP, OptionArgVectorSP> Desugar();
75
76 protected:
77   bool IsNestedAlias();
78
79 private:
80   lldb::CommandObjectSP m_underlying_command_sp;
81   std::string m_option_string;
82   OptionArgVectorSP m_option_args_sp;
83   LazyBool m_is_dashdash_alias;
84   bool m_did_set_help : 1;
85   bool m_did_set_help_long : 1;
86 };
87 } // namespace lldb_private
88
89 #endif // liblldb_CommandAlias_h_