dbertoni 01/06/14 11:27:51
Modified: c/src/PlatformSupport StringTokenizer.cpp
StringTokenizer.hpp
Log:
New nextToken() overload to tokenize directly into a string.
Revision Changes Path
1.5 +48 -0 xml-xalan/c/src/PlatformSupport/StringTokenizer.cpp
Index: StringTokenizer.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/StringTokenizer.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- StringTokenizer.cpp 2000/11/02 01:45:36 1.4
+++ StringTokenizer.cpp 2001/06/14 18:27:30 1.5
@@ -202,6 +202,54 @@
+void
+StringTokenizer::nextToken(XalanDOMString& theToken)
+{
+ assert(m_CurrentIndex < m_StringLength);
+
+ // Find the index of the next delimiter.
+ unsigned int theIndex = FindNextDelimiterIndex(m_CurrentIndex);
+
+ if (theIndex == m_CurrentIndex)
+ {
+ m_CurrentIndex = theIndex + 1;
+
+ if (m_fReturnTokens == true)
+ {
+ // The next delimiter is at the current index. If we're
+ // returning delimiters as tokens, then make that the
+ // return value. Otherwise, return an empty string.
+ substring(
+ m_String,
+ theToken,
+ theIndex,
+ theIndex + 1);
+ }
+ else if (m_CurrentIndex < m_StringLength)
+ {
+ theToken = nextToken();
+ }
+ }
+ else
+ {
+ if (theIndex == m_CurrentIndex)
+ {
+ theIndex = FindNextDelimiterIndex(m_CurrentIndex + 1);
+ }
+ assert(theIndex > m_CurrentIndex);
+
+ substring(
+ m_String,
+ theToken,
+ m_CurrentIndex,
+ theIndex);
+
+ m_CurrentIndex = theIndex;
+ }
+}
+
+
+
unsigned int
StringTokenizer::countTokens() const
{
1.8 +9 -0 xml-xalan/c/src/PlatformSupport/StringTokenizer.hpp
Index: StringTokenizer.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/StringTokenizer.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- StringTokenizer.hpp 2000/11/02 01:45:37 1.7
+++ StringTokenizer.hpp 2001/06/14 18:27:35 1.8
@@ -151,6 +151,15 @@
nextToken();
/**
+ * Retrieve the next token to be parsed; behavior is undefined if there
are
+ * no more tokens
+ *
+ * @param theToken next token string
+ */
+ virtual void
+ nextToken(XalanDOMString& theToken);
+
+ /**
* Count the number of tokens yet to be parsed
*
* @return number of remaining tokens
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]