You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(622) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(303) |
Feb
(64) |
Mar
(5) |
Apr
(63) |
May
(82) |
Jun
(53) |
Jul
(50) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Christian P. <cp...@us...> - 2005-01-20 22:42:46
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22017/include/pclasses Modified Files: AtomicTraits.h Log Message: Added export macro. Index: AtomicTraits.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/AtomicTraits.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- AtomicTraits.h 24 Dec 2004 17:15:50 -0000 1.2 +++ AtomicTraits.h 20 Jan 2005 22:42:30 -0000 1.3 @@ -18,9 +18,10 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef _P_AtomicTraits_h_ -#define _P_AtomicTraits_h_ +#ifndef P_AtomicTraits_h +#define P_AtomicTraits_h +#include <pclasses/Export.h> #include <pclasses/System/CriticalSection.h> namespace P { @@ -76,7 +77,7 @@ //#ifdef PCLASSES_HAVE_ATOMIC_INT //! Atomic integer type-traits template <> -struct AtomicTraits<int> { +struct PCORE_EXPORT AtomicTraits<int> { typedef int AtomicType; static void set(int* atomic, int val) throw(); |
From: Christian P. <cp...@us...> - 2005-01-20 22:40:33
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21455/include/pclasses Modified Files: ByteOrderTraits.h Log Message: Added export macros. Index: ByteOrderTraits.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/ByteOrderTraits.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ByteOrderTraits.h 22 Dec 2004 17:54:40 -0000 1.1.1.1 +++ ByteOrderTraits.h 20 Jan 2005 22:40:24 -0000 1.2 @@ -18,9 +18,10 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef _P_ByteOrderTraits_H_ -#define _P_ByteOrderTraits_H_ +#ifndef P_ByteOrderTraits_h +#define P_ByteOrderTraits_h +#include <pclasses/Export.h> #include <pclasses/BasicTypes.h> namespace P { @@ -28,7 +29,7 @@ namespace Traits { template <typename Type> -struct ByteOrderTraits { +struct PCORE_EXPORT ByteOrderTraits { static void setLittleEndian(Type& cpuVal, const Type& newValLE) throw(); static Type littleEndian(const Type& cpuVal) throw(); @@ -37,7 +38,7 @@ }; template <> -struct ByteOrderTraits<uint16_t> { +struct PCORE_EXPORT ByteOrderTraits<uint16_t> { static void setLittleEndian(uint16_t& cpuVal, uint16_t newValLE) throw(); static uint16_t littleEndian(uint16_t cpuVal) throw(); @@ -46,7 +47,7 @@ }; template <> -struct ByteOrderTraits<uint32_t> { +struct PCORE_EXPORT ByteOrderTraits<uint32_t> { static void setLittleEndian(uint32_t& cpuVal, uint32_t newValLE) throw(); static uint32_t littleEndian(uint32_t cpuVal) throw(); @@ -56,7 +57,7 @@ #ifdef PCLASSES_HAVE_64BIT_INT template <> -struct ByteOrderTraits<uint64_t> { +struct PCORE_EXPORT ByteOrderTraits<uint64_t> { static void setLittleEndian(uint64_t& cpuVal, uint64_t newValLE) throw(); static uint64_t littleEndian(uint64_t cpuVal) throw(); |
From: Christian P. <cp...@us...> - 2005-01-20 22:30:44
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19015/include/pclasses Modified Files: LinkedItem.h Log Message: Added export macros. Index: LinkedItem.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/LinkedItem.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- LinkedItem.h 22 Dec 2004 17:54:40 -0000 1.1.1.1 +++ LinkedItem.h 20 Jan 2005 22:30:19 -0000 1.2 @@ -18,15 +18,16 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef _P_LinkedItem_h_ -#define _P_LinkedItem_h_ +#ifndef P_LinkedItem_h +#define P_LinkedItem_h +#include <pclasses/Export.h> #include <pclasses/BasicTypes.h> namespace P { //! Single-linked item base -class LinkedItemBase { +class PCORE_EXPORT LinkedItemBase { public: LinkedItemBase(LinkedItemBase* _next); ~LinkedItemBase(); @@ -50,7 +51,7 @@ }; //! Double-linked item base -class DLinkedItemBase { +class PCORE_EXPORT DLinkedItemBase { public: DLinkedItemBase(DLinkedItemBase* _prev, DLinkedItemBase* _next); ~DLinkedItemBase(); |
From: Christian P. <cp...@us...> - 2005-01-20 22:16:24
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15322/include/pclasses Modified Files: Exception.h Log Message: Added export macros. Index: Exception.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Exception.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Exception.h 25 Dec 2004 00:04:37 -0000 1.4 +++ Exception.h 20 Jan 2005 22:16:13 -0000 1.5 @@ -22,6 +22,7 @@ #define _P_Exception_h_ #include <string> +#include <pclasses/Export.h> #include <pclasses/SourceInfo.h> namespace P { @@ -38,7 +39,7 @@ about the exception. */ -class Exception { +class PCORE_EXPORT Exception { public: /** Creates an exception with the given what() string @@ -73,7 +74,7 @@ }; //! Logic error -class LogicError: public Exception { +class PCORE_EXPORT LogicError: public Exception { public: LogicError(const char* what, const SourceInfo& si) throw(); LogicError(const std::string & what, const SourceInfo& si) throw(); @@ -81,21 +82,21 @@ }; //! Runtime error -class RuntimeError: public Exception { +class PCORE_EXPORT RuntimeError: public Exception { public: RuntimeError(const char* what, const SourceInfo& si) throw(); RuntimeError(const std::string & what, const SourceInfo& si) throw(); ~RuntimeError() throw(); }; -class OverrunError: public RuntimeError { +class PCORE_EXPORT OverrunError: public RuntimeError { public: OverrunError(const char* what, const SourceInfo& si) throw(); OverrunError(const std::string & what, const SourceInfo& si) throw(); ~OverrunError() throw(); }; -class UnderrunError: public RuntimeError { +class PCORE_EXPORT UnderrunError: public RuntimeError { public: UnderrunError(const char* what, const SourceInfo& si) throw(); UnderrunError(const std::string & what, const SourceInfo& si) throw(); @@ -103,14 +104,14 @@ ~UnderrunError() throw(); }; -class OutOfBounds: public RuntimeError { +class PCORE_EXPORT OutOfBounds: public RuntimeError { public: OutOfBounds(const char* what, const SourceInfo& si) throw(); OutOfBounds(const std::string & what, const SourceInfo& si) throw(); ~OutOfBounds() throw(); }; -class OverflowError: public RuntimeError { +class PCORE_EXPORT OverflowError: public RuntimeError { public: OverflowError(const char* what, const SourceInfo& si) throw(); OverflowError(const std::string & what, const SourceInfo& si) throw(); |
From: Christian P. <cp...@us...> - 2005-01-20 19:56:43
|
Update of /cvsroot/pclasses/pclasses2/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9042/test Modified Files: CmdLineTest.cpp Log Message: Finished advanced command line parsing. Index: CmdLineTest.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/test/CmdLineTest.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- CmdLineTest.cpp 20 Jan 2005 10:59:50 -0000 1.1 +++ CmdLineTest.cpp 20 Jan 2005 19:56:30 -0000 1.2 @@ -18,15 +18,17 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include "Test.h" #include "pclasses/App/CmdLine.h" using namespace P; using namespace P::App; -CmdLineFlag cmdLineOpt1("f", "flag", false); -CmdLineValue cmdLineVal1("v", "value", "", true); -CmdLineValue cmdLineVal2("v2", "value2", "testdefault", false); +CmdLineFlag cmdLineOpt1("f", "flag", "Test flag (optional)"); +CmdLineValue cmdLineVal1("v", "value", "Test value"); +CmdLineValue cmdLineVal2("v2", "value2", "Test value with default", +"testdefault"); CmdLineOption* opts[] = { &cmdLineOpt1, @@ -38,6 +40,15 @@ int main(int argc, char* argv[]) { CmdLineParser p(opts); - p.parse(argc, argv); + try + { + p.parse(argc, argv); + } + catch(CmdLineError& err) + { + std::cout << err.what() << std::endl; + std::cout << "Usage:" << std::endl; + p.dumpHelp(std::cout); + } } |
From: Christian P. <cp...@us...> - 2005-01-20 19:56:42
|
Update of /cvsroot/pclasses/pclasses2/src/App In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9042/src/App Modified Files: CmdLine.cpp Log Message: Finished advanced command line parsing. Index: CmdLine.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/App/CmdLine.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- CmdLine.cpp 20 Jan 2005 11:02:01 -0000 1.3 +++ CmdLine.cpp 20 Jan 2005 19:56:29 -0000 1.4 @@ -20,14 +20,19 @@ #include "pclasses/App/CmdLine.h" #include <sstream> +#include <iomanip> +#include <iostream> namespace P { namespace App { CmdLineOption::CmdLineOption(const std::string& shortOpt, - const std::string& longOpt, bool required) -: _shortOpt(shortOpt), _longOpt(longOpt), _required(required) + const std::string& longOpt, const std::string& helpText, + bool required, bool needValue) +: _isset(false), _shortOpt(shortOpt), _longOpt(longOpt), + _helpText(helpText), _required(required), + _needValue(needValue) { } @@ -45,61 +50,89 @@ return _longOpt; } +const std::string& CmdLineOption::helpText() const throw() +{ + return _helpText; +} + bool CmdLineOption::required() const throw() { return _required; } +bool CmdLineOption::isset() const throw() +{ + return _isset; +} + +bool CmdLineOption::needValue() const throw() +{ + return _needValue; +} CmdLineFlag::CmdLineFlag(const std::string& shortOpt, - const std::string& longOpt, bool defaultVal, bool required) -: CmdLineOption(shortOpt, longOpt, required), _defaultVal(defaultVal) + const std::string& longOpt, const std::string& helpText, + bool defaultVal, bool required) +: CmdLineOption(shortOpt, longOpt, helpText, required, false), + _defaultVal(defaultVal) { } + CmdLineFlag::~CmdLineFlag() { } +void CmdLineFlag::setValue(const std::string& val) +{ + _isset = true; +} -CmdLineValue::CmdLineValue(const std::string& shortOpt, - const std::string& longOpt, const std::string& defaultVal, bool required) -: CmdLineOption(shortOpt, longOpt, required), _defaultVal(defaultVal) +std::string CmdLineFlag::value() const throw() { + return std::string(_isset ? "1" : "0"); } -CmdLineValue::~CmdLineValue() + +CmdLineValue::CmdLineValue(const std::string& shortOpt, + const std::string& longOpt, const std::string& helpText, + const std::string& defaultVal) +: CmdLineOption(shortOpt, longOpt, helpText, false, true), + _defaultVal(defaultVal) { } +CmdLineValue::CmdLineValue(const std::string& shortOpt, + const std::string& longOpt, const std::string& helpText, + bool required) +: CmdLineOption(shortOpt, longOpt, helpText, required, true), + _defaultVal("") +{ +} -CmdLineParser::CmdLineParser(CmdLineOption* opts[]) -: _opts(opts) +CmdLineValue::~CmdLineValue() { } -CmdLineParser::~CmdLineParser() +void CmdLineValue::setValue(const std::string& val) { + _value = val; + _isset = true; } -bool CmdLineParser::parse(int argc, char* argv[]) +std::string CmdLineValue::value() const throw() { - _parsedOpts.clear(); + return _value; +} - std::ostringstream os; - for(int i = 1; i < argc; ++i) - { - os << argv[i]; - if(i+1 < argc) - os << ' '; - } - return parse(os.str()); +CmdLineParser::CmdLineParser(CmdLineOption* opts[]) +: _opts(opts) +{ } -void parseOptName(std::istream& is, std::string& optName) +CmdLineParser::~CmdLineParser() { - // break on '=' and ' ' } CmdLineOption* findOptShort(CmdLineOption* opts[], std::string& shortOpt) @@ -130,42 +163,126 @@ return 0; } -bool CmdLineParser::parse(const std::string& cmdline) +CmdLineError::CmdLineError(const std::string& what, const SourceInfo& si) +: RuntimeError(what, si) { - std::istringstream is(cmdline); +} - char ch; - while((is >> ch)) +CmdLineError::~CmdLineError() +{ +} + + +void CmdLineParser::parse(int argc, char* argv[]) throw(CmdLineError) +{ + _unnamedValues.clear(); + CmdLineOption* opt = 0; + + std::string optName, optVal; + std::string tmp; + + for(int i = 1; i < argc; ++i) { - if(ch == '-') - { - std::string optName; - CmdLineOption* opt = 0; + tmp = argv[i]; - is >> ch; + if(tmp.size() > 1 && tmp[0] == '-') + { + bool isLongOpt = false; - if(ch != '-') + // long option? + if(tmp.size() > 2 && tmp[1] == '-') { - is.unget(); - parseOptName(is, optName); - opt = findOptShort(_opts, optName); + isLongOpt = true; + tmp = tmp.substr(2, std::string::npos); } + // must be a short option ... else { - parseOptName(is, optName); - opt = findOptLong(_opts, optName); + tmp = tmp.substr(1, std::string::npos); } - // unknown option? + // split option=value string + // the value may also be processed later .. (that is in the next iteration + // of the loop) + std::string::size_type pos = tmp.find('='); + optName = tmp.substr(0, pos); + if(pos != std::string::npos) + optVal = tmp.substr(pos+1, std::string::npos); + + // find the option object .... + if(isLongOpt) + opt = findOptLong(_opts, optName); + else + opt = findOptShort(_opts, optName); + + // unknown option ... if(!opt) + throw CmdLineError("Unknown command line option: " + + std::string(argv[i]), P_SOURCEINFO); + + // do we have value for this option ....? + // it doesnt matter if the option needs a value or not... + // option values for flags are simply discarded + if(pos != std::string::npos) { - //@fixme throw CmdLineError() - return false; + opt->setValue(optVal); + opt = 0; + } + // option does not need a value... + else if(!opt->needValue()) + { + opt->setValue(std::string()); + opt = 0; + } + } + // option value ... + else + { + // the value is for the current option... + if(opt) + { + opt->setValue(tmp); + opt = 0; + } + // unnamed option value ... + else + { + _unnamedValues.push_back(tmp); } } } +} - return false; +const std::string& CmdLineParser::value(unsigned int index) const + throw(OutOfBounds) +{ + if(index < _unnamedValues.size()) + return _unnamedValues[index]; + + throw OutOfBounds("Value-index is out of bounds", P_SOURCEINFO); +} + +unsigned int CmdLineParser::valueCount() const throw() +{ + return _unnamedValues.size(); +} + +void CmdLineParser::parse(const std::string& cmdline) throw(CmdLineError) +{ + throw CmdLineError("Not implemented", P_SOURCEINFO); +} + +void CmdLineParser::dumpHelp(std::ostream& os) const +{ + int i = 0; + while(_opts[i]) + { + os << std::setw(10) << "-"+_opts[i]->shortName() << ' ' + << std::setw(20) << "--"+_opts[i]->longName() << " " + << _opts[i]->helpText() << std::endl; + + ++i; + } } |
From: Christian P. <cp...@us...> - 2005-01-20 19:56:42
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/App In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9042/include/pclasses/App Modified Files: CmdLine.h Log Message: Finished advanced command line parsing. Index: CmdLine.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/App/CmdLine.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- CmdLine.h 20 Jan 2005 11:01:59 -0000 1.3 +++ CmdLine.h 20 Jan 2005 19:56:29 -0000 1.4 @@ -22,8 +22,9 @@ #define P_App_CmdLine_h #include <pclasses/Export.h> +#include <pclasses/Exception.h> #include <string> -#include <map> +#include <vector> namespace P { @@ -33,30 +34,48 @@ class PAPP_EXPORT CmdLineOption { public: CmdLineOption(const std::string& shortOpt, const std::string& longOpt, - bool required); + const std::string& helpText, bool required, bool needsValue); - ~CmdLineOption(); + virtual ~CmdLineOption(); const std::string& shortName() const throw(); const std::string& longName() const throw(); + const std::string& helpText() const throw(); + bool required() const throw(); + bool isset() const throw(); + + bool needValue() const throw(); + + virtual void setValue(const std::string& val) = 0; + virtual std::string value() const throw() = 0; + + protected: + bool _isset; + private: std::string _shortOpt; std::string _longOpt; + std::string _helpText; bool _required; + bool _needValue; }; //! Command-line option flag class PAPP_EXPORT CmdLineFlag: public CmdLineOption { public: CmdLineFlag(const std::string& shortOpt, const std::string& longOpt, - bool defaultVal, bool required = false); + const std::string& helpText, bool defaultVal = false, + bool required = false); ~CmdLineFlag(); + void setValue(const std::string& val); + std::string value() const throw(); + private: bool _defaultVal; }; @@ -65,12 +84,25 @@ class PAPP_EXPORT CmdLineValue: public CmdLineOption { public: CmdLineValue(const std::string& shortOpt, const std::string& longOpt, - const std::string& defaultVal, bool required = false); + const std::string& helpText, const std::string& defaultVal); + + CmdLineValue(const std::string& shortOpt, const std::string& longOpt, + const std::string& helpText, bool requird = false); ~CmdLineValue(); + void setValue(const std::string& val); + std::string value() const throw(); + private: std::string _defaultVal; + std::string _value; +}; + +class PAPP_EXPORT CmdLineError: public RuntimeError { + public: + CmdLineError(const std::string& what, const SourceInfo& si); + ~CmdLineError(); }; //! Advanced command-line parser @@ -79,15 +111,22 @@ CmdLineParser(CmdLineOption* opts[] = 0); ~CmdLineParser(); - bool parse(int argc, char* argv[]); - bool parse(const std::string& cmdline); + void parse(int argc, char* argv[]) throw(CmdLineError); + void parse(const std::string& cmdline) throw(CmdLineError); + + //! Returns a unnamed command line value + const std::string& value(unsigned int index) const throw(OutOfBounds); + + //! Returns the number of unnamed command line values + unsigned int valueCount() const throw(); + + void dumpHelp(std::ostream& os) const; private: - typedef std::map<std::string, - CmdLineOption*> ParsedCmdOptMap; + typedef std::vector<std::string> StringVector; - CmdLineOption** _opts; - ParsedCmdOptMap _parsedOpts; + CmdLineOption** _opts; + StringVector _unnamedValues; }; } // !namespace App |
From: Christian P. <cp...@us...> - 2005-01-20 11:06:08
|
Update of /cvsroot/pclasses/pclasses2/src/App In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4616/src/App Modified Files: Makefile.am Log Message: Added CmdLine.[h|cpp] Index: Makefile.am =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/App/Makefile.am,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Makefile.am 18 Jan 2005 17:53:14 -0000 1.5 +++ Makefile.am 20 Jan 2005 11:05:57 -0000 1.6 @@ -5,7 +5,7 @@ CPPFLAGS = -DPAPP_BUILD libpclasses_app_la_SOURCES = AppDetails.cpp LogMessage.cpp LogTarget.cpp \ - LogChannel.cpp LogManager.cpp SimpleApp.cpp BackgroundApp.cpp + LogChannel.cpp LogManager.cpp SimpleApp.cpp BackgroundApp.cpp CmdLine.cpp libpclasses_app_la_LDFLAGS = -no-undefined |
From: Christian P. <cp...@us...> - 2005-01-20 11:06:05
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/App In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4616/include/pclasses/App Modified Files: Makefile.am Log Message: Added CmdLine.[h|cpp] Index: Makefile.am =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/App/Makefile.am,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Makefile.am 18 Jan 2005 17:53:12 -0000 1.3 +++ Makefile.am 20 Jan 2005 11:05:56 -0000 1.4 @@ -3,4 +3,4 @@ INCLUDES = METASOURCES = AUTO pclasses_app_include_HEADERS = AppDetails.h LogMessage.h LogTarget.h \ - LogChannel.h LogManager.h SimpleApp.h BackgroundApp.h + LogChannel.h LogManager.h SimpleApp.h BackgroundApp.h CmdLine.h |
From: Christian P. <cp...@us...> - 2005-01-20 11:02:13
|
Update of /cvsroot/pclasses/pclasses2/src/App In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3925/src/App Modified Files: CmdLine.cpp Log Message: More work on CmdLine (early commit .. sorry) Index: CmdLine.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/App/CmdLine.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CmdLine.cpp 19 Jan 2005 13:43:57 -0000 1.2 +++ CmdLine.cpp 20 Jan 2005 11:02:01 -0000 1.3 @@ -35,6 +35,21 @@ { } +const std::string& CmdLineOption::shortName() const throw() +{ + return _shortOpt; +} + +const std::string& CmdLineOption::longName() const throw() +{ + return _longOpt; +} + +bool CmdLineOption::required() const throw() +{ + return _required; +} + CmdLineFlag::CmdLineFlag(const std::string& shortOpt, const std::string& longOpt, bool defaultVal, bool required) @@ -58,7 +73,7 @@ } -CmdLineParser::CmdLineParser(CmdLineOption* opts) +CmdLineParser::CmdLineParser(CmdLineOption* opts[]) : _opts(opts) { } @@ -82,11 +97,74 @@ return parse(os.str()); } +void parseOptName(std::istream& is, std::string& optName) +{ + // break on '=' and ' ' +} + +CmdLineOption* findOptShort(CmdLineOption* opts[], std::string& shortOpt) +{ + int i = 0; + while(opts[i]) + { + if(opts[i]->shortName() == shortOpt) + return opts[i]; + + ++i; + } + + return 0; +} + +CmdLineOption* findOptLong(CmdLineOption* opts[], std::string& longOpt) +{ + int i = 0; + while(opts[i]) + { + if(opts[i]->longName() == longOpt) + return opts[i]; + + ++i; + } + + return 0; +} + bool CmdLineParser::parse(const std::string& cmdline) { std::istringstream is(cmdline); - //@fixme + char ch; + while((is >> ch)) + { + if(ch == '-') + { + std::string optName; + CmdLineOption* opt = 0; + + is >> ch; + + if(ch != '-') + { + is.unget(); + parseOptName(is, optName); + opt = findOptShort(_opts, optName); + } + else + { + parseOptName(is, optName); + opt = findOptLong(_opts, optName); + } + + // unknown option? + if(!opt) + { + //@fixme throw CmdLineError() + return false; + } + } + } + return false; } |
From: Christian P. <cp...@us...> - 2005-01-20 11:02:12
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/App In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3925/include/pclasses/App Modified Files: CmdLine.h Log Message: More work on CmdLine (early commit .. sorry) Index: CmdLine.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/App/CmdLine.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CmdLine.h 19 Jan 2005 13:43:59 -0000 1.2 +++ CmdLine.h 20 Jan 2005 11:01:59 -0000 1.3 @@ -37,6 +37,12 @@ ~CmdLineOption(); + const std::string& shortName() const throw(); + + const std::string& longName() const throw(); + + bool required() const throw(); + private: std::string _shortOpt; std::string _longOpt; @@ -70,7 +76,7 @@ //! Advanced command-line parser class PAPP_EXPORT CmdLineParser { public: - CmdLineParser(CmdLineOption* opts = 0); + CmdLineParser(CmdLineOption* opts[] = 0); ~CmdLineParser(); bool parse(int argc, char* argv[]); @@ -80,7 +86,7 @@ typedef std::map<std::string, CmdLineOption*> ParsedCmdOptMap; - CmdLineOption* _opts; + CmdLineOption** _opts; ParsedCmdOptMap _parsedOpts; }; |
From: Christian P. <cp...@us...> - 2005-01-20 11:00:48
|
Update of /cvsroot/pclasses/pclasses2/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3701/test Modified Files: Makefile.am Log Message: Fixed PtrTest libs. Added LogTest, CmdLineTest. Index: Makefile.am =================================================================== RCS file: /cvsroot/pclasses/pclasses2/test/Makefile.am,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Makefile.am 7 Jan 2005 13:46:21 -0000 1.4 +++ Makefile.am 20 Jan 2005 11:00:35 -0000 1.5 @@ -1,11 +1,10 @@ INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include METASOURCES = AUTO -bin_PROGRAMS = PtrTest -PtrTest_SOURCES = PtrTest.cpp -PtrTest_LDADD = $(top_builddir)/src/System/libpclasses_system.la $(top_builddir)/src/libpclasses.la noinst_HEADERS = Test.h noinst_PROGRAMS = QueueTest StackTest IntTypeTest ListTest ThreadTest \ - StringTest IOTest SignalTest HTTPClientTest + StringTest IOTest SignalTest HTTPClientTest LogTest PtrTest CmdLineTest +PtrTest_SOURCES = PtrTest.cpp +PtrTest_LDADD = $(top_builddir)/src/System/libpclasses_system.la $(top_builddir)/src/libpclasses.la QueueTest_SOURCES = QueueTest.cpp QueueTest_LDADD = $(top_builddir)/src/libpclasses.la StackTest_SOURCES = StackTest.cpp @@ -27,3 +26,12 @@ HTTPClientTest_SOURCES = HTTPClientTest.cpp HTTPClientTest_LDADD = $(top_builddir)/src/Net/libpclasses_net.la\ $(top_builddir)/src/libpclasses.la +LogTest_LDADD = $(top_builddir)/src/App/libpclasses_app.la\ + $(top_builddir)/src/libpclasses.la +LogTest_SOURCES = LogTest.cpp +CmdLineTest_SOURCES = CmdLineTest.cpp +CmdLineTest_LDADD = $(top_builddir)/src/Unicode/libpclasses_unicode.la\ + $(top_builddir)/src/System/libpclasses_system.la\ + $(top_builddir)/src/IO/libpclasses_io.la\ + $(top_builddir)/src/App/libpclasses_app.la\ + $(top_builddir)/src/libpclasses.la |
From: Christian P. <cp...@us...> - 2005-01-20 10:59:59
|
Update of /cvsroot/pclasses/pclasses2/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3509/test Added Files: CmdLineTest.cpp Log Message: Added beginning CmdLineTest --- NEW FILE: CmdLineTest.cpp --- /*************************************************************************** * Copyright (C) 2005 by Christian Prochnow * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "pclasses/App/CmdLine.h" using namespace P; using namespace P::App; CmdLineFlag cmdLineOpt1("f", "flag", false); CmdLineValue cmdLineVal1("v", "value", "", true); CmdLineValue cmdLineVal2("v2", "value2", "testdefault", false); CmdLineOption* opts[] = { &cmdLineOpt1, &cmdLineVal1, &cmdLineVal2, 0 }; int main(int argc, char* argv[]) { CmdLineParser p(opts); p.parse(argc, argv); } |
From: Christian P. <cp...@us...> - 2005-01-20 10:59:26
|
Update of /cvsroot/pclasses/pclasses2/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3456/test Added Files: LogTest.cpp Log Message: Added LogTest. --- NEW FILE: LogTest.cpp --- /*************************************************************************** * Copyright (C) 2004 by Christian Prochnow * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "Test.h" #include "pclasses/IO/URL.h" #include "pclasses/Plugin/Plugin.h" #include "pclasses/App/LogManager.h" #include "pclasses/App/LogTarget.h" #include "pclasses/App/LogChannel.h" #include <iostream> namespace P { class LogTest: public UnitTest { public: void run() throw() { Plugin::PluginManager<App::LogTarget>::instance().addPlugin("../plugins/LogTarget/Console/.libs/plog_console.so"); App::LogManager& logMgr = App::LogManager::instance(); App::LogChannel* globalChannel = logMgr.addChannel("global"); App::LogTarget* target = logMgr.addTarget(globalChannel, "test2", "ConsoleLogTarget"); target->open(IO::URL()); (*globalChannel)(App::LogMessage::Debug) << "test" << std::endl; } }; } int main(int argc, char* argv[]) { P::LogTest lt; lt.run(); return 0; } |
From: Christian P. <cp...@us...> - 2005-01-20 10:58:59
|
Update of /cvsroot/pclasses/pclasses2/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3335/test Modified Files: Test.h Log Message: Log to cerr instead of cout. Index: Test.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/test/Test.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- Test.h 22 Dec 2004 17:54:37 -0000 1.1.1.1 +++ Test.h 20 Jan 2005 10:58:46 -0000 1.2 @@ -45,13 +45,13 @@ protected: void success(const char* msg) throw() { - std::cout << msg << ": ok" << std::endl; + std::cerr << msg << ": ok" << std::endl; } void failure(const char* msg) throw() { ++_failures; - std::cout << msg << ": failed" << std::endl; + std::cerr << msg << ": failed" << std::endl; } private: |
From: stephan b. <sg...@us...> - 2005-01-20 01:44:18
|
Update of /cvsroot/pclasses/pclasses2/doc/manual In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10169 Modified Files: pclasses2.lyx Log Message: Added Daniel Loof to Credits. Index: pclasses2.lyx =================================================================== RCS file: /cvsroot/pclasses/pclasses2/doc/manual/pclasses2.lyx,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- pclasses2.lyx 18 Jan 2005 18:13:05 -0000 1.6 +++ pclasses2.lyx 20 Jan 2005 01:44:10 -0000 1.7 @@ -259,6 +259,13 @@ stephan beal (Germany): likes to write docs and break old code/conventions. Writes the P::s11n support (http://s11n.net/ps11n/). +\layout Itemize + +Daniel Loof (you guessed it: Germany): +\color red +TODO +\color default +. \layout Section Architectural overview |
From: Loof, D. <dl...@us...> - 2005-01-19 23:31:11
|
Update of /cvsroot/pclasses/pclasses2/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10864/src Modified Files: Date.cpp Log Message: Operators consider leap years Index: Date.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Date.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Date.cpp 19 Jan 2005 16:25:17 -0000 1.3 +++ Date.cpp 19 Jan 2005 23:31:01 -0000 1.4 @@ -174,10 +174,12 @@ Date& Date::operator+=(const TimeSpan& sp) throw() { int tmp = (int)_day + sp.days(); - while ( tmp > daysInMonth(_month, _year) ) + while ( tmp && tmp > daysInMonth(_month, _year) ) { tmp -= daysInMonth(_month, _year); - if ( _month == 12 ) + if ( _month == 2 && isInLeapYear() ) + --tmp; + else if ( _month == 12 ) { _month = 1; ++_year; @@ -203,6 +205,8 @@ --_month; tmp += daysInMonth(_month, _year); + if ( _month == 2 && isInLeapYear() ) + ++tmp; } _day = tmp; return *this; |
From: Loof, D. <dl...@us...> - 2005-01-19 18:49:48
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13284/include/pclasses Modified Files: Time.h Log Message: add operators +=, -=, +, - Index: Time.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Time.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Time.h 27 Dec 2004 05:33:16 -0000 1.2 +++ Time.h 19 Jan 2005 18:49:38 -0000 1.3 @@ -22,6 +22,7 @@ #define P_Time_h #include <pclasses/Exception.h> +#include <pclasses/TimeSpan.h> #include <iostream> namespace P { @@ -63,6 +64,12 @@ bool operator!=(const Time& t) const throw(); Time& operator=(const Time& t) throw(); + + Time& operator+=(const TimeSpan& sp) throw(); + Time& operator-=(const TimeSpan& sp) throw(); + + friend Time operator+(const Time& t, const TimeSpan& sp) throw(); + friend Time operator-(const Time& t, const TimeSpan& sp) throw(); friend std::ostream& operator << (std::ostream& os, const Time& t); |
From: Loof, D. <dl...@us...> - 2005-01-19 18:48:57
|
Update of /cvsroot/pclasses/pclasses2/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13071/src Modified Files: Time.cpp Log Message: add operators +=, -=, +, - Index: Time.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Time.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Time.cpp 27 Dec 2004 05:33:15 -0000 1.2 +++ Time.cpp 19 Jan 2005 18:48:39 -0000 1.3 @@ -82,7 +82,7 @@ void Time::setUsec(unsigned int usec) throw(InvalidTime) { if(usec > (1000 * 1000) - 1) - throw InvalidTime("Invalid hour", P_SOURCEINFO); + throw InvalidTime("Invalid usec", P_SOURCEINFO); _usec = usec; } @@ -140,6 +140,80 @@ return (!operator==(t)); } +Time& Time::operator+=(const TimeSpan& sp) throw() +{ + _usec += sp.usecs(); + if ( _usec > (1000 * 1000) - 1 ) + { + ++_second; + } + + _second += sp.seconds(); + if ( _second > 59 ) + { + _second -= 60; + ++_minute; + } + + _minute += sp.minutes(); + if ( _minute > 59 ) + { + _minute -= 60; + ++_hour; + } + + _hour += sp.hours(); + if ( _hour > 23 ) + throw OverflowError("Overflow", P_SOURCEINFO); + + return *this; +} + +Time& Time::operator-=(const TimeSpan& sp) throw() +{ + if ( _usec < sp.usecs() ) + { + _usec += ( 1000 * 1000 ); + --_second; + } + _usec -= sp.usecs(); + + if ( _second < sp.seconds() ) + { + _second += 60; + --_minute; + } + _second -= sp.seconds(); + + if ( _minute < sp.minutes() ) + { + _minute += 60; + --_hour; + } + _minute -= sp.minutes(); + + if ( _hour < sp.hours()) + throw OverflowError("Overflow", P_SOURCEINFO); + + _hour -= sp.hours(); + + return *this; +} + +Time operator+(const Time& t, const TimeSpan& sp) throw() +{ + Time ret = t; + ret += sp; + return ret; +} + +Time operator-(const Time& t, const TimeSpan& sp) throw() +{ + Time ret = t; + ret -= sp; + return ret; +} + std::ostream& operator << (std::ostream& os, const Time& t) { int oldw = os.width(); |
From: Loof, D. <dl...@us...> - 2005-01-19 16:26:12
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12012/include/pclasses Modified Files: Date.h Log Message: add operators +, -, +=, -= Index: Date.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Date.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Date.h 27 Dec 2004 05:33:16 -0000 1.2 +++ Date.h 19 Jan 2005 16:25:58 -0000 1.3 @@ -22,6 +22,7 @@ #define P_Date_h #include <pclasses/Exception.h> +#include <pclasses/TimeSpan.h> #include <iostream> namespace P { @@ -99,6 +100,12 @@ bool operator<=(const Date& d) const throw(); bool operator==(const Date& d) const throw(); bool operator!=(const Date& d) const throw(); + + Date& operator+=(const TimeSpan& sp) throw(); + Date& operator-=(const TimeSpan& sp) throw(); + + friend Date operator+(const Date& d, const TimeSpan& sp) throw(); + friend Date operator-(const Date& d, const TimeSpan& sp) throw(); //! Returns the number of days in month static unsigned int daysInMonth(unsigned int month, unsigned int year) |
From: Loof, D. <dl...@us...> - 2005-01-19 16:25:28
|
Update of /cvsroot/pclasses/pclasses2/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11915/src Modified Files: Date.cpp Log Message: add operators +, -, +=, -= Index: Date.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Date.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Date.cpp 27 Dec 2004 05:33:15 -0000 1.2 +++ Date.cpp 19 Jan 2005 16:25:17 -0000 1.3 @@ -171,6 +171,57 @@ return (!operator==(d)); } +Date& Date::operator+=(const TimeSpan& sp) throw() +{ + int tmp = (int)_day + sp.days(); + while ( tmp > daysInMonth(_month, _year) ) + { + tmp -= daysInMonth(_month, _year); + if ( _month == 12 ) + { + _month = 1; + ++_year; + } + else + ++_month; + } + _day = tmp; + return *this; +} + +Date& Date::operator-=(const TimeSpan& sp) throw() +{ + int tmp = (int)_day - sp.days(); + while ( tmp < 1 ) + { + if ( _month == 1 ) + { + _month = 12; + --_year; + } + else + --_month; + + tmp += daysInMonth(_month, _year); + } + _day = tmp; + return *this; +} + +Date operator+(const Date& d, const TimeSpan& sp) throw() +{ + Date ret = d; + ret += sp; + return ret; +} + +Date operator-(const Date& d, const TimeSpan& sp) throw() +{ + Date ret = d; + ret -= sp; + return ret; +} + std::ostream& operator << (std::ostream& os, const Date& d) { int oldw = os.width(); |
From: Christian P. <cp...@us...> - 2005-01-19 13:44:38
|
Update of /cvsroot/pclasses/pclasses2/src/App In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1221/src/App Modified Files: CmdLine.cpp Log Message: Compile fixes. Index: CmdLine.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/App/CmdLine.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- CmdLine.cpp 19 Jan 2005 13:35:50 -0000 1.1 +++ CmdLine.cpp 19 Jan 2005 13:43:57 -0000 1.2 @@ -58,7 +58,7 @@ } -CmdLineParser::CmdLineParser(CmdLineOption* opts = 0) +CmdLineParser::CmdLineParser(CmdLineOption* opts) : _opts(opts) { } @@ -72,7 +72,7 @@ _parsedOpts.clear(); std::ostringstream os; - for(int i = 1; i < argc) + for(int i = 1; i < argc; ++i) { os << argv[i]; if(i+1 < argc) |
From: Christian P. <cp...@us...> - 2005-01-19 13:44:08
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/App In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1221/include/pclasses/App Modified Files: CmdLine.h Log Message: Compile fixes. Index: CmdLine.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/App/CmdLine.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- CmdLine.h 19 Jan 2005 13:35:51 -0000 1.1 +++ CmdLine.h 19 Jan 2005 13:43:59 -0000 1.2 @@ -78,7 +78,7 @@ private: typedef std::map<std::string, - CmdLineOption&> ParsedCmdOptMap; + CmdLineOption*> ParsedCmdOptMap; CmdLineOption* _opts; ParsedCmdOptMap _parsedOpts; |
From: Christian P. <cp...@us...> - 2005-01-19 13:36:13
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/App In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31833/include/pclasses/App Added Files: CmdLine.h Log Message: Added beginning of CmdLine classes - advanced command line parsing. --- NEW FILE: CmdLine.h --- /*************************************************************************** * Copyright (C) 2005 by Christian Prochnow * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef P_App_CmdLine_h #define P_App_CmdLine_h #include <pclasses/Export.h> #include <string> #include <map> namespace P { namespace App { //! Command-line option class PAPP_EXPORT CmdLineOption { public: CmdLineOption(const std::string& shortOpt, const std::string& longOpt, bool required); ~CmdLineOption(); private: std::string _shortOpt; std::string _longOpt; bool _required; }; //! Command-line option flag class PAPP_EXPORT CmdLineFlag: public CmdLineOption { public: CmdLineFlag(const std::string& shortOpt, const std::string& longOpt, bool defaultVal, bool required = false); ~CmdLineFlag(); private: bool _defaultVal; }; //! Command-line value class PAPP_EXPORT CmdLineValue: public CmdLineOption { public: CmdLineValue(const std::string& shortOpt, const std::string& longOpt, const std::string& defaultVal, bool required = false); ~CmdLineValue(); private: std::string _defaultVal; }; //! Advanced command-line parser class PAPP_EXPORT CmdLineParser { public: CmdLineParser(CmdLineOption* opts = 0); ~CmdLineParser(); bool parse(int argc, char* argv[]); bool parse(const std::string& cmdline); private: typedef std::map<std::string, CmdLineOption&> ParsedCmdOptMap; CmdLineOption* _opts; ParsedCmdOptMap _parsedOpts; }; } // !namespace App } // !namespace P #endif |
From: Christian P. <cp...@us...> - 2005-01-19 13:36:05
|
Update of /cvsroot/pclasses/pclasses2/src/App In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31833/src/App Added Files: CmdLine.cpp Log Message: Added beginning of CmdLine classes - advanced command line parsing. --- NEW FILE: CmdLine.cpp --- /*************************************************************************** * Copyright (C) 2005 by Christian Prochnow * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "pclasses/App/CmdLine.h" #include <sstream> namespace P { namespace App { CmdLineOption::CmdLineOption(const std::string& shortOpt, const std::string& longOpt, bool required) : _shortOpt(shortOpt), _longOpt(longOpt), _required(required) { } CmdLineOption::~CmdLineOption() { } CmdLineFlag::CmdLineFlag(const std::string& shortOpt, const std::string& longOpt, bool defaultVal, bool required) : CmdLineOption(shortOpt, longOpt, required), _defaultVal(defaultVal) { } CmdLineFlag::~CmdLineFlag() { } CmdLineValue::CmdLineValue(const std::string& shortOpt, const std::string& longOpt, const std::string& defaultVal, bool required) : CmdLineOption(shortOpt, longOpt, required), _defaultVal(defaultVal) { } CmdLineValue::~CmdLineValue() { } CmdLineParser::CmdLineParser(CmdLineOption* opts = 0) : _opts(opts) { } CmdLineParser::~CmdLineParser() { } bool CmdLineParser::parse(int argc, char* argv[]) { _parsedOpts.clear(); std::ostringstream os; for(int i = 1; i < argc) { os << argv[i]; if(i+1 < argc) os << ' '; } return parse(os.str()); } bool CmdLineParser::parse(const std::string& cmdline) { std::istringstream is(cmdline); //@fixme return false; } } // !namespace App } // !namespace P |