summaryrefslogtreecommitdiff
path: root/src/DllPlugInTester/CommandLineParser.h
diff options
context:
space:
mode:
authorBaptiste Lepilleur <gaiacrtn@free.fr>2002-04-20 20:54:36 +0000
committerBaptiste Lepilleur <gaiacrtn@free.fr>2002-04-20 20:54:36 +0000
commitf05089dffe81419786776b60bc2dc13d2a421a5c (patch)
tree8451a33146a505c999a28288fe4574e98f268238 /src/DllPlugInTester/CommandLineParser.h
parentc4995a9e022ed586cf4e3f166738dfe01bf51c16 (diff)
downloadcppunit-f05089dffe81419786776b60bc2dc13d2a421a5c.tar.gz
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.
Diffstat (limited to 'src/DllPlugInTester/CommandLineParser.h')
-rw-r--r--src/DllPlugInTester/CommandLineParser.h121
1 files changed, 121 insertions, 0 deletions
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 <cppunit/Portability.h>
+#include <cppunit/plugin/Parameters.h>
+#include <string>
+#include <stdexcept>
+#include <deque>
+
+
+/*! 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 &copy );
+
+ /// Prevents the use of the copy operator.
+ void operator =( const CommandLineParser &copy );
+
+ 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<CommandLinePlugInInfo> PlugIns;
+ PlugIns m_plugIns;
+};
+
+
+#endif // CPPUNIT_HELPER_COMMANDLINEPARSER_H