Home | History | Annotate | Download | only in Commands
      1 //===-- 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"
     18 #include "lldb/Interpreter/Options.h"
     19 
     20 namespace lldb_private {
     21 
     22 //-------------------------------------------------------------------------
     23 // CommandObjectHelp
     24 //-------------------------------------------------------------------------
     25 
     26 class CommandObjectHelp : public CommandObjectParsed
     27 {
     28 public:
     29 
     30     CommandObjectHelp (CommandInterpreter &interpreter);
     31 
     32     virtual
     33     ~CommandObjectHelp ();
     34 
     35     virtual int
     36     HandleCompletion (Args &input,
     37                       int &cursor_index,
     38                       int &cursor_char_position,
     39                       int match_start_point,
     40                       int max_return_elements,
     41                       bool &word_complete,
     42                       StringList &matches);
     43 
     44     class CommandOptions : public Options
     45     {
     46     public:
     47 
     48         CommandOptions (CommandInterpreter &interpreter) :
     49         Options (interpreter)
     50         {
     51         }
     52 
     53         virtual
     54         ~CommandOptions (){}
     55 
     56         virtual Error
     57         SetOptionValue (uint32_t option_idx, const char *option_arg)
     58         {
     59             Error error;
     60             const int short_option = m_getopt_table[option_idx].val;
     61 
     62             switch (short_option)
     63             {
     64                 case 'a':
     65                     m_show_aliases = true;
     66                     break;
     67                 case 'u':
     68                     m_show_user_defined = false;
     69                     break;
     70                 default:
     71                     error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
     72                     break;
     73             }
     74 
     75             return error;
     76         }
     77 
     78         void
     79         OptionParsingStarting ()
     80         {
     81             m_show_aliases = false;
     82             m_show_user_defined = true;
     83         }
     84 
     85         const OptionDefinition*
     86         GetDefinitions ()
     87         {
     88             return g_option_table;
     89         }
     90 
     91         // Options table: Required for subclasses of Options.
     92 
     93         static OptionDefinition g_option_table[];
     94 
     95         // Instance variables to hold the values for command options.
     96 
     97         bool m_show_aliases;
     98         bool m_show_user_defined;
     99     };
    100 
    101     virtual Options *
    102     GetOptions ()
    103     {
    104         return &m_options;
    105     }
    106 
    107 protected:
    108     virtual bool
    109     DoExecute (Args& command,
    110              CommandReturnObject &result);
    111 
    112 private:
    113     CommandOptions m_options;
    114 
    115 };
    116 
    117 } // namespace lldb_private
    118 
    119 #endif  // liblldb_CommandObjectHelp_h_
    120