From f05089dffe81419786776b60bc2dc13d2a421a5c Mon Sep 17 00:00:00 2001 From: Baptiste Lepilleur Date: Sat, 20 Apr 2002 20:54:36 +0000 Subject: THANKS: updated THANKS: updated * src/cppunit/DynamicLibraryManager.cpp: bugfix: did not pass library name to exception. * include/cppunit/TestPath.h: * src/cppunit/TestPath.cpp: changed into value object. * src/cppunit/BeosDynamicLibraryManager.cpp: integrated patch from Shibu Yoshiki for BeOS ('cuppa' project team). * src/DllPlugInTester/CommandLineParser.h: * src/DllPlugInTester/CommandLineParser.cpp: added. Command line parsing. * src/DllPlugInTester/DllPlugInTester.cpp: full command line support with parameters for plug-ins. * src/DllPlugInTester/makefile.am: * examples/simple/makefile.am: * examples/cppunittest/makefile.am: integrated Jeffrey Morgan patch, Unix side should be working again. * examples/ReadMe.txt: added. Brief description of each example. * examples/cppunittest/CppUnitTestPlugIn.cpp: * examples/cppunittest/CppUnitTestPlugIn.dsp: added. New project to build CppUnit's test suite as a test plug-in. * examples/cppunittest/CppUnitTestSuite.cpp: updated. Use new helper macros to create the test suite hierarchy. * examples/simple/simple_plugin.opt: added. Contains debug tab settings. * examples/ClockerPlugIn/ClockerListener.cpp: * examples/ClockerPlugIn/ClockerListener.h: * examples/ClockerPlugIn/Timer.cpp: * examples/ClockerPlugIn/Timer.h: * examples/ClockerPlugIn/WinNtTimer.cpp: * examples/ClockerPlugIn/WinNtTimer.h: * examples/ClockerPlugIn/ClockerPlugIn.cpp: * examples/ClockerPlugIn/ClockerPlugIn.dsp: added. test listener plug-in that times tests. * examples/DumperPlugIn/DumperListener.cpp: * examples/DumperPlugIn/DumperListener.h: * examples/DumperPlugIn/DumperPlugIn.cpp: * examples/DumperPlugIn/DumperPlugIn.dsp: added. test listener plug-in that dump the test tree. --- src/DllPlugInTester/CommandLineParser.h | 121 ++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 src/DllPlugInTester/CommandLineParser.h (limited to 'src/DllPlugInTester/CommandLineParser.h') diff --git a/src/DllPlugInTester/CommandLineParser.h b/src/DllPlugInTester/CommandLineParser.h new file mode 100644 index 0000000..9fd5c5d --- /dev/null +++ b/src/DllPlugInTester/CommandLineParser.h @@ -0,0 +1,121 @@ +#ifndef CPPUNIT_HELPER_COMMANDLINEPARSER_H +#define CPPUNIT_HELPER_COMMANDLINEPARSER_H + +#include +#include +#include +#include +#include + + +/*! Exception thrown on error while parsing command line. + */ +class CommandLineParserException : public std::runtime_error +{ +public: + CommandLineParserException( std::string message ) + : std::runtime_error( message ) + { + } +}; + + +struct CommandLinePlugInInfo +{ + std::string m_fileName; + CppUnit::Parameters m_parameters; +}; + + +/*! \brief Parses a command line. + +-c --compiler +-x --xml [filename] +-s --xsl stylesheet +-e --encoding encoding +-b --brief-progress +-n --no-progress +-t --text +-o --cout +filename[="options"] +:testpath + + */ +class CommandLineParser +{ +public: + /*! Constructs a CommandLineParser object. + */ + CommandLineParser( int argc, + char *argv[] ); + + /// Destructor. + virtual ~CommandLineParser(); + + /*! Parses the command line. + * \exception CommandLineParserException if an error occurs. + */ + void parse(); + + bool useCompilerOutputter() const; + bool useXmlOutputter() const; + std::string getXmlFileName() const; + std::string getXmlStyleSheet() const; + std::string getEncoding() const; + bool useBriefTestProgress() const; + bool noTestProgress() const; + bool useTextOutputter() const; + bool useCoutStream() const; + std::string getTestPath() const; + int getPlugInCount() const; + CommandLinePlugInInfo getPlugInAt( int index ) const; + +protected: + /// Prevents the use of the copy constructor. + CommandLineParser( const CommandLineParser © ); + + /// Prevents the use of the copy operator. + void operator =( const CommandLineParser © ); + + bool isOption( const std::string &shortName, + const std::string &longName ); + + bool hasNext() const; + bool startsWith( const std::string &expected ) const; + char next(); + void skipNext( int count =1 ); + bool isSpace() const; + + std::string getParameter(); + std::string getQuotedParameter(); + std::string getUnquotedParameter(); + std::string getOptionalParameter(); + void fail( std::string message ); + void getNextOption(); + void skipSpaces(); + static bool isSpace( unsigned char c ); + + void readNonOptionCommands(); + +protected: + std::string m_line; + int m_currentIndex; + std::string m_option; + + bool m_useCompiler; + bool m_useXml; + std::string m_xmlFileName; + std::string m_xsl; + std::string m_encoding; + bool m_briefProgress; + bool m_noProgress; + bool m_useText; + bool m_useCout; + std::string m_testPath; + + typedef std::deque PlugIns; + PlugIns m_plugIns; +}; + + +#endif // CPPUNIT_HELPER_COMMANDLINEPARSER_H -- cgit v1.2.1