CLI for C++ Project Page CLI for C++ Home Page

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

Option.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2005 John H. Poplett. All rights reserved.
00003  * 
00004  * This software is provided 'as-is', without any express or implied
00005  * warranty. In no event will the authors be held liable for any damages
00006  * arising from the use of this software.
00007  * 
00008  * Permission is granted to anyone to use this software for any purpose,
00009  * including commercial applications, and to alter it and redistribute it
00010  * freely, subject to the following restrictions:
00011  * 
00012  *     1. The origin of this software must not be misrepresented; you must
00013  *     not claim that you wrote the original software. If you use this
00014  *     software in a product, an acknowledgment in the product documentation
00015  *     would be appreciated but is not required.
00016  * 
00017  *     2. Altered source versions must be plainly marked as such, and must
00018  *     not be misrepresented as being the original software.
00019  * 
00020  *     3. This notice may not be removed or altered from any source
00021  *     distribution.
00022  */
00023 #ifndef _Option_h_included
00024 #define  _Option_h_included
00025 
00026 #include <string>
00027 #include <vector>
00028 
00029 namespace CLI {
00030 
00037 class Option {
00038     public:
00044         enum Args {
00045             NO_ARGS,
00046             ONE_ARG,
00047             AT_LEAST_ONE_ARG,
00048             MANY_ARGS
00049         };
00050 
00051         Option();
00052 
00053         Option(const Option&);
00054         Option& operator=(const Option&);
00055 
00063         Option(const char* const option, const bool hasArg, const char* const description);
00064 
00072         Option(const char* const option, const Args takesArgs, const char* const description);
00073 
00081         Option(const char* const option, const char* const description);
00082 
00091         Option(const char* const option, const char* const longOption, const bool hasArg, const char* const description);
00100         Option(const char* const option, const char* const longOption, const Args takesArgs, const char* const description);
00101 
00102 
00103         ~Option();
00104 
00109         std::string getArgName() const;
00110 
00114         std::string getOpt() const;
00118         std::string getLongOpt() const;
00122         bool hasLongOpt() const;
00123 
00131         std::string getDescription() const;
00132 
00140         int getId() const;
00141 
00145         std::string getValue() const;
00146 
00153         std::string getValue(const char* const defaultValue) const;
00154 
00155 
00161         std::string getValue(const unsigned index) const;
00162 
00163         std::vector<std::string> getValues() const;
00164 
00168         bool hasArgName() const;
00169 
00170         bool hasArg() const;
00171         bool hasArgs() const;
00172 
00180         void setArgName(const std::string& argName);
00181 
00189         void setArgs(const Args takesArgs);
00190 
00195         void addValue(const std::string& value);
00196 
00197     private:
00198         class Implementation;
00199         Implementation* impl_;
00200 };
00201 
00202 
00203 } 
00204 
00205 #endif // #ifndef _Option_h_included

SourceForge Logo hosts this site. Send comments to:
John Poplett