Added two new classes for command options:

    lldb_private::OptionGroup
    lldb_private::OptionGroupOptions

OptionGroup lets you define a class that encapsulates settings that you want
to reuse in multiple commands. It contains only the option definitions and the
ability to set the option values, but it doesn't directly interface with the
lldb_private::Options class that is the front end to all of the CommandObject
option parsing. For that the OptionGroupOptions class can be used. It aggregates
one or more OptionGroup objects and directs the option setting to the 
appropriate OptionGroup class. For an example of this, take a look at the 
CommandObjectFile and how it uses its "m_option_group" object shown below
to be able to set values in both the FileOptionGroup and PlatformOptionGroup
classes. The members used in CommandObjectFile are:

    OptionGroupOptions m_option_group;
    FileOptionGroup m_file_options;
    PlatformOptionGroup m_platform_options;

Then in the constructor for CommandObjectFile you can combine the option
settings. The code below shows a simplified version of the constructor:

CommandObjectFile::CommandObjectFile(CommandInterpreter &interpreter) :
    CommandObject (...),
    m_option_group (interpreter),
    m_file_options (),
    m_platform_options(true)
{
    m_option_group.Append (&m_file_options);
    m_option_group.Append (&m_platform_options);
    m_option_group.Finalize();
}

We append the m_file_options and then the m_platform_options and then tell
the option group the finalize the results. This allows the m_option_group to
become the organizer of our prefs and after option parsing we end up with
valid preference settings in both the m_file_options and m_platform_options
objects. This also allows any other commands to use the FileOptionGroup and
PlatformOptionGroup classes to implement options for their commands.

Renamed:
    virtual void Options::ResetOptionValues();
to:
    virtual void Options::OptionParsingStarting();

And implemented a new callback named:

    virtual Error Options::OptionParsingFinished();
    
This allows Options subclasses to verify that the options all go together
after all of the options have been specified and gives the chance for the
command object to return an error. It also gives a chance to take all of the
option values and produce or initialize objects after all options have
completed parsing.

Modfied:

    virtual Error
    SetOptionValue (int option_idx, const char *option_arg) = 0;
    
to be:

    virtual Error
    SetOptionValue (uint32_t option_idx, const char *option_arg) = 0;

(option_idx is now unsigned).




git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@129415 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Commands/CommandObjectPlatform.h b/source/Commands/CommandObjectPlatform.h
index 994052e..255fc3b 100644
--- a/source/Commands/CommandObjectPlatform.h
+++ b/source/Commands/CommandObjectPlatform.h
@@ -15,6 +15,7 @@
 // Other libraries and framework includes
 // Project includes
 #include "lldb/Interpreter/CommandObjectMultiword.h"
+#include "lldb/Interpreter/Options.h"
 
 namespace lldb_private {
 
@@ -25,21 +26,74 @@
 class CommandObjectPlatform : public CommandObjectMultiword
 {
 public:
-    //------------------------------------------------------------------
-    // Constructors and Destructors
-    //------------------------------------------------------------------
     CommandObjectPlatform(CommandInterpreter &interpreter);
 
     virtual
     ~CommandObjectPlatform();
 
-private:
-    //------------------------------------------------------------------
-    // For CommandObjectPlatform only
-    //------------------------------------------------------------------
+    private:
     DISALLOW_COPY_AND_ASSIGN (CommandObjectPlatform);
 };
 
+    
+//-------------------------------------------------------------------------
+// PlatformOptionGroup
+//
+// Make platform options available to to any other command in case they 
+// need them. The "file" command needs them, and by exposing them we can
+// reuse the platform command options for any command, we can keep things
+// consistent.
+//-------------------------------------------------------------------------
+class PlatformOptionGroup : public OptionGroup
+{
+public:
+    
+    PlatformOptionGroup (bool include_platform_option) :
+        m_include_platform_option (include_platform_option),
+        platform_sp (),
+        os_version_major (UINT32_MAX),
+        os_version_minor (UINT32_MAX),
+        os_version_update (UINT32_MAX)
+    {
+    }
+    
+    virtual
+    ~PlatformOptionGroup ()
+    {
+    }
+    
+    virtual uint32_t
+    GetNumDefinitions ();
+    
+    virtual const OptionDefinition*
+    GetDefinitions ();
+    
+    virtual Error
+    SetOptionValue (CommandInterpreter &interpreter,
+                    uint32_t option_idx,
+                    const char *option_value);
+    
+    lldb::PlatformSP 
+    CreatePlatformWithOptions (CommandInterpreter &interpreter,
+                               const char *platform_name, 
+                               bool select, 
+                               Error& error);
+
+    virtual void
+    OptionParsingStarting (CommandInterpreter &interpreter);
+        
+    // Instance variables to hold the values for command options.
+    
+    lldb::PlatformSP platform_sp;
+    uint32_t os_version_major;
+    uint32_t os_version_minor;
+    uint32_t os_version_update;
+protected:
+    bool m_include_platform_option;
+};
+
+    
+    
 } // namespace lldb_private
 
 #endif  // liblldb_CommandObjectPlatform_h_