blob: c0890489fa7f0deefdb65196123e86b5bd167a33 [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001//===-- CommandObjectHelp.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_CommandObjectHelp_h_
11#define liblldb_CommandObjectHelp_h_
12
13// C Includes
14// C++ Includes
15// Other libraries and framework includes
16// Project includes
17#include "lldb/Interpreter/CommandObject.h"
Enrico Granata1ac6d1f2011-09-09 17:49:36 +000018#include "lldb/Interpreter/Options.h"
Chris Lattner24943d22010-06-08 16:52:24 +000019
20namespace lldb_private {
21
22//-------------------------------------------------------------------------
23// CommandObjectHelp
24//-------------------------------------------------------------------------
25
26class CommandObjectHelp : public CommandObject
27{
28public:
29
Greg Clayton238c0a12010-09-18 01:14:36 +000030 CommandObjectHelp (CommandInterpreter &interpreter);
Chris Lattner24943d22010-06-08 16:52:24 +000031
32 virtual
33 ~CommandObjectHelp ();
34
Chris Lattner24943d22010-06-08 16:52:24 +000035 virtual bool
Greg Clayton238c0a12010-09-18 01:14:36 +000036 Execute (Args& command,
Chris Lattner24943d22010-06-08 16:52:24 +000037 CommandReturnObject &result);
38
39 virtual int
Greg Clayton238c0a12010-09-18 01:14:36 +000040 HandleCompletion (Args &input,
Chris Lattner24943d22010-06-08 16:52:24 +000041 int &cursor_index,
42 int &cursor_char_position,
43 int match_start_point,
44 int max_return_elements,
Jim Ingham802f8b02010-06-30 05:02:46 +000045 bool &word_complete,
Chris Lattner24943d22010-06-08 16:52:24 +000046 StringList &matches);
Enrico Granata1ac6d1f2011-09-09 17:49:36 +000047
48 class CommandOptions : public Options
49 {
50 public:
51
52 CommandOptions (CommandInterpreter &interpreter) :
53 Options (interpreter)
54 {
55 }
56
57 virtual
58 ~CommandOptions (){}
59
60 virtual Error
61 SetOptionValue (uint32_t option_idx, const char *option_arg)
62 {
63 Error error;
64 char short_option = (char) m_getopt_table[option_idx].val;
65
66 switch (short_option)
67 {
68 case 'a':
69 m_show_aliases = true;
70 break;
71 case 'u':
72 m_show_user_defined = false;
73 break;
74 default:
75 error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option);
76 break;
77 }
78
79 return error;
80 }
81
82 void
83 OptionParsingStarting ()
84 {
85 m_show_aliases = false;
86 m_show_user_defined = true;
87 }
88
89 const OptionDefinition*
90 GetDefinitions ()
91 {
92 return g_option_table;
93 }
94
95 // Options table: Required for subclasses of Options.
96
97 static OptionDefinition g_option_table[];
98
99 // Instance variables to hold the values for command options.
100
101 bool m_show_aliases;
102 bool m_show_user_defined;
103 };
104
105 CommandOptions m_options;
106
107 virtual Options *
108 GetOptions ()
109 {
110 return &m_options;
111 }
Chris Lattner24943d22010-06-08 16:52:24 +0000112
113};
114
115} // namespace lldb_private
116
117#endif // liblldb_CommandObjectHelp_h_