PixelLightAPI  .
CommandLineOption.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: CommandLineOption.h                            *
00003  *
00004  *  Copyright (C) 2002-2011 The PixelLight Team (http://www.pixellight.org/)
00005  *
00006  *  This file is part of PixelLight.
00007  *
00008  *  PixelLight is free software: you can redistribute it and/or modify
00009  *  it under the terms of the GNU Lesser General Public License as published by
00010  *  the Free Software Foundation, either version 3 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  PixelLight is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  *  GNU Lesser General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU Lesser General Public License
00019  *  along with PixelLight. If not, see <http://www.gnu.org/licenses/>.
00020 \*********************************************************/
00021 
00022 
00023 #ifndef __PLCORE_COMMANDLINEOPTION_H__
00024 #define __PLCORE_COMMANDLINEOPTION_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include "PLCore/String/String.h"
00032 
00033 
00034 //[-------------------------------------------------------]
00035 //[ Namespace                                             ]
00036 //[-------------------------------------------------------]
00037 namespace PLCore {
00038 
00039 
00040 //[-------------------------------------------------------]
00041 //[ Classes                                               ]
00042 //[-------------------------------------------------------]
00043 /**
00044 *  @brief
00045 *    Command line option
00046 */
00047 class CommandLineOption {
00048 
00049 
00050     //[-------------------------------------------------------]
00051     //[ Public definitions                                    ]
00052     //[-------------------------------------------------------]
00053     public:
00054         /**
00055         *  @brief
00056         *    Command line option type
00057         */
00058         enum EType {
00059             OptionFlag,         /**< A flag, e.g. 'command -v' or 'command --verbose' */
00060             OptionParam,        /**< A parameter, e.g. 'command -f name' or 'command --filename name' */
00061             OptionArgument      /**< An argument, e.g. 'command name' */
00062         };
00063 
00064 
00065     //[-------------------------------------------------------]
00066     //[ Public functions                                      ]
00067     //[-------------------------------------------------------]
00068     public:
00069         /**
00070         *  @brief
00071         *    Constructor
00072         */
00073         inline CommandLineOption();
00074 
00075         /**
00076         *  @brief
00077         *    Destructor
00078         */
00079         inline ~CommandLineOption();
00080 
00081         /**
00082         *  @brief
00083         *    Get option type
00084         *
00085         *  @return
00086         *    Type of option
00087         */
00088         inline EType GetType() const;
00089 
00090         /**
00091         *  @brief
00092         *    Set option type
00093         *
00094         *  @param[in] nType
00095         *    Type of option
00096         */
00097         inline void SetType(EType nType);
00098 
00099         /**
00100         *  @brief
00101         *    Check if this option is required
00102         *
00103         *  @return
00104         *    'true' if the option is required, else 'false'
00105         */
00106         inline bool IsRequired() const;
00107 
00108         /**
00109         *  @brief
00110         *    Set if this option is required
00111         *
00112         *  @param[in] bRequired
00113         *    'true' if the option is required, else 'false'
00114         */
00115         inline void SetRequired(bool bRequired);
00116 
00117         /**
00118         *  @brief
00119         *    Get name
00120         *
00121         *  @return
00122         *    Option name (e.g. "Name")
00123         */
00124         inline String GetName() const;
00125 
00126         /**
00127         *  @brief
00128         *    Set name
00129         *
00130         *  @param[in] sName
00131         *    Option name (e.g. "Name")
00132         */
00133         inline void SetName(const String &sName);
00134 
00135         /**
00136         *  @brief
00137         *    Get short name
00138         *
00139         *  @return
00140         *    Short option name (e.g. "-a")
00141         */
00142         inline String GetShortName() const;
00143 
00144         /**
00145         *  @brief
00146         *    Set short name
00147         *
00148         *  @param[in] sName
00149         *    Short option name (e.g. "-a")
00150         */
00151         inline void SetShortName(const String &sName);
00152 
00153         /**
00154         *  @brief
00155         *    Get long name
00156         *
00157         *  @return
00158         *    Long option name (e.g. "--optiona")
00159         */
00160         inline String GetLongName() const;
00161 
00162         /**
00163         *  @brief
00164         *    Set long name
00165         *
00166         *  @param[in] sName
00167         *    Long option name (e.g. "--optiona")
00168         */
00169         inline void SetLongName(const String &sName);
00170 
00171         /**
00172         *  @brief
00173         *    Get description
00174         *
00175         *  @return
00176         *    Description string
00177         */
00178         inline String GetDescription() const;
00179 
00180         /**
00181         *  @brief
00182         *    Set description
00183         *
00184         *  @param[in] sDescription
00185         *    Description string
00186         */
00187         inline void SetDescription(const String &sDescription);
00188 
00189         /**
00190         *  @brief
00191         *    Get default value
00192         *
00193         *  @return
00194         *    Default value
00195         */
00196         inline String GetDefault() const;
00197 
00198         /**
00199         *  @brief
00200         *    Set default value
00201         *
00202         *  @param[in] sDefault
00203         *    Default value
00204         */
00205         inline void SetDefault(const String &sDefault);
00206 
00207         /**
00208         *  @brief
00209         *    Check if option value is set (either by command line or by default value)
00210         *
00211         *  @return
00212         *    'true' if the value is set, else 'false'
00213         */
00214         inline bool IsSet() const;
00215 
00216         /**
00217         *  @brief
00218         *    Get option value
00219         *
00220         *  @return
00221         *    Value of option ("true"/"false" for boolean values)
00222         */
00223         inline String GetValue() const;
00224 
00225         /**
00226         *  @brief
00227         *    Set value
00228         *
00229         *  @param[in] sValue
00230         *    Option value
00231         */
00232         inline void SetValue(const String &sValue);
00233 
00234 
00235     //[-------------------------------------------------------]
00236     //[ Private data                                          ]
00237     //[-------------------------------------------------------]
00238     private:
00239         EType   m_nType;        /**< Type of command line option */
00240         bool    m_bRequired;    /**< Is this option required? */
00241         String  m_sName;        /**< Name, can be "" except for OptionArgument */
00242         String  m_sShortName;   /**< Short name (e.g. "-a"), can be "" */
00243         String  m_sLongName;    /**< Long name (e.g. "--optiona"), can be "" */
00244         String  m_sDescription; /**< Description */
00245         String  m_sDefault;     /**< Default value */
00246         String  m_sValue;       /**< Current value */
00247 
00248 
00249 };
00250 
00251 
00252 //[-------------------------------------------------------]
00253 //[ Namespace                                             ]
00254 //[-------------------------------------------------------]
00255 } // PLCore
00256 
00257 
00258 //[-------------------------------------------------------]
00259 //[ Implementation                                        ]
00260 //[-------------------------------------------------------]
00261 #include "PLCore/Tools/CommandLineOption.inl"
00262 
00263 
00264 #endif // __PLCORE_COMMANDLINEOPTION_H__


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:50:51
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported