You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by am...@apache.org on 2006/10/02 19:26:22 UTC

svn commit: r452136 - in /xerces/c/trunk/src/xercesc/util/regx: RegularExpression.cpp RegularExpression.hpp RegxParser.hpp

Author: amassari
Date: Mon Oct  2 10:26:21 2006
New Revision: 452136

URL: http://svn.apache.org/viewvc?view=rev&rev=452136
Log:
Allow RegEx parser to be derived

Modified:
    xerces/c/trunk/src/xercesc/util/regx/RegularExpression.cpp
    xerces/c/trunk/src/xercesc/util/regx/RegularExpression.hpp
    xerces/c/trunk/src/xercesc/util/regx/RegxParser.hpp

Modified: xerces/c/trunk/src/xercesc/util/regx/RegularExpression.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/RegularExpression.cpp?view=diff&rev=452136&r1=452135&r2=452136
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/RegularExpression.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/RegularExpression.cpp Mon Oct  2 10:26:21 2006
@@ -418,30 +418,32 @@
 // ---------------------------------------------------------------------------
 //  RegularExpression: Setter methods
 // ---------------------------------------------------------------------------
-void RegularExpression::setPattern(const XMLCh* const pattern,
-								   const XMLCh* const options) {
-
-    fTokenFactory = new (fMemoryManager) TokenFactory(fMemoryManager);
-	fOptions = parseOptions(options);
-	fPattern = XMLString::replicate(pattern, fMemoryManager);
 
+RegxParser* RegularExpression::getRegexParser(const int options, MemoryManager* const manager)
+{
     // the following construct causes an error in an Intel 7.1 32 bit compiler for 
     // red hat linux 7.2
     // (when an exception is thrown the wrong object is deleted)
     //RegxParser* regxParser = isSet(fOptions, XMLSCHEMA_MODE)
     //	? new (fMemoryManager) ParserForXMLSchema(fMemoryManager) 
     //    : new (fMemoryManager) RegxParser(fMemoryManager);
-    RegxParser* regxParser;
-    if (isSet(fOptions, XMLSCHEMA_MODE)) {
-	    regxParser = new (fMemoryManager) ParserForXMLSchema(fMemoryManager);
-    }
-    else {
-        regxParser = new (fMemoryManager) RegxParser(fMemoryManager);
-    }
+    if (isSet(options, XMLSCHEMA_MODE))
+	    return new (manager) ParserForXMLSchema(manager);
+
+    return new (manager) RegxParser(manager);
+}
+
+void RegularExpression::setPattern(const XMLCh* const pattern,
+								   const XMLCh* const options) {
+
+    fTokenFactory = new (fMemoryManager) TokenFactory(fMemoryManager);
+	fOptions = parseOptions(options);
+	fPattern = XMLString::replicate(pattern, fMemoryManager);
+
+    RegxParser* regxParser=getRegexParser(fOptions, fMemoryManager);
 
-    if (regxParser) {
+    if (regxParser)
         regxParser->setTokenFactory(fTokenFactory);
-    }
 
 	Janitor<RegxParser> janRegxParser(regxParser);
 	fTokenTree = regxParser->parse(fPattern, fOptions);

Modified: xerces/c/trunk/src/xercesc/util/regx/RegularExpression.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/RegularExpression.hpp?view=diff&rev=452136&r1=452135&r2=452136
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/RegularExpression.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/RegularExpression.hpp Mon Oct  2 10:26:21 2006
@@ -42,6 +42,7 @@
 // ---------------------------------------------------------------------------
 class RangeToken;
 class Match;
+class RegxParser;
 
 class XMLUTIL_EXPORT RegularExpression : public XMemory
 {
@@ -150,6 +151,19 @@
 
     static bool isSet(const int options, const int flag);
 
+protected:
+    virtual RegxParser* getRegexParser(const int options, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
+
+    // -----------------------------------------------------------------------
+    //  Cleanup methods
+    // -----------------------------------------------------------------------
+    void cleanUp();
+
+    // -----------------------------------------------------------------------
+    //  Setter methods
+    // -----------------------------------------------------------------------
+    void setPattern(const XMLCh* const pattern, const XMLCh* const options=0);
+
 private:
     // -----------------------------------------------------------------------
     //  Private data types
@@ -184,16 +198,6 @@
     // -----------------------------------------------------------------------
     RegularExpression(const RegularExpression&);
     RegularExpression& operator=(const RegularExpression&);
-
-    // -----------------------------------------------------------------------
-    //  Cleanup methods
-    // -----------------------------------------------------------------------
-    void cleanUp();
-
-    // -----------------------------------------------------------------------
-    //  Setter methods
-    // -----------------------------------------------------------------------
-    void setPattern(const XMLCh* const pattern, const XMLCh* const options=0);
 
     // -----------------------------------------------------------------------
     //  Private Helper methods

Modified: xerces/c/trunk/src/xercesc/util/regx/RegxParser.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/RegxParser.hpp?view=diff&rev=452136&r1=452135&r2=452136
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/RegxParser.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/RegxParser.hpp Mon Oct  2 10:26:21 2006
@@ -94,12 +94,14 @@
 	int            getOffset() const;
 	bool           hasBackReferences() const;
     TokenFactory*  getTokenFactory() const;
+    int            getOptions() const;
 
 	// -----------------------------------------------------------------------
     //  Setter methods
     // -----------------------------------------------------------------------
 	void setParseContext(const unsigned short value);
     void setTokenFactory(TokenFactory* const tokFactory);
+    void setOptions(const int options);
 
 	// -----------------------------------------------------------------------
     //  Public Parsing methods
@@ -154,6 +156,7 @@
     // -----------------------------------------------------------------------
 	virtual Token*      getTokenForShorthand(const XMLInt32 ch);
 
+    bool isSet(const int flag);
 private:
     // -----------------------------------------------------------------------
     //  Private parsing/processing methods
@@ -183,7 +186,6 @@
     // -----------------------------------------------------------------------
     //  Private Helper methods
     // -----------------------------------------------------------------------
-    bool isSet(const int flag);
 	int hexChar(const XMLInt32 ch);
 
 	// -----------------------------------------------------------------------
@@ -245,6 +247,12 @@
 inline MemoryManager* RegxParser::getMemoryManager() const {
     return fMemoryManager;
 }
+
+inline int RegxParser::getOptions() const {
+
+    return fOptions;
+}
+
 // ---------------------------------------------------------------------------
 //  RegxParser: Setter Methods
 // ---------------------------------------------------------------------------
@@ -256,6 +264,11 @@
 inline void RegxParser::setTokenFactory(TokenFactory* const tokFactory) {
 
     fTokenFactory = tokFactory;
+}
+
+inline void RegxParser::setOptions(const int options) {
+
+	fOptions = options;
 }
 
 // ---------------------------------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org