aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Support
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-07-23 02:35:57 +0000
committerChris Lattner <sabre@nondot.org>2001-07-23 02:35:57 +0000
commit8f367bd3c0f56b7b318c46cee04f77735f617777 (patch)
treeef00b00e2465f9168bbbd83fd2ebef8fa857146f /include/llvm/Support
parenta28504313d4c3fe87173a71b511dd4c8e25c3312 (diff)
downloadexternal_llvm-8f367bd3c0f56b7b318c46cee04f77735f617777.zip
external_llvm-8f367bd3c0f56b7b318c46cee04f77735f617777.tar.gz
external_llvm-8f367bd3c0f56b7b318c46cee04f77735f617777.tar.bz2
Large scale changes to implement new command line argument facility
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support')
-rw-r--r--include/llvm/Support/ProgramOption.h142
-rw-r--r--include/llvm/Support/ProgramOptions.h145
2 files changed, 0 insertions, 287 deletions
diff --git a/include/llvm/Support/ProgramOption.h b/include/llvm/Support/ProgramOption.h
deleted file mode 100644
index 83eeac6..0000000
--- a/include/llvm/Support/ProgramOption.h
+++ /dev/null
@@ -1,142 +0,0 @@
-// $Id$ -*-c++-*-
-//***************************************************************************
-//
-// File:
-// ProgramOption.h
-//
-// Purpose:
-// General representations for a program option.
-//
-// History:
-// 08/08/95 - adve - created in the dHPF compiler
-// 11/26/96 - adve - EvalOpt now returns #args consumed, or -1 for error
-// 07/15/01 - vadve - Copied to LLVM system and modified
-//
-//**************************************************************************/
-
-#ifndef LLVM_SUPPORT_PROGRAMOPTION_H
-#define LLVM_SUPPORT_PROGRAMOPTION_H
-
-#include "llvm/Support/Unique.h"
-#include <string>
-
-
-class ProgramOption: public Unique {
-public:
- /*ctor*/ ProgramOption (const string &_argString,
- const string &_helpMesg,
- int _minExpectedArgs = 1)
- : optionSpecified(false),
- argString(_argString),
- helpMesg(_helpMesg),
- minExpectedArgs(_minExpectedArgs) {}
-
- /*dtor*/ virtual ~ProgramOption() {}
-
- // Pure virtual function for an option with 0 or more arguments.
- // `optarg' points to the start of the next word in argv[].
- // It will be NULL if there are no more words.
- // The return value indicates the number of words of argv[] that
- // were consumed by EvalOpt and should be discarded.
- // A return value of -1 indicates an error.
- //
- virtual int EvalOpt (const string &) = 0;
-
- // Returns the value associated with the option as a human-readable
- // string.
- virtual string GetTextValue () const = 0;
-
- // Inline accessor functions for common option information
- //
- bool OptionSpecified () const { return optionSpecified; }
- const string ArgString () const { return argString; }
- const string HelpMesg () const { return helpMesg; }
- int MinExpectedArgs () const { return minExpectedArgs; }
-
-protected:
- bool optionSpecified;
- string argString;
- string helpMesg;
- int minExpectedArgs;
-};
-
-//**************************************************************************/
-
-class StringOption : public ProgramOption {
-public:
- /*ctor*/ StringOption (const string &argString,
- const string &helpMesg,
- const string &initValue = "",
- bool append = false);
- // append = false: EvalOpt will overwrite preexisting value
- // append = true : EvalOpt will append <optArg> to value
-
- /*dtor*/ virtual ~StringOption () {}
-
- virtual int EvalOpt (const string &optarg);
-
- const string &Value() const { return value; }
- virtual string GetTextValue() const { return value; }
-
-protected:
- string value;
- bool append;
-};
-
-//**************************************************************************/
-
-// -<flag_opt> sets the flag to TRUE
-// -<flag_opt> 0 sets the flag to FALSE
-//
-// To provide an actual argument (not option) of "0", mark the
-// end of the options with "--" (see getopt(1)).
-
-class FlagOption : public ProgramOption {
-public:
- FlagOption(const string &argString, const string &helpMesg,
- bool initValue = false);
-
- virtual ~FlagOption() {}
-
- virtual int EvalOpt (const string &optarg);
-
- bool Value () const { return value; }
- virtual string GetTextValue() const { return value ? "true" : "false";}
-private:
- bool value;
-};
-
-//**************************************************************************/
-
-class RealValuedOption : public ProgramOption {
-public:
- /*ctor*/ RealValuedOption(const string &argString,
- const string &helpMesg,
- double initValue = 0.0);
- /*dtor*/ virtual ~RealValuedOption() {}
-
- virtual int EvalOpt (const string &optarg);
-
- double Value () const { return value; }
- virtual string GetTextValue() const;
-
-private:
- double value;
-};
-
-//**************************************************************************/
-
-class IntegerValuedOption : public RealValuedOption {
-public:
- /*ctor*/ IntegerValuedOption(const string &argString,
- const string &helpMesg,
- int initValue = 0);
- /*ctor*/ virtual ~IntegerValuedOption() {}
-
- int Value() const;
- virtual string GetTextValue() const;
-};
-
-//**************************************************************************/
-
-#endif
diff --git a/include/llvm/Support/ProgramOptions.h b/include/llvm/Support/ProgramOptions.h
deleted file mode 100644
index 9ebc975..0000000
--- a/include/llvm/Support/ProgramOptions.h
+++ /dev/null
@@ -1,145 +0,0 @@
-// $Id$ -*-c++-*-
-//***************************************************************************
-//
-// File:
-// ProgramOptions.h
-//
-// Purpose:
-// A representation of options for any program.
-//
-// History:
-// 08/08/95 - adve - Created in the dHPF compiler
-// 10/10/96 - mpal, dbaker - converted to const member functions.
-// 10/19/96 - meven - slightly changed interface to accomodate
-// arguments other than -X type options
-// 07/15/01 - vadve - Copied to LLVM system and modified
-//
-//**************************************************************************/
-
-#ifndef LLVM_SUPPORT_PROGRAMOPTIONS_H
-#define LLVM_SUPPORT_PROGRAMOPTIONS_H
-
-#include "llvm/Support/Unique.h"
-#include <vector>
-#include <hash_map>
-#include <string>
-
-template <> struct hash<string> {
- size_t operator()(string const &str) const {
- return hash<char const *>()(str.c_str());
- }
-};
-
-class ProgramOption;
-
-//---------------------------------------------------------------------------
-//
-// Class: ProgramOptions
-//
-// Base Classes: none
-//
-// Class Data Members:
-// ProgramOptionsRepr* Internal representation of program options,
-// accessible to derived classes.
-// Purpose:
-// Base class for representing the set of options for a program.
-//
-//---------------------------------------------------------------------------
-
-class ProgramOptions: public Unique {
-public:
- /*ctor*/ ProgramOptions (int _argc,
- const char* _argv[],
- const char* _envp[]);
- /*dtor*/ ~ProgramOptions () {}
-
- //--------------------------------------------------------------------
- // Retrieving different kinds of arguments.
- // The required argument is specified by the optionString.
- //--------------------------------------------------------------------
-
- string StringOptionValue(const string &optionString) const;
- bool FlagOptionValue (const string &optionString) const;
- double RealOptionValue (const string &optionString) const;
- int IntOptionValue (const string &optionString) const;
-
- bool OptionSpecified (const string &optionString) const;
-
- //--------------------------------------------------------------------
- // The name used to invoke this program.
- //--------------------------------------------------------------------
- const char* ProgramName () const;
-
- //--------------------------------------------------------------------
- // Access to unparsed arguments
- //--------------------------------------------------------------------
- int NumberOfOtherOptions() const;
- const char* OtherOption(int i) const;
-
- //--------------------------------------------------------------------
- // Access to the original arguments
- //--------------------------------------------------------------------
- const char** GetOriginalArgs() const;
- void PrintArgs(ostream &out) const;
-
- //--------------------------------------------------------------------
- // Derived classes may use PrintOptions in their own PrintUsage() fct
- // to print information about optional, required, or additional
- // arguments
- //--------------------------------------------------------------------
- virtual void PrintOptions (ostream& stream) const;
- virtual void Usage () const;
-
- //--------------------------------------------------------------------
- // Generate a human-friendly description of the options actually set.
- // The vector returned contains a multiple of 3 of entries, entry 3n is
- // the name of the option, entry 3n + 1 contains the description of
- // the option and entry 3n + 2 contains the ascii value of the option.
- // All entries are allocated using malloc and can be freed with 'free'.
- //--------------------------------------------------------------------
- virtual vector<string> GetDescription () const;
-
-protected:
- //--------------------------------------------------------------------
- // Called by the subclass to register each possible option
- // used by the program. Assumes ownership of the ProgramOption.
- //--------------------------------------------------------------------
- void Register (ProgramOption* option);
-
- //--------------------------------------------------------------------
- // Parses the options.
- //--------------------------------------------------------------------
- void ParseArgs (int argc,
- const char* argv[],
- const char* envp[]);
-
- inline ProgramOption* OptionHandler(const string &optString) {
- hash_map<string, ProgramOption*>::iterator hp =
- optionRegistry.find(optString);
- return (hp != optionRegistry.end()) ? hp->second : 0;
- }
- inline const ProgramOption* OptionHandler(const string &optString) const {
- hash_map<string, ProgramOption*>::const_iterator hp =
- optionRegistry.find(optString);
- return (hp != optionRegistry.end()) ? hp->second : 0;
- }
-protected:
- //--------------------------------------------------------------------
- // Functions that must be overridden by the subclass.
- //--------------------------------------------------------------------
-
- virtual void ParseExtraArgs () = 0; // called after successful ParseArgs
-
- virtual void PrintUsage (ostream& stream) const = 0;
-
-protected:
- hash_map<string, ProgramOption*> optionRegistry;
- int argc;
- const char** argv;
- const char** envp;
- int argsConsumed;
-};
-
-//**************************************************************************/
-
-#endif