You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@locus.apache.org on 2000/04/11 16:35:35 UTC
cvs commit: xml-xalan/c/src/PlatformSupport AttributeListImpl.cpp AttributeListImpl.hpp DOMStringHelper.cpp DOMStringHelper.hpp DOMStringPrintWriter.cpp DOMStringPrintWriter.hpp DecimalFormat.cpp DecimalFormat.hpp DecimalFormatSymbols.cpp DecimalFormatSymbols.hpp DirectoryEnumerator.hpp ExecutionContext.hpp NamedNodeMapAttributeList.cpp NamedNodeMapAttributeList.hpp NullPrintWriter.cpp NullPrintWriter.hpp NumberFormat.cpp NumberFormat.hpp PrintWriter.hpp STLHelper.hpp StringTokenizer.cpp StringTokenizer.hpp Writer.hpp XSLException.cpp XSLException.hpp
dbertoni 00/04/11 07:35:34
Modified: c/src/PlatformSupport AttributeListImpl.cpp
AttributeListImpl.hpp DOMStringHelper.cpp
DOMStringHelper.hpp DOMStringPrintWriter.cpp
DOMStringPrintWriter.hpp DecimalFormat.cpp
DecimalFormat.hpp DecimalFormatSymbols.cpp
DecimalFormatSymbols.hpp DirectoryEnumerator.hpp
ExecutionContext.hpp NamedNodeMapAttributeList.cpp
NamedNodeMapAttributeList.hpp NullPrintWriter.cpp
NullPrintWriter.hpp NumberFormat.cpp
NumberFormat.hpp PrintWriter.hpp STLHelper.hpp
StringTokenizer.cpp StringTokenizer.hpp Writer.hpp
XSLException.cpp XSLException.hpp
Log:
Changes for new Xalan DOM.
Revision Changes Path
1.4 +33 -17 xml-xalan/c/src/PlatformSupport/AttributeListImpl.cpp
Index: AttributeListImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/AttributeListImpl.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AttributeListImpl.cpp 2000/02/17 20:27:26 1.3
+++ AttributeListImpl.cpp 2000/04/11 14:35:29 1.4
@@ -64,8 +64,7 @@
-#include <util/Janitor.hpp>
-#include <util/XMLString.hpp>
+#include "DOMStringHelper.hpp"
@@ -258,15 +257,11 @@
+
const XMLCh*
AttributeListImpl::getValue(const char* const name) const
{
- XMLCh* const theTranscodedName =
- XMLString::transcode(name);
-
- ArrayJanitor<XMLCh> theJanitor(theTranscodedName);
-
- return getValue(theTranscodedName);
+ return getValue(MakeXalanDOMCharVector(name).begin());
}
@@ -300,10 +295,11 @@
#if !defined(XALAN_NO_NAMESPACES)
using std::for_each;
#endif
+
// Delete all of the objects in the vector.
- std::for_each(m_AttributeVector.begin(),
- m_AttributeVector.end(),
- DeleteFunctor<AttributeVectorEntry>());
+ for_each(m_AttributeVector.begin(),
+ m_AttributeVector.end(),
+ DeleteFunctor<AttributeVectorEntry>());
// Clear everything out.
m_AttributeVector.clear();
@@ -312,11 +308,28 @@
+// A convenience function to find the length of a null-terminated
+// array of XMLChs
+static const XMLCh*
+endArray(const XMLCh* data)
+{
+ const XMLCh* theEnd = data;
+
+ while(*theEnd)
+ {
+ ++theEnd;
+ }
+
+ return theEnd;
+}
+
+
+
bool
AttributeListImpl::addAttribute(
- const XMLCh* const name,
- const XMLCh* const type,
- const XMLCh* const value)
+ const XMLCh* name,
+ const XMLCh* type,
+ const XMLCh* value)
{
#if !defined(XALAN_NO_NAMESPACES)
using std::make_pair;
@@ -333,9 +346,9 @@
if (m_AttributeKeyMap.find(name) == m_AttributeKeyMap.end())
{
AttributeVectorEntry* const theEntry =
- new AttributeVectorEntry(MakeXMLChVector(name),
- MakeXMLChVector(value),
- MakeXMLChVector(type));
+ new AttributeVectorEntry(XMLChVectorType(name, endArray(name) + 1),
+ XMLChVectorType(value, endArray(value) + 1),
+ XMLChVectorType(type, endArray(type) + 1));
// Add the new one.
m_AttributeVector.push_back(theEntry);
@@ -381,6 +394,9 @@
m_AttributeVector.end(),
bind1st(equal_to<const AttributeVectorEntry*>(), (*i).second));
assert(j != m_AttributeVector.end());
+
+ // Delete it...
+ delete *j;
// Erase it from the vector.
m_AttributeVector.erase(j);
1.4 +17 -11 xml-xalan/c/src/PlatformSupport/AttributeListImpl.hpp
Index: AttributeListImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/AttributeListImpl.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AttributeListImpl.hpp 2000/02/23 20:23:11 1.3
+++ AttributeListImpl.hpp 2000/04/11 14:35:29 1.4
@@ -117,7 +117,7 @@
virtual const XMLCh*
getValue(const XMLCh* const name) const;
- virtual const XMLCh*
+ virtual const XMLCh*
getValue(const char* const name) const;
// The mutators are new to this class.
@@ -136,9 +136,9 @@
* @param value attribute value
*/
virtual bool
- addAttribute(const XMLCh* const name,
- const XMLCh* const type,
- const XMLCh* const value);
+ addAttribute(const XMLCh* name,
+ const XMLCh* type,
+ const XMLCh* value);
/**
* Removes an attribute from the attribute list
@@ -146,7 +146,7 @@
* @param name attribute name
*/
virtual bool
- removeAttribute(const XMLCh* const name);
+ removeAttribute(const XMLCh* name);
protected:
@@ -155,21 +155,27 @@
operator==(const AttributeListImpl&) const;
+#if defined(XALAN_NO_NAMESPACES)
+ typedef vector<XMLCh> XMLChVectorType;
+#else
+ typedef std::vector<XMLCh> XMLChVectorType;
+#endif
+
// A struct to hold information about each attribute.
struct AttributeVectorEntry
{
- AttributeVectorEntry(const XMLCharVectorType& theName = XMLCharVectorType(),
- const XMLCharVectorType& theValue = XMLCharVectorType(),
- const XMLCharVectorType& theType = XMLCharVectorType()) :
+ AttributeVectorEntry(const XMLChVectorType& theName = XMLChVectorType(),
+ const XMLChVectorType& theValue = XMLChVectorType(),
+ const XMLChVectorType& theType = XMLChVectorType()) :
m_Name(theName),
m_Value(theValue),
m_Type(theType)
{
}
- const XMLCharVectorType m_Name;
- const XMLCharVectorType m_Value;
- const XMLCharVectorType m_Type;
+ const XMLChVectorType m_Name;
+ const XMLChVectorType m_Value;
+ const XMLChVectorType m_Type;
};
#if defined(XALAN_NO_NAMESPACES)
1.14 +490 -189 xml-xalan/c/src/PlatformSupport/DOMStringHelper.cpp
Index: DOMStringHelper.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/DOMStringHelper.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- DOMStringHelper.cpp 2000/03/20 14:33:39 1.13
+++ DOMStringHelper.cpp 2000/04/11 14:35:29 1.14
@@ -66,23 +66,26 @@
+#include <algorithm>
#include <strstream>
#include <vector>
#if !defined(XALAN_NO_NAMESPACES)
+using std::back_inserter;
+using std::copy;
using std::hex;
using std::ostream;
using std::ostrstream;
using std::string;
+using std::transform;
using std::vector;
#endif
// Xerces header files
-#include <util/Janitor.hpp>
#include <util/TextOutputStream.hpp>
#include <util/XMLString.hpp>
@@ -92,18 +95,27 @@
#include "DoubleSupport.hpp"
+#include "STLHelper.hpp"
-#if !defined(XML_LSTRSUPPORT)
+// The maximum number of digits that sprintf can put in a buffer.
+// 100 for now. We're using this because we want to avoid transcoding
+// number strings when we don't have to,
+const size_t MAX_PRINTF_DIGITS = 50;
+
+
+
+#if !defined(XALAN_LSTRSUPPORT)
// This string is defined just to make sure that
// _something_ trips the initialization code
// before main() is entered.
-const DOMString theDummy(XALAN_STATIC_UCODE_STRING("dummy"));
+const XalanDOMString theDummy(XALAN_STATIC_UCODE_STRING("dummy"));
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(const DOMString)
+
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(const XalanDOMString)
initializeAndTranscode(const char* theString)
{
static bool fInitialized = false;
@@ -115,70 +127,80 @@
fInitialized = true;
}
- return DOMString(theString);
+ return XalanDOMString(theString);
}
#endif
+
+#if !defined(XALAN_FULL_WCHAR_SUPPORT)
+
// Simulates the java String method indexOf(). Returns the index of theChar
-// in theString, or -1 if the character is not found.
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
-indexOf(const DOMString& theString,
- XMLCh theChar)
+// in theString, or length(theString) if the character is not found.
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(unsigned int)
+indexOf(
+ const XalanDOMChar* theString,
+ XalanDOMChar theChar)
{
const unsigned int theLength = length(theString);
if (theLength == 0)
{
- return -1;
+ return theLength;
}
else
{
unsigned int theIndex = 0;
while(theIndex < theLength &&
- charAt(theString, theIndex) != theChar)
+ theString[theIndex] != theChar)
{
++theIndex;
}
- return theIndex == theLength ? -1 : theIndex;
+ return theIndex == theLength ? theLength : theIndex;
}
}
+#endif
+
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
-indexOf(const DOMString& theFirstString,
- const DOMString& theSecondString)
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(unsigned int)
+indexOf(
+ const XalanDOMChar* theString,
+ const XalanDOMChar* theSubstring)
{
- const unsigned int theFirstStringLength = length(theFirstString);
- const unsigned int theSecondStringLength = length(theSecondString);
+ assert(theString != 0);
+ assert(theSubstring != 0);
+ const unsigned int theStringLength = length(theString);
+ const unsigned int theSubstringLength = length(theSubstring);
+
// If the substring is longer than the string, then
// it's not a substring.
- if (theFirstStringLength < theSecondStringLength)
+ if (theStringLength < theSubstringLength)
{
- return -1;
+ return theStringLength;
}
else
{
bool fMatch = false;
- unsigned int theFirstStringIndex = 0;
+ unsigned int theStringIndex = 0;
// While we haven't matched, and we haven't finished with the
// first string, and the number of characters left in the first
// string is greater than the length of the second string, try
// to match the strings.
while(fMatch == false &&
- theFirstStringIndex < theFirstStringLength &&
- theFirstStringLength - theFirstStringIndex >= theSecondStringLength)
+ theStringIndex < theStringLength &&
+ theStringLength - theStringIndex >= theSubstringLength)
{
// We always start over from the beginning of the second string.
- unsigned int theSecondStringIndex = 0;
+ unsigned int theSubstringIndex = 0;
// This variable will be incremented to index into the first
// string. That way, we preserve the first string index for
@@ -188,68 +210,96 @@
// Compare the characters in the two strings, at the
// current indices, until the characters don't match.
- while(theFirstStringIndex < theFirstStringLength &&
- theSecondStringIndex < theSecondStringLength &&
- charAt(theFirstString, theFirstStringIndex + theOffset) ==
- charAt(theSecondString, theSecondStringIndex))
+ while(theStringIndex < theStringLength &&
+ theSubstringIndex < theSubstringLength &&
+ theString[theStringIndex + theOffset] ==
+ theSubstring[theSubstringIndex])
{
theOffset++;
- theSecondStringIndex++;
+ theSubstringIndex++;
}
// If we've reached the end of the second string,
// then we've found a match.
- if (theSecondStringIndex == theSecondStringLength)
+ if (theSubstringIndex == theSubstringLength)
{
fMatch = true;
}
else
{
- theFirstStringIndex++;
+ theStringIndex++;
}
}
- return fMatch == false ? -1 : theFirstStringIndex;
+ return fMatch == false ? theStringLength : theStringIndex;
}
}
-// Simulates the java String method lastIndexOf(). Returns the index of theChar
-// in theString, or -1 if the character is not found.
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
-lastIndexOf(const DOMString& theString, XMLCh theChar)
+
+
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(unsigned int)
+indexOf(
+ const XalanDOMString& theString,
+ const XalanDOMString& theSubstring)
+{
+ if (isEmpty(theString) == true)
+ {
+ return 0;
+ }
+ else if (isEmpty(theSubstring) == true)
+ {
+ return theString.length();
+ }
+ else
+ {
+ return indexOf(c_wstr(theString), c_wstr(theSubstring));
+ }
+}
+
+
+
+#if !defined(XALAN_FULL_WCHAR_SUPPORT)
+
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(unsigned int)
+lastIndexOf(
+ const XalanDOMChar* theString,
+ XalanDOMChar theChar)
{
const unsigned int theLength = length(theString);
if (theLength == 0)
{
- return -1;
+ return theLength;
}
else
{
- int theIndex = theLength - 1;
+ unsigned int theIndex = theLength - 1;
- while(theIndex >=0 && charAt(theString, theIndex) != theChar)
+ while(theIndex < theLength && theString[theIndex] != theChar)
{
theIndex--;
}
- return theIndex == -1 ? -1 : theIndex;
+ return theIndex > theLength ? theLength : theIndex;
}
}
+#endif
+
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
-startsWith(const DOMString& theDOMString,
- const DOMString& theSubString)
+startsWith(
+ const XalanDOMChar* theString,
+ const XalanDOMChar* theSubstring)
{
bool fResult = false;
- const unsigned int theStringLength = length(theDOMString);
+ const unsigned int theStringLength = length(theString);
assert(theStringLength >= 0);
- const unsigned int theSubStringLength = length(theSubString);
+ const unsigned int theSubStringLength = length(theSubstring);
assert(theSubStringLength >= 0);
// If either string is of length 0, or if the substring
@@ -261,7 +311,7 @@
// Compare each character...
for (;
i < theSubStringLength &&
- charAt(theDOMString, i) == charAt(theSubString, i);
+ theString[i] == theSubstring[i];
i++)
{
;
@@ -281,15 +331,48 @@
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
+startsWith(
+ const XalanDOMString& theDOMString,
+ const XalanDOMString& theSubstring)
+{
+ const bool fStringIsEmpty = isEmpty(theDOMString);
+ const bool fSubstringIsEmpty = isEmpty(theSubstring);
+
+ // $$$ ToDo: Are these cases with the empty strings
+ // correct?
+ if (fStringIsEmpty == true)
+ {
+ if (fSubstringIsEmpty == false)
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+ else if (isEmpty(theSubstring) == true)
+ {
+ return false;
+ }
+ else
+ {
+ return startsWith(c_wstr(theDOMString), c_wstr(theSubstring));
+ }
+}
+
+
+
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
endsWith(
- const DOMString& theDOMString,
- const DOMString& theSubString)
+ const XalanDOMChar* theString,
+ const XalanDOMChar* theSubstring)
{
- bool fResult = false;
+ bool fResult = false;
- const unsigned int theStringLength = length(theDOMString);
+ const unsigned int theStringLength = length(theString);
- const unsigned int theSubStringLength = length(theSubString);
+ const unsigned int theSubStringLength = length(theSubstring);
// If either string is of length 0, or if the substring
// is longer, there's no point in continuing.
@@ -301,7 +384,7 @@
// Compare each character...
for (;
j >= 0 &&
- charAt(theDOMString, i) == charAt(theSubString, j);
+ theString[i] == theSubstring[j];
--j, --i)
{
;
@@ -322,8 +405,8 @@
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void)
-OutputString(TextOutputStream& theStream,
- const DOMString& theString)
+OutputString(TextOutputStream& theStream,
+ const XalanDOMString& theString)
{
if (isEmpty(theString) == false)
{
@@ -335,94 +418,162 @@
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void)
OutputString(
- ostream& theStream,
- const DOMString& theString)
+ ostream& theStream,
+ const XalanDOMString& theString)
{
char* const theTranscodedString =
theString.transcode();
- ArrayJanitor<char> theJanitor(theTranscodedString);
+ array_auto_ptr<char> theJanitor(theTranscodedString);
theStream << theTranscodedString;
}
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(DOMString)
-toLowerCase(const DOMString& theString)
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)
+substring(
+ const XalanDOMChar* theString,
+ unsigned int theStartIndex,
+ unsigned int theEndIndex)
{
+ assert(theString != 0);
+
const unsigned int theStringLength = length(theString);
- if (theStringLength == 0)
+ // $$$ ToDo: In Java-land, any failing of these
+ // assertions would result in an exception being thrown.
+ assert(theStartIndex <= theStringLength && theStartIndex >= 0);
+
+ if (theStartIndex == theStringLength)
{
- return theString;
+ // This is allowed, and should return an empty string.
+ return XalanDOMString();
}
else
{
- DOMString theLowerCaseString(theString.clone());
+ const unsigned int theLength = theEndIndex == UINT_MAX ? theStringLength - theStartIndex :
+ theEndIndex - theStartIndex;
+ assert(theStartIndex + theLength <= theStringLength);
- XMLCh* const theBuffer = theLowerCaseString.rawBuffer();
- assert(theBuffer != 0);
+ return XalanDOMString(theString + theStartIndex, theLength);
+ }
+}
+
+
+
+
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)
+substring(
+ const XalanDOMString& theString,
+ unsigned int theStartIndex,
+ unsigned int theEndIndex)
+{
+ const unsigned int theStringLength = length(theString);
+
+ // $$$ ToDo: In Java-land, any failing of these
+ // assertions would result in an exception being thrown.
+ assert(theStartIndex <= theStringLength && theStartIndex >= 0);
+
+ if (theStartIndex == theStringLength)
+ {
+ // This is allowed, and should return an empty string.
+ return XalanDOMString();
+ }
+ else
+ {
+ const unsigned int theLength = theEndIndex == UINT_MAX ? theStringLength - theStartIndex :
+ theEndIndex - theStartIndex;
+ assert(theStartIndex + theLength <= theStringLength);
+
+ // @@ JMD:
+ // If this is the case, the DOMString class doesn't create a new string,
+ // and in any case, does not null terminate the string, just points to
+ // the beginning, so we have to manually extract 'theLength' characters
+ // and create a new buffer
+ if (0 == theStartIndex)
+ {
+ vector<XalanDOMChar> theBuffer;
+
+ // Reserve the buffer now. We don't have to null-terminate,
+ // because the XalanDOMString constructor will take a size
+ // option.
+ theBuffer.reserve(theLength);
- for(unsigned int i = 0; i < theStringLength; i++)
+ const XalanDOMChar* const ptr = theString.rawBuffer();
+
+ copy(ptr,
+ ptr + theLength,
+ back_inserter(theBuffer));
+
+ return XalanDOMString(theBuffer.begin(), theBuffer.size());
+ }
+ else
{
- theBuffer[i] = towlower(theBuffer[i]);
+ return theString.substringData(theStartIndex, theLength);
}
-
- return theLowerCaseString;
}
}
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(DOMString)
-toUpperCase(const DOMString& theString)
+template <class FunctionType>
+XalanDOMString
+TransformXalanDOMString(
+ const XalanDOMString& theInputString,
+ FunctionType theFunction)
{
- const unsigned int theStringLength = length(theString);
+ const unsigned int theStringLength = length(theInputString);
if (theStringLength == 0)
{
- return theString;
+ return theInputString;
}
else
{
- DOMString theLowerCaseString(theString.clone());
+ vector<XalanDOMChar> theConvertedString;
- XMLCh* const theBuffer = theLowerCaseString.rawBuffer();
+ const XalanDOMChar* const theBuffer = c_wstr(theInputString);
assert(theBuffer != 0);
- for(unsigned int i = 0; i < theStringLength; i++)
- {
- theBuffer[i] = towupper(theBuffer[i]);
- }
+ transform(theBuffer,
+ theBuffer + theStringLength,
+ back_inserter(theConvertedString),
+ theFunction);
- return theLowerCaseString;
+ return XalanDOMString(theConvertedString.begin(), theConvertedString.size());
}
}
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
-equals(const XMLCh* theLHS,
- const XMLCh* theRHS)
+
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)
+toLowerCase(const XalanDOMString& theString)
{
- assert(theLHS != 0 && theRHS != 0);
+ return TransformXalanDOMString(theString, towlower);
+}
- while(*theLHS != 0 && *theRHS != 0 && *theLHS == *theRHS)
- {
- theLHS++;
- theRHS++;
- }
- return *theLHS == *theRHS ? true : false;
+
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)
+toUpperCase(const XalanDOMString& theString)
+{
+ return TransformXalanDOMString(theString, towupper);
}
+#if !defined(_MSC_VER)
+
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
-equalsIgnoreCase(const DOMString& theLHS,
- const DOMString& theRHS)
+equalsIgnoreCase(
+ const XalanDOMChar* theLHS,
+ const XalanDOMChar* theRHS)
{
+ assert(theLHS != 0);
+ assert(theRHS != 0);
+
bool fResult = false;
const unsigned int theLength = length(theLHS);
@@ -436,8 +587,8 @@
for(; i < theLength; i++)
{
- if (towupper(charAt(theLHS, i)) !=
- towupper(charAt(theRHS, i)))
+ if (towupper(theLHS[i]) !=
+ towupper(theRHS[i]))
{
break;
}
@@ -453,12 +604,46 @@
return fResult;
}
+#endif
+
+
+
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
+equalsIgnoreCase(
+ const XalanDOMString& theLHS,
+ const XalanDOMString& theRHS)
+{
+ const bool fLHSIsEmpty = isEmpty(theLHS);
+ const bool fRHSIsEmpty = isEmpty(theRHS);
+
+ if (fLHSIsEmpty == true)
+ {
+ // If theRHS is empty, then they're equal, or if the
+ // length of theRHS is 0, they're equal as well.
+ return fRHSIsEmpty == true ? true : length(theRHS) == 0 ? true : false;
+ }
+ else if (fRHSIsEmpty == true)
+ {
+ // It the length of theRHS is 0, they're equal.
+ return length(theLHS) == 0 ? true : false;
+ }
+ else
+ {
+ assert(c_wstr(theLHS) != 0);
+ assert(c_wstr(theRHS) != 0);
+
+ return equalsIgnoreCase(c_wstr(theLHS), c_wstr(theRHS));
+ }
+}
+
+#if !defined(XALAN_FULL_WCHAR_SUPPORT)
+
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
compare(
- const DOMString& theLHS,
- const DOMString& theRHS)
+ const XalanDOMChar* theLHS,
+ const XalanDOMChar* theRHS)
{
unsigned const int theLHSLength = length(theLHS);
unsigned const int theRHSLength = length(theRHS);
@@ -467,15 +652,15 @@
if (theLHSLength != 0 || theRHSLength != 0)
{
- XMLCh theLHSChar = 0;
- XMLCh theRHSChar = 0;
+ XalanDOMChar theLHSChar = 0;
+ XalanDOMChar theRHSChar = 0;
unsigned int i = 0;
for(; i < theLHSLength && i < theRHSLength; i++)
{
- theLHSChar = charAt(theLHS, i);
- theRHSChar = charAt(theRHS, i);
+ theLHSChar = theLHS[i];
+ theRHSChar = theRHS[i];
if (theLHSChar != theRHSChar)
{
@@ -513,11 +698,105 @@
return theResult;
}
+#endif
+
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
+compare(
+ const XalanDOMString& theLHS,
+ const XalanDOMString& theRHS)
+{
+ const bool fLHSIsEmpty = isEmpty(theLHS);
+ const bool fRHSIsEmpty = isEmpty(theRHS);
+
+ // correct?
+ if (fLHSIsEmpty == true)
+ {
+ if (fRHSIsEmpty == true || length(theRHS) == 0)
+ {
+ return 0;
+ }
+ else
+ {
+ return 1;
+ }
+ }
+ else if (isEmpty(theRHS) == true)
+ {
+ if (length(theLHS) == 0)
+ {
+ return 0;
+ }
+ else
+ {
+ return -1;
+ }
+ }
+ else
+ {
+ assert(c_wstr(theLHS) != 0 && c_wstr(theRHS) != 0);
+
+ return compare(c_wstr(theLHS), c_wstr(theRHS));
+ }
+}
+
+
+
+
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMCharVectorType)
+MakeXalanDOMCharVector(
+ const char* data,
+ bool fTranscode)
+{
+ assert(data != 0);
+
+ if (fTranscode == true)
+ {
+ XalanDOMChar* theTranscodedData = XMLString::transcode(data);
+
+ array_auto_ptr<XalanDOMChar> theJanitor(theTranscodedData);
+
+ // Create a vector which includes the terminating 0.
+
+ return MakeXalanDOMCharVector(theTranscodedData);
+ }
+ else
+ {
+ // Include the terminating null byte...
+ const unsigned int theLength = strlen(data) + 1;
+
+ XalanDOMCharVectorType theResult;
+
+ theResult.reserve(theLength);
+
+ copy(data,
+ data + theLength,
+ back_inserter(theResult));
+
+ return theResult;
+ }
+}
+
+
+
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMCharVectorType)
+MakeXalanDOMCharVector(const XalanDOMChar* data)
+{
+ assert(data != 0);
+
+ unsigned int theLength = length(data);
+
+ // Create a vector which includes the terminating 0.
+ return XalanDOMCharVectorType(data, data + theLength);
+}
+
+
+
static void
-CopyDOMStringToVector(const DOMString& theString,
- vector<char>& theVector)
+CopyWideStringToVector(
+ const XalanDOMChar* theString,
+ vector<char>& theVector)
{
const int theLength = length(theString);
@@ -529,14 +808,14 @@
{
#if defined(XALAN_OLD_STYLE_CASTS)
// Assert that the truncation will not affect the resulting character.
- assert(charAt(theString, i) == (char)charAt(theString, i));
+ assert(theString[i] == (char)theString[i]);
- theVector.push_back((char)charAt(theString, i));
+ theVector.push_back((char)theString[i]);
#else
// Assert that the truncation will not affect the resulting character.
- assert(charAt(theString, i) == static_cast<char>(charAt(theString, i)));
+ assert(theString[i] == static_cast<char>(theString[i]));
- theVector.push_back(static_cast<char>(charAt(theString, i)));
+ theVector.push_back(static_cast<char>(theString[i]));
#endif
}
@@ -547,16 +826,15 @@
-
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
-DOMStringToInt(const DOMString& theString)
+WideStringToInt(const XalanDOMChar* theString)
{
int theResult = 0;
vector<char> theVector;
- CopyDOMStringToVector(theString,
- theVector);
+ CopyWideStringToVector(theString,
+ theVector);
if (theVector.size() > 0)
{
@@ -569,14 +847,14 @@
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(long)
-DOMStringToLong(const DOMString& theString)
+WideStringToLong(const XalanDOMChar* theString)
{
long theResult = 0;
vector<char> theVector;
- CopyDOMStringToVector(theString,
- theVector);
+ CopyWideStringToVector(theString,
+ theVector);
if (theVector.size() > 0)
{
@@ -589,18 +867,21 @@
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(double)
-DOMStringToDouble(const DOMString& theString)
+WideStringToDouble(const XalanDOMChar* theString)
{
- double theResult = DoubleSupport::getNaN();
+ double theResult = DoubleSupport::getNaN();
- if (length(theString) > 0)
+ // This extra test is here because of all the difficulties
+ // with Xerces DOMString implementation. It's just
+ // easier this way...
+ if (theString != 0 && length(theString) > 0)
{
typedef vector<char> VectorType;
VectorType theVector;
- CopyDOMStringToVector(theString,
- theVector);
+ CopyWideStringToVector(theString,
+ theVector);
if (theVector.size() > 0)
{
@@ -638,8 +919,8 @@
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(DOMString)
-trim(const DOMString& theString)
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)
+trim(const XalanDOMString& theString)
{
if (isEmpty(theString))
return theString;
@@ -665,25 +946,23 @@
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(DOMString)
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)
DoubleToDOMString(double theDouble)
{
if (DoubleSupport::isNaN(theDouble) == true)
{
- return "NaN";
+ return XALAN_STATIC_UCODE_STRING("NaN");
}
else if (DoubleSupport::isPositiveInfinity(theDouble) == true)
{
- return "Infinity";
+ return XALAN_STATIC_UCODE_STRING("Infinity");
}
else if (DoubleSupport::isNegativeInfinity(theDouble) == true)
{
- return "-Infinity";
+ return XALAN_STATIC_UCODE_STRING("-Infinity");
}
else
{
- ostrstream theFormatter;
-
// $$$ ToDo: this is all temporary, until we get the NumberFormat and DecimalFormat
// classes working.
// According to the XPath standard, any values without
@@ -692,21 +971,14 @@
double fracPart = fabs(modf(theDouble, &intPart));
- string theResult;
-
if (fracPart == 0)
{
-#if defined(XALAN_OLD_STYLE_CASTS)
- theFormatter << (long)theDouble << '\0';
-
-#else
- theFormatter << static_cast<long>(theDouble) << '\0';
-
-#endif
- theResult = theFormatter.str();
+ return LongToDOMString(theDouble);
}
else
{
+ ostrstream theFormatter;
+
theFormatter << theDouble << '\0';
// OK, now we have to clean up the output for
@@ -718,99 +990,126 @@
// point, and and least 1 non-zero digit after
// the decimal point, since any values with no
// fractional part were printed as integers
- theResult = theFormatter.str();
+ XalanDOMCharVectorType theResult =
+ MakeXalanDOMCharVector(theFormatter.str(), false);
- string::iterator thePosition = theResult.end();
+ theFormatter.freeze(false);
+ XalanDOMCharVectorType::iterator thePosition = theResult.end();
+
+ // Move to the terminating null byte...
+ --thePosition;
+
+ // Now, move back while there are zeros.
while(*--thePosition == '0')
{
}
- theResult.erase(++thePosition);
- }
+ // Move up one, since we need to keep at least one...
+ ++thePosition;
+
+ // Terminate it...
+ *thePosition = 0;
- delete(theFormatter.str());
- return theResult.c_str();
+ return XalanDOMString(theResult.begin());
+ }
}
}
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(DOMString)
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)
LongToHexDOMString(long theLong)
{
+#if defined(XALAN_FULL_WCHAR_SUPPORT)
+
+ wchar_t theBuffer[MAX_PRINTF_DIGITS + 1];
+
+ swprintf(theBuffer,
+ L"%lx",
+ theLong);
+
+ return XalanDOMString(theBuffer, length(theBuffer));
+
+#else
+
ostrstream theFormatter;
theFormatter << hex << theLong << '\0';
- DOMString theString = theFormatter.str();
- delete theFormatter.str();
+
+ const XalanDOMString theString = theFormatter.str();
+
+ theFormatter.freeze(false);
+
return theString;
+
+#endif
}
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(DOMString)
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)
LongToDOMString(long theLong)
{
- ostrstream theFormatter;
+#if defined(XALAN_FULL_WCHAR_SUPPORT)
- theFormatter << theLong << '\0';
- DOMString theString = theFormatter.str();
- delete theFormatter.str();
- return theString;
-}
+ wchar_t theBuffer[MAX_PRINTF_DIGITS + 1];
+ swprintf(theBuffer,
+ L"%ld",
+ theLong);
+ return XalanDOMString(theBuffer, length(theBuffer));
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(DOMString)
-UnsignedLongToDOMString(unsigned long theUnsignedLong)
-{
+#else
+
ostrstream theFormatter;
- theFormatter << theUnsignedLong << '\0';
- DOMString theString = theFormatter.str();
- delete theFormatter.str();
+ theFormatter << theLong << '\0';
+
+ XalanDOMString theString = MakeDOMStheFormatter.str();
+
+ theFormatter.freeze(false);
+
return theString;
+
+#endif
}
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XMLCharVectorType)
-MakeXMLChVector(const char* data)
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)
+UnsignedLongToDOMString(unsigned long theUnsignedLong)
{
- assert(data != 0);
+#if defined(XALAN_FULL_WCHAR_SUPPORT)
- XMLCh* theTranscodedData = XMLString::transcode(data);
+ wchar_t theBuffer[MAX_PRINTF_DIGITS + 1];
- ArrayJanitor<XMLCh> theJanitor(theTranscodedData);
+ swprintf(theBuffer,
+ L"%lu",
+ theUnsignedLong);
- // Create a vector which includes the terminating 0.
- return MakeXMLChVector(theTranscodedData);
-}
+ return XalanDOMString(theBuffer, length(theBuffer));
+#else
+ ostrstream theFormatter;
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XMLCharVectorType)
-MakeXMLChVector(const XMLCh* data)
-{
- assert(data != 0);
+ theFormatter << theUnsignedLong << '\0';
- const XMLCh* theEnd = data;
+ XalanDOMString theString = theFormatter.str();
- // Find the terminating 0.
- while(*theEnd)
- {
- theEnd++;
- }
+ theFormatter.freeze(false);
- // Create a vector which includes the terminating 0.
- return XMLCharVectorType(data, theEnd + 1);
+ return theString;
+
+#endif
}
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
-isWhiteSpace(const DOMString& string)
+isWhiteSpace(const XalanDOMString& string)
{
const unsigned int theLength = length(string);
@@ -827,9 +1126,9 @@
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
isWhiteSpace(
- const XMLCh* const ch,
- unsigned int start,
- unsigned int length)
+ const XalanDOMChar* const ch,
+ unsigned int start,
+ unsigned int length)
{
const unsigned int end = start + length;
@@ -845,10 +1144,10 @@
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(string)
-DOMStringToStdString(const DOMString& domString)
+DOMStringToStdString(const XalanDOMString& domString)
{
- XMLCh* toTranscode = domString.rawBuffer();
- unsigned int len = domString.length();
+ XalanDOMChar* const toTranscode = domString.rawBuffer();
+ unsigned int len = domString.length();
// Short circuit if its a null pointer
@@ -857,21 +1156,22 @@
return string();
}
- // See if our XMLCh and wchar_t as the same on this platform
- const bool isSameSize = (sizeof(XMLCh) == sizeof(wchar_t));
+ // See if our XalanDOMChar and wchar_t as the same on this platform
+ const bool isSameSize = (sizeof(XalanDOMChar) == sizeof(wchar_t));
//
// Get the actual number of chars. If the passed len is zero, its null
// terminated. Else we have to use the len.
//
wchar_t realLen = (wchar_t)len;
+
if (!realLen)
{
//
// We cannot just assume we can use wcslen() because we don't know
- // if our XMLCh is the same as wchar_t on this platform.
+ // if our XalanDOMChar is the same as wchar_t on this platform.
//
- const XMLCh* tmpPtr = toTranscode;
+ const XalanDOMChar* tmpPtr = toTranscode;
while (*(tmpPtr++))
realLen++;
}
@@ -883,7 +1183,7 @@
//
wchar_t* const tmpSource = new wchar_t[realLen + 1];
- ArrayJanitor<wchar_t> tmpSourceJanitor(tmpSource);
+ array_auto_ptr<wchar_t> tmpSourceJanitor(tmpSource);
if (isSameSize)
{
@@ -905,14 +1205,15 @@
// Allocate out storage member
char* const localForm = new char[targetLen + 1];
- ArrayJanitor<char> localFormJanitor(localForm);
+ array_auto_ptr<char> localFormJanitor(localForm);
//
// And transcode our temp source buffer to the local buffer. Cap it
// off since the converter won't do it (because the null is beyond
// where the target will fill up.)
//
- ::wcstombs(localForm, tmpSource, targetLen);
+ wcstombs(localForm, tmpSource, targetLen);
+
localForm[targetLen] = 0;
return localForm;
1.12 +544 -245 xml-xalan/c/src/PlatformSupport/DOMStringHelper.hpp
Index: DOMStringHelper.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/DOMStringHelper.hpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- DOMStringHelper.hpp 2000/03/22 20:14:59 1.11
+++ DOMStringHelper.hpp 2000/04/11 14:35:29 1.12
@@ -70,12 +70,16 @@
#include <vector>
#include <string>
+#if defined(XALAN_LSTRSUPPORT)
+#include <cwchar>
+#endif
+
#if defined(__GNUC__)
#include <wctype.h>
#endif
-#include <dom/DOMString.hpp>
+#include <XalanDOM/XalanDOMString.hpp>
@@ -89,7 +93,7 @@
// It is _not_ designed to be thread-safe, because there will always be
// at least one global static transcoded string that will trigger the
// code at startup.
-#if defined(XML_LSTRSUPPORT)
+#if defined(XALAN_LSTRSUPPORT)
#define XALAN_STATIC_UCODE_STRING(str) L##str
@@ -97,7 +101,7 @@
// Makes sure the Xerces platform is initialized, then
// transcodes the string.
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(const DOMString)
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(const XalanDOMString)
initializeAndTranscode(const char* theString);
#define XALAN_STATIC_UCODE_STRING(str) initializeAndTranscode(str)
@@ -106,102 +110,85 @@
/**
- * Simulates the java String method indexOf().
+ * Get the underlying representation of the target XalanDOMString as a
+ * null-terminated string
*
- * @param theString string to search
- * @param theChar character searched for
- * @return the index of theChar in theString, or -1 if the character is not
- * found.
+ * @param theString target string
+ * @return null-terminated string of XalanDOMChar
*/
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
-indexOf(
- const DOMString& theString,
- XMLCh theChar);
+inline const XalanDOMChar*
+c_wstr(const XalanDOMString& theString)
+{
+ const XalanDOMChar* const ptr = theString.rawBuffer();
+ assert(!ptr || ptr[theString.length()] == '\0');
+ return ptr;
+}
-/**
- * Simulates the java String method indexOf().
- *
- * @param theString string to search
- * @param theSubString substring searched for
- * @return the index of theSubString in theString, or -1 if the string is not
- * found.
- */
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
-indexOf(
- const DOMString& theString,
- const DOMString& theSubString);
/**
- * Simulates the java String method lastIndexOf().
+ * Get the underlying representation of the wide string as a
+ * UNICODE null-terminated string. This is here simply for
+ * consistency in the code. On certain platforms, compiler-
+ * generated wide strings will not contain Unicode code
+ * points. Another macro converts those into XalanDOMStrings,
+ * which are then transcoded. In these cases, the previous
+ * defined c_sstr() function gets called.
+ *
+ * On platforms where the compiler does generate Unicode wide
+ * strings, this function will be called instead.
*
- * @param theString string to search
- * @param theChar character searched for
- * @return the index of theChar in theString, or -1 if the character is not
- * found.
+ * @param theString target string
+ * @return null-terminated string of XalanDOMChar
*/
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
-lastIndexOf(
- const DOMString& theString,
- XMLCh theChar);
+inline const XalanDOMChar*
+c_wstr(const XalanDOMChar* theString)
+{
+ return theString;
+}
/**
- * Simulates the java String method startsWith().
+ * Get the underlying representation of the target XalanDOMString as an array of
+ * XalanDOMChar, not guaranteed to be null-terminated.
*
- * @param theDOMString target string to search
- * @param theSubString substring searched for
- * @return true if the target string begins with the substring
+ * @param theString target string
+ * @return array of XalanDOMChar
*/
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
-startsWith(
- const DOMString& theDOMString,
- const DOMString& theSubString);
+inline XalanDOMChar*
+toCharArray(const XalanDOMString& theString)
+{
+ return theString.rawBuffer();
+}
/**
- * Simulates the java String method startsWith().
+ * Get the underlying representation of the target XalanDOMString as an array of
+ * XalanDOMChar, not guaranteed to be null-terminated.
*
- * @param theDOMString target string to search
- * @param theSubString substring searched for
- * @return true if the target string begins with the substring
+ * @param theString target string
+ * @return array of XalanDOMChar
*/
-inline bool
-startsWith(
- const DOMString& theDOMString,
- const char* theSubString)
+inline XalanDOMChar*
+toCharArray(XalanDOMString& theString)
{
- return startsWith(theDOMString,
- DOMString(theSubString));
+ return theString.rawBuffer();
}
-/**
- * Simulates the java String method endsWith().
- *
- * @param theDOMString target string to search
- * @param theSubString substring searched for
- * @return true if the target string ends with the substring
- */
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
-endsWith(
- const DOMString& theDOMString,
- const DOMString& theSubString);
-
-
/**
- * Simulates the java String method length() for a DOMString
+ * Simulates the java String method length() for a XalanDOMString
*
* @param theDOMString target string
* @return the length of the target string
*/
inline unsigned int
-length(const DOMString& theString)
+length(const XalanDOMString& theString)
{
return theString.length();
}
@@ -210,17 +197,20 @@
/**
* Simulates the java String method length() for a null-terminated buffer of
- * XMLCh characters
+ * XalanDOMChar characters
*
* @param theBuffer target string
* @return the length of the target string
*/
inline unsigned int
-length(const XMLCh* theBuffer)
+length(const XalanDOMChar* theBuffer)
{
assert(theBuffer != 0);
- const XMLCh* theBufferPointer = theBuffer;
+#if defined(XALAN_FULL_WCHAR_SUPPORT)
+ return wcslen(theBuffer);
+#else
+ const XalanDOMChar* theBufferPointer = theBuffer;
while(*theBufferPointer != 0)
{
@@ -228,6 +218,7 @@
}
return theBufferPointer - theBuffer;
+#endif
}
@@ -239,88 +230,351 @@
* @return true if the target string has a non-zero length
*/
inline bool
-isEmpty(const DOMString& str)
+isEmpty(const XalanDOMString& str)
{
return length(str) == 0 ? true : false;
}
+#if defined(XALAN_FULL_WCHAR_SUPPORT)
+
+inline unsigned int
+indexOf(
+ const XalanDOMChar* theString,
+ XalanDOMChar theChar)
+{
+ const XalanDOMChar* const thePointer =
+ wcschr(theString, theChar);
+
+ if (thePointer == 0)
+ {
+ return length(theString);
+ }
+ else
+ {
+ return thePointer - theString;
+ }
+}
+
+#else
+/**
+ * Simulates the java String method indexOf().
+ *
+ * @param theString string to search
+ * @param theChar character searched for
+ * @return the index of theChar in theString,
+ * or length(theString) if the character is not
+ * found.
+ */
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(unsigned int)
+indexOf(
+ const XalanDOMChar* theString,
+ XalanDOMChar theChar);
+#endif
+
+
/**
- * Converts a double value into a DOMString
+ * Simulates the java String method indexOf().
*
+ * @param theString string to search
+ * @param theChar character searched for
+ * @return the index of theChar in theString,
+ * or length(theString) if the character is not
+ * found.
+ */
+inline unsigned int
+indexOf(
+ const XalanDOMString& theString,
+ XalanDOMChar theChar)
+{
+ return indexOf(c_wstr(theString), theChar);
+}
+
+
+
+/**
+ * Simulates the java String method indexOf().
+ *
+ * @param theString string to search
+ * @param theSubstring substring searched for
+ * @return the index of theSubstring in theString,
+ * or length(theString) if the string is not
+ * found.
+ */
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(unsigned int)
+indexOf(
+ const XalanDOMChar* theString,
+ const XalanDOMChar* theSubstring);
+
+
+/**
+ * Simulates the java String method indexOf().
+ *
+ * @param theString string to search
+ * @param theSubstring substring searched for
+ * @return the index of theSubstring in theString,
+ * or length(theString) if the string is not
+ * found.
+ */
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(unsigned int)
+indexOf(
+ const XalanDOMString& theString,
+ const XalanDOMString& theSubstring);
+
+
+
+/**
+ * Simulates the java String method lastIndexOf().
+ *
+ * @param theString string to search
+ * @param theChar character searched for
+ * @return the index of theChar in theString,
+ * or length(theString) if the character is not
+ * found.
+ */
+#if defined(XALAN_FULL_WCHAR_SUPPORT)
+
+inline unsigned int
+lastIndexOf(
+ const XalanDOMChar* theString,
+ XalanDOMChar theChar)
+{
+ const XalanDOMChar* const thePointer =
+ wcsrchr(theString, theChar);
+
+ if (thePointer == 0)
+ {
+ return length(theString);
+ }
+ else
+ {
+ return thePointer - theString;
+ }
+}
+
+#else
+
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(unsigned int)
+lastIndexOf(
+ const XalanDOMChar* theString,
+ XalanDOMChar theChar);
+
+#endif
+
+/**
+ * Simulates the java String method lastIndexOf().
+ *
+ * @param theString string to search
+ * @param theChar character searched for
+ * @return the index of theChar in theString,
+ * or length(theString) if the character is not
+ * found.
+ */
+inline unsigned int
+lastIndexOf(
+ const XalanDOMString& theString,
+ XalanDOMChar theChar)
+{
+ return lastIndexOf(c_wstr(theString), theChar);
+}
+
+
+
+/**
+ * Simulates the java String method startsWith().
+ *
+ * @param theDOMString target string to search
+ * @param theSubstring substring searched for
+ * @return true if the target string begins with the substring
+ */
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
+startsWith(
+ const XalanDOMChar* theString,
+ const XalanDOMChar* theSubstring);
+
+
+
+/**
+ * Simulates the java String method startsWith().
+ *
+ * @param theDOMString target string to search
+ * @param theSubstring substring searched for
+ * @return true if the target string begins with the substring
+ */
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
+startsWith(
+ const XalanDOMString& theDOMString,
+ const XalanDOMString& theSubstring);
+
+
+
+/**
+ * Simulates the java String method startsWith().
+ *
+ * @param theDOMString target string to search
+ * @param theSubstring substring searched for
+ * @return true if the target string begins with the substring
+ */
+inline bool
+startsWith(
+ const XalanDOMString& theDOMString,
+ const char* theSubstring)
+{
+ return startsWith(theDOMString,
+ XalanDOMString(theSubstring));
+}
+
+
+/**
+ * Simulates the java String method endsWith().
+ *
+ * @param theDOMString target string to search
+ * @param theSubstring substring searched for
+ * @return true if the target string ends with the substring
+ */
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
+endsWith(
+ const XalanDOMChar* theString,
+ const XalanDOMChar* theSubstring);
+
+
+
+/**
+ * Simulates the java String method endsWith().
+ *
+ * @param theDOMString target string to search
+ * @param theSubstring substring searched for
+ * @return true if the target string ends with the substring
+ */
+inline bool
+endsWith(
+ const XalanDOMString& theDOMString,
+ const XalanDOMString& theSubstring)
+{
+ return endsWith(c_wstr(theDOMString), c_wstr(theSubstring));
+}
+
+
+
+/**
+ * Converts a double value into a XalanDOMString
+ *
* @param theDouble number to be converted
* @return decimal string representation of the number
*/
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(DOMString)
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)
DoubleToDOMString(double theDouble);
/**
- * Converts a long value into a DOMString
+ * Converts a long value into a XalanDOMString
*
* @param theInt number to be converted
* @return hexadecimal string representation of the number
*/
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(DOMString)
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)
LongToHexDOMString(long theInt);
/**
- * Converts a long value into a DOMString
+ * Converts a long value into a XalanDOMString
*
* @param theInt number to be converted
* @return decimal string representation of the number
*/
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(DOMString)
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)
LongToDOMString(long theInt);
/**
- * Converts an unsigned long value into a DOMString
+ * Converts an unsigned long value into a XalanDOMString
*
* @param theInt number to be converted
* @return decimal string representation of the number
*/
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(DOMString)
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)
UnsignedLongToDOMString(unsigned long theInt);
/**
- * Converts a DOMString into an integer value
+ * Converts a wide string into an integer value
*
* @param theString target string
* @return integer value of target string
*/
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
-DOMStringToInt(const DOMString& theString);
+WideStringToInt(const XalanDOMChar* theString);
/**
- * Converts a DOMString into a long value
+ * Converts a wide string into a long value
*
* @param theString target string
* @return long value of target string
*/
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(long)
-DOMStringToLong(const DOMString& theString);
+WideStringToLong(const XalanDOMChar* theString);
/**
- * Converts a DOMString into a double value
+ * Converts a wide string into a double value
*
* @param theString target string
* @return double value of target string
*/
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(double)
-DOMStringToDouble(const DOMString& theString);
+WideStringToDouble(const XalanDOMChar* theString);
+
+
+
+/**
+ * Converts a XalanDOMString into an integer value
+ *
+ * @param theString target string
+ * @return integer value of target string
+ */
+inline int
+DOMStringToInt(const XalanDOMString& theString)
+{
+ return WideStringToInt(c_wstr(theString));
+}
+
+
+
+/**
+ * Converts a XalanDOMString into a long value
+ *
+ * @param theString target string
+ * @return long value of target string
+ */
+inline long
+DOMStringToLong(const XalanDOMString& theString)
+{
+ return WideStringToLong(c_wstr(theString));
+}
+
+
+
+/**
+ * Converts a XalanDOMString into a double value
+ *
+ * @param theString target string
+ * @return double value of target string
+ */
+inline double
+DOMStringToDouble(const XalanDOMString& theString)
+{
+ return WideStringToDouble(c_wstr(theString));
+}
+
/**
@@ -332,8 +586,8 @@
*/
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void)
OutputString(
- TextOutputStream& theStream,
- const DOMString& theString);
+ TextOutputStream& theStream,
+ const XalanDOMString& theString);
@@ -347,11 +601,11 @@
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void)
OutputString(
#if defined(XALAN_NO_NAMESPACES)
- ostream& theStream,
+ ostream& theStream,
#else
- std::ostream& theStream,
+ std::ostream& theStream,
#endif
- const DOMString& theString);
+ const XalanDOMString& theString);
@@ -364,8 +618,8 @@
*/
inline TextOutputStream&
operator<<(
- TextOutputStream& theStream,
- const DOMString& theString)
+ TextOutputStream& theStream,
+ const XalanDOMString& theString)
{
OutputString(theStream,
theString);
@@ -388,8 +642,8 @@
inline std::ostream&
#endif
operator<<(
- std::ostream& theStream,
- const DOMString& theString)
+ std::ostream& theStream,
+ const XalanDOMString& theString)
{
OutputString(theStream,
theString);
@@ -405,8 +659,8 @@
* @param theString target string
* @return copy of string
*/
-inline DOMString
-clone(const DOMString& theString)
+inline XalanDOMString
+clone(const XalanDOMString& theString)
{
return theString.clone();
}
@@ -420,7 +674,7 @@
* @return true if character represents white space
*/
inline bool
-isSpace(XMLCh theChar)
+isSpace(XalanDOMChar theChar)
{
return iswspace(theChar) ? true : false;
}
@@ -434,10 +688,10 @@
* @param theIndex index of character
* @return character at specified index
*/
-inline XMLCh
+inline XalanDOMChar
charAt(
- const DOMString& theString,
- unsigned int theIndex)
+ const XalanDOMString& theString,
+ unsigned int theIndex)
{
return theString.charAt(theIndex);
}
@@ -451,7 +705,7 @@
* @return true if character represents a digit
*/
inline bool
-isDigit(XMLCh theChar)
+isDigit(XalanDOMChar theChar)
{
return iswdigit(theChar) ? true : false;
}
@@ -465,7 +719,7 @@
* @return true if character represents a letter or digit
*/
inline bool
-isLetterOrDigit(XMLCh theChar)
+isLetterOrDigit(XalanDOMChar theChar)
{
return iswalnum(theChar) ? true : false;
}
@@ -483,48 +737,30 @@
* @param theEndIndex ending index, exclusive
* @return string containing the specified range of characters from target
*/
-inline DOMString
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)
substring(
- const DOMString& theString,
- unsigned int theStartIndex,
- unsigned int theEndIndex = UINT_MAX)
-{
- const unsigned int theStringLength = length(theString);
+ const XalanDOMChar* theString,
+ unsigned int theStartIndex,
+ unsigned int theEndIndex = UINT_MAX);
- // $$$ ToDo: In Java-land, any failing of these
- // assertions would result in an exception being thrown.
- assert(theStartIndex <= theStringLength && theStartIndex >= 0);
- if (theStartIndex == theStringLength)
- {
- // This is allowed, and should return an empty string.
- return DOMString();
- }
- else
- {
- const unsigned int theLength = theEndIndex == UINT_MAX ? theStringLength - theStartIndex :
- theEndIndex - theStartIndex;
- assert(theStartIndex + theLength <= theStringLength);
-
- // @@ JMD:
- // If this is the case, the DOMString class doesn't create a new string,
- // and in any case, does not null terminate the string, just points to
- // the beginning, so we have to manually extract 'theLength' characters
- // and create a new buffer
- if (0 == theStartIndex)
- {
- const XMLCh *ptr = theString.rawBuffer();
- XMLCh *newStr = new XMLCh[theLength+1];
- for (size_t u = 0; u < theLength; u++)
- newStr[u] = ptr[u];
- newStr[u] = 0;
- DOMString domStr = newStr;
- delete []newStr;
- return domStr;
- }
- return theString.substringData(theStartIndex, theLength);
- }
-}
+
+/**
+ * Simulates the java String method substring(). Returns a new string that is
+ * a substring of this string. The substring begins at the specified
+ * theStartIndex and extends to the character at index theEndIndex - 1. Thus
+ * the length of the substring is theEndIndex-theStartIndex.
+ *
+ * @param theString target string
+ * @param theStartIndex starting index, inclusive
+ * @param theEndIndex ending index, exclusive
+ * @return string containing the specified range of characters from target
+ */
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)
+substring(
+ const XalanDOMString& theString,
+ unsigned int theStartIndex,
+ unsigned int theEndIndex = UINT_MAX);
@@ -535,8 +771,8 @@
* @param theString target string
* @return string containing lower case characters
*/
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(DOMString)
-toLowerCase(const DOMString& theString);
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)
+toLowerCase(const XalanDOMString& theString);
@@ -547,75 +783,109 @@
* @param theString target string
* @return string containing upper case characters
*/
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(DOMString)
-toUpperCase(const DOMString& theString);
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)
+toUpperCase(const XalanDOMString& theString);
// These two function are specifically not defined, and
// should produce ambiguity during compilation. This
-// is necessary because the Xerces DOMString class
+// is necessary because the Xerces XalanDOMString class
// defines == as referring to the same underlying
// handle, not identical strings, as in Java.
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
operator==(
- const DOMString& theLHS,
- const DOMString& theRHS);
+ const XalanDOMString& theLHS,
+ const XalanDOMString& theRHS);
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
operator!=(
- const DOMString& theLHS,
- const DOMString& theRHS);
+ const XalanDOMString& theLHS,
+ const XalanDOMString& theRHS);
/**
- * Get the underlying representation of the target DOMString as a
- * null-terminated string
+ * Compare the contents of two strings for equality
*
- * @param theString target string
- * @return null-terminated string of XMLCh
+ * @param theLHS first string to compare
+ * @param theRHS second string to compare
+ * @return Returns 0 for equal strings, less than 0 if theLHS is lexically
+ * less than theRHS, or greater than 0 if theRHS is lexically greater than
+ * theLHS.
+ * @see operator<
*/
-inline const XMLCh*
-c_wstr(const DOMString& theString)
+#if defined(XALAN_FULL_WCHAR_SUPPORT)
+
+inline int
+compare(
+ const XalanDOMChar* theLHS,
+ const XalanDOMChar* theRHS)
{
- XMLCh *ptr = theString.rawBuffer();
+ return wcscmp(theLHS, theRHS);
+}
- assert(!ptr || ptr[theString.length()] == '\0');
+#else
- return ptr;
-}
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
+compare(
+ const XalanDOMChar* theLHS,
+ const XalanDOMChar* theRHS);
+
+#endif
+
/**
- * Get the underlying representation of the target DOMString as an array of
- * XMLCh, not guaranteed to be null-terminated.
+ * Compare the contents of two strings for equality
*
- * @param theString target string
- * @return array of XMLCh
+ * @param theLHS first string to compare
+ * @param theRHS second string to compare
+ * @return Returns 0 for equal strings, less than 0 if theLHS is lexically
+ * less than theRHS, or greater than 0 if theRHS is lexically greater than
+ * theLHS.
+ * @see operator<
+ */
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
+compare(
+ const XalanDOMString& theLHS,
+ const XalanDOMString& theRHS);
+
+
+
+/**
+ * Compare the contents of two strings for equality
+ *
+ * @param theLHS first string to compare
+ * @param theRHS second string to compare
+ * @return true if the contents of both strings are identical
*/
-inline const XMLCh*
-toCharArray(const DOMString& theString)
+inline bool
+equals(const XalanDOMChar* theLHS,
+ const XalanDOMChar* theRHS)
{
- return theString.rawBuffer();
+ return compare(theLHS, theRHS) == 0 ? true : false;
}
/**
- * Get the underlying representation of the target DOMString as an array of
- * XMLCh, not guaranteed to be null-terminated.
+ * Compare the contents of two strings for equality
*
- * @param theString target string
- * @return array of XMLCh
+ * @param theLHS first string to compare
+ * @param theRHS second string to compare
+ * @return true if the contents of both strings are identical
*/
-inline XMLCh*
-toCharArray(DOMString& theString)
+inline bool
+equals(const XalanDOMChar* theLHS,
+ const XalanDOMString& theRHS)
{
- return theString.rawBuffer();
+ assert(theLHS != 0);
+
+ return theRHS.equals(theLHS);
}
@@ -627,9 +897,14 @@
* @param theRHS second string to compare
* @return true if the contents of both strings are identical
*/
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
-equals(const XMLCh* theLHS,
- const XMLCh* theRHS);
+inline bool
+equals(const XalanDOMString& theLHS,
+ const XalanDOMChar* theRHS)
+{
+ assert(theRHS != 0);
+
+ return theLHS.equals(theRHS);
+}
@@ -641,10 +916,12 @@
* @return true if the contents of both strings are identical
*/
inline bool
-equals(const XMLCh* theLHS,
- const DOMString& theRHS)
+equals(const XalanDOMString& theLHS,
+ const char* theRHS)
{
- return equals(theLHS, c_wstr(theRHS));
+ assert(theRHS != 0);
+
+ return theLHS.equals(theRHS) ? true : false;
}
@@ -657,10 +934,10 @@
* @return true if the contents of both strings are identical
*/
inline bool
-equals(const DOMString& theLHS,
- const XMLCh* theRHS)
+equals(const XalanDOMChar* theLHS,
+ const char* theRHS)
{
- return equals(c_wstr(theLHS), theRHS);
+ return equals(theLHS, XalanDOMString(theRHS));
}
@@ -673,10 +950,13 @@
* @return true if the contents of both strings are identical
*/
inline bool
-equals(const DOMString& theLHS,
- const char* theRHS)
+equals(const char* theLHS,
+ const XalanDOMChar* theRHS)
{
- return theLHS.equals(theRHS) ? true : false;
+ assert(theLHS != 0);
+ assert(theRHS != 0);
+
+ return equals(XalanDOMString(theLHS), theRHS);
}
@@ -690,14 +970,29 @@
*/
inline bool
equals(
- const DOMString& theLHS,
- const DOMString& theRHS)
+ const XalanDOMString& theLHS,
+ const XalanDOMString& theRHS)
{
return theLHS.equals(theRHS) ? true : false;
}
+#if defined(_MSC_VER)
+
+inline bool
+equalsIgnoreCase(
+ const XalanDOMChar* theLHS,
+ const XalanDOMChar* theRHS)
+{
+ assert(theLHS != 0);
+ assert(theRHS != 0);
+
+ return _wcsicmp(theLHS, theRHS) == 0 ? true : false;
+}
+
+#else
+
/**
* Compare the contents of two strings for equality, without regard for case
*
@@ -707,30 +1002,28 @@
*/
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
equalsIgnoreCase(
- const DOMString& theLHS,
- const DOMString& theRHS);
+ const XalanDOMChar* theLHS,
+ const XalanDOMChar* theRHS);
+#endif
/**
- * Compare the contents of two strings for equality
+ * Compare the contents of two strings for equality, without regard for case
*
* @param theLHS first string to compare
* @param theRHS second string to compare
- * @return Returns 0 for equal strings, less than 0 if theLHS is lexically
- * less than theRHS, or greater than 0 if theRHS is lexically greater than
- * theLHS.
- * @see operator<
+ * @return true if the case-insensitive contents of both strings are identical
*/
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
-compare(
- const DOMString& theLHS,
- const DOMString& theRHS);
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
+equalsIgnoreCase(
+ const XalanDOMString& theLHS,
+ const XalanDOMString& theRHS);
/**
- * Compare the contents of two strings for equality
+ * Implements operator< for DOMStrings.
*
* @param theLHS first string to compare
* @param theRHS second string to compare
@@ -740,8 +1033,8 @@
*/
inline bool
operator<(
- const DOMString& theLHS,
- const DOMString& theRHS)
+ const XalanDOMString& theLHS,
+ const XalanDOMString& theRHS)
{
return compare(theLHS, theRHS) < 0 ? true : false;
}
@@ -755,10 +1048,10 @@
* @param theStringToAppend string to add to target
* @return string with contents of 'theStringToAppend' added to target string
*/
-inline DOMString&
+inline XalanDOMString&
append(
- DOMString& theString,
- const DOMString& theStringToAppend)
+ XalanDOMString& theString,
+ const XalanDOMString& theStringToAppend)
{
theString.appendData(theStringToAppend);
@@ -773,8 +1066,8 @@
* @param theString target string
* @return string with contents of target string less trailing whitespace
*/
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(DOMString)
-trim(const DOMString& theString);
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)
+trim(const XalanDOMString& theString);
@@ -784,15 +1077,18 @@
* @param theString target string
*/
inline void
-clear(DOMString& theString)
+clear(XalanDOMString& theString)
{
- theString.deleteData(0, length(theString));
+ if (length(theString) > 0)
+ {
+ theString.deleteData(0, length(theString));
+ }
}
/**
- * Replaces a character at a specified index in a DOMString
+ * Replaces a character at a specified index in a XalanDOMString
*
* @param theString target string
* @param theIndex index of character
@@ -800,24 +1096,24 @@
*/
inline void
setCharAt(
- DOMString& theString,
- unsigned int theIndex,
- XMLCh theChar)
+ XalanDOMString& theString,
+ unsigned int theIndex,
+ XalanDOMChar theChar)
{
assert(theIndex < length(theString));
- XMLCh* const theBuffer = toCharArray(theString);
+ XalanDOMChar* const theBuffer = toCharArray(theString);
theBuffer[theIndex] = theChar;
}
-// A standard vector of XMLChs
+// A standard vector of XalanChars
#if defined(XALAN_NO_NAMESPACES)
-typedef vector<XMLCh> XMLCharVectorType;
+typedef vector<XalanDOMChar> XalanDOMCharVectorType;
#else
-typedef std::vector<XMLCh> XMLCharVectorType;
+typedef std::vector<XalanDOMChar> XalanDOMCharVectorType;
#endif
@@ -826,47 +1122,50 @@
/**
* Utility function to make a null-terminated vector of XMLChs, from a
- * null-terminated array of chars, via transcoding.
+ * null-terminated array of chars, via transcoding, if requested.
*
* @param data array to be converted
- * @return null-terminated vector of XMLCh
+ * @param whether or not to transcode
+ * @return null-terminated vector of XalanDOMChar
*/
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XMLCharVectorType)
-MakeXMLChVector(const char* data);
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMCharVectorType)
+MakeXalanDOMCharVector(
+ const char* data,
+ bool fTranscode = true);
/**
* Utility function to make a null-terminated vector of XMLChs, from a
- * null-terminated array of XMLCh.
+ * null-terminated array of XalanDOMChar.
*
* @param data array to be converted
- * @return null-terminated vector of XMLCh
+ * @return null-terminated vector of XalanDOMChar
*/
-XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XMLCharVectorType)
-MakeXMLChVector(const XMLCh* data);
+XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMCharVectorType)
+MakeXalanDOMCharVector(const XalanDOMChar* data);
/**
* Utility function to make a null-terminated vector of XMLChs, from a
- * DOMString
+ * XalanDOMString
*
- * @param data DOMString to be converted
- * @return null-terminated vector of XMLCh
+ * @param data XalanDOMString to be converted
+ * @return null-terminated vector of XalanDOMChar
*/
-inline XMLCharVectorType
-MakeXMLChVector(const DOMString& data)
+inline XalanDOMCharVectorType
+MakeXalanDOMCharVector(const XalanDOMString& data)
{
- return MakeXMLChVector(c_wstr(data));
+ return MakeXalanDOMCharVector(c_wstr(data));
}
#if defined(XALAN_NO_NAMESPACES)
-struct c_wstr_functor : public unary_function<DOMString, const XMLCh*>
+struct c_wstr_functor : public unary_function<XalanDOMString, const XalanDOMChar*>
#else
-struct c_wstr_functor : public std::unary_function<DOMString, const XMLCh*>
+struct c_wstr_functor : public std::unary_function<XalanDOMString, const XalanDOMChar*>
#endif
{
result_type
@@ -881,19 +1180,19 @@
/**
* Hash functor for DOMStrings
*
- * @param theKey DOMString to be hashed
- * @return hash value for DOMString
+ * @param theKey XalanDOMString to be hashed
+ * @return hash value for XalanDOMString
*/
#if defined(XALAN_NO_NAMESPACES)
-struct DOMStringHashFunction : public unary_function<const DOMString&, size_t>
+struct DOMStringHashFunction : public unary_function<const XalanDOMString&, size_t>
#else
-struct DOMStringHashFunction : public std::unary_function<const DOMString&, size_t>
+struct DOMStringHashFunction : public std::unary_function<const XalanDOMString&, size_t>
#endif
{
result_type
operator() (argument_type theKey) const
{
- const XMLCh* theRawBuffer = c_wstr(theKey);
+ const XalanDOMChar* theRawBuffer = c_wstr(theKey);
unsigned long theHashValue = 0L;
@@ -921,9 +1220,9 @@
* @return true if the contents of both strings are identical
*/
#if defined(XALAN_NO_NAMESPACES)
-struct DOMStringEqualsFunction : public binary_function<const DOMString&, const DOMString&, bool>
+struct DOMStringEqualsFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool>
#else
-struct DOMStringEqualsFunction : public std::binary_function<const DOMString&, const DOMString&, bool>
+struct DOMStringEqualsFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool>
#endif
{
result_type
@@ -937,7 +1236,7 @@
/**
- * Convert DOMString to C++ standard library string
+ * Convert XalanDOMString to C++ standard library string
*
* @param theString target string
* @return C++ standard library string representation of target
@@ -947,7 +1246,7 @@
#else
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(std::string)
#endif
-DOMStringToStdString(const DOMString& domString);
+DOMStringToStdString(const XalanDOMString& domString);
@@ -958,7 +1257,7 @@
* @return true if string contains only whitespace
*/
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
-isWhiteSpace(const DOMString& string);
+isWhiteSpace(const XalanDOMString& string);
@@ -972,9 +1271,9 @@
*/
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
isWhiteSpace(
- const XMLCh* ch,
- unsigned int start,
- unsigned int length);
+ const XalanDOMChar* ch,
+ unsigned int start,
+ unsigned int length);
1.3 +23 -31 xml-xalan/c/src/PlatformSupport/DOMStringPrintWriter.cpp
Index: DOMStringPrintWriter.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/DOMStringPrintWriter.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DOMStringPrintWriter.cpp 2000/02/17 20:27:26 1.2
+++ DOMStringPrintWriter.cpp 2000/04/11 14:35:29 1.3
@@ -63,16 +63,11 @@
-#include <util/TextOutputStream.hpp>
-#include <dom/DOMString.hpp>
-
-
-
#include <PlatformSupport/DOMStringHelper.hpp>
-DOMStringPrintWriter::DOMStringPrintWriter(const DOMString& theBaseString) :
+DOMStringPrintWriter::DOMStringPrintWriter(const XalanDOMString& theBaseString) :
PrintWriter(true),
m_outputString(theBaseString)
{
@@ -113,16 +108,16 @@
unsigned int theOffset,
unsigned int theLength)
{
- write(DOMString(s), theOffset, theLength);
+ write(XalanDOMString(s), theOffset, theLength);
}
void
DOMStringPrintWriter::write(
- const XMLCh* s,
- unsigned int theOffset,
- unsigned int theLength)
+ const XalanDOMChar* s,
+ unsigned int theOffset,
+ unsigned int theLength)
{
#if !defined(XALAN_NO_NAMESPACES)
using std::vector;
@@ -130,16 +125,15 @@
#endif
assert(s != 0);
- assert(theOffset >= 0);
- assert(theLength >= 0);
+ assert(theLength == UINT_MAX || length(s) >= theOffset + theLength);
- if (theLength == -1)
+ if (theLength == UINT_MAX)
{
m_outputString += (s + theOffset);
}
else
{
- vector<XMLCh> theBuffer(theLength + 1);
+ vector<XalanDOMChar> theBuffer(theLength + 1);
// We'll copy the characters into the vector first.
copy(s + theOffset,
@@ -157,7 +151,7 @@
void
-DOMStringPrintWriter::write(XMLCh c)
+DOMStringPrintWriter::write(XalanDOMChar c)
{
m_outputString += c;
}
@@ -166,16 +160,14 @@
void
DOMStringPrintWriter::write(
- const DOMString& s,
- unsigned int theOffset,
- unsigned int theLength)
+ const XalanDOMString& s,
+ unsigned int theOffset,
+ unsigned int theLength)
{
assert(s != 0);
- assert(theOffset >= 0);
- assert(theLength >= 0 || theLength == -1);
- assert(length(s) >= theOffset + theLength);
+ assert(theLength == UINT_MAX || length(s) >= theOffset + theLength);
- if (theOffset == 0 && theLength == -1)
+ if (theOffset == 0 && theLength == UINT_MAX)
{
m_outputString += s;
}
@@ -192,11 +184,11 @@
{
if (b == true)
{
- print(DOMString("true"));
+ print(XALAN_STATIC_UCODE_STRING("true"));
}
else
{
- print(DOMString("false"));
+ print(XALAN_STATIC_UCODE_STRING("false"));
}
}
@@ -224,8 +216,8 @@
void
DOMStringPrintWriter::print(
- const XMLCh* s,
- unsigned int theLength)
+ const XalanDOMChar* s,
+ unsigned int theLength)
{
write(s,
0,
@@ -259,7 +251,7 @@
void
-DOMStringPrintWriter::print(const DOMString& s)
+DOMStringPrintWriter::print(const XalanDOMString& s)
{
m_outputString += s;
}
@@ -269,7 +261,7 @@
void
DOMStringPrintWriter::println()
{
- m_outputString += "\n";
+ m_outputString += XALAN_STATIC_UCODE_STRING("\n");
}
@@ -308,8 +300,8 @@
void
DOMStringPrintWriter::println(
- const XMLCh* s,
- unsigned int theLength)
+ const XalanDOMChar* s,
+ unsigned int theLength)
{
print(s, theLength);
@@ -349,7 +341,7 @@
void
-DOMStringPrintWriter::println(const DOMString& s)
+DOMStringPrintWriter::println(const XalanDOMString& s)
{
print(s);
1.5 +17 -17 xml-xalan/c/src/PlatformSupport/DOMStringPrintWriter.hpp
Index: DOMStringPrintWriter.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/DOMStringPrintWriter.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DOMStringPrintWriter.hpp 2000/02/23 20:23:11 1.4
+++ DOMStringPrintWriter.hpp 2000/04/11 14:35:29 1.5
@@ -71,7 +71,7 @@
-#include <dom/DOMString.hpp>
+#include <XalanDOM/XalanDOMString.hpp>
@@ -82,12 +82,12 @@
// If a string is passed in, a copy will be made, and all
// output will be appended to that string.
explicit
- DOMStringPrintWriter(const DOMString& theBaseString = DOMString());
+ DOMStringPrintWriter(const XalanDOMString& theBaseString = XalanDOMString());
virtual
~DOMStringPrintWriter();
- const DOMString&
+ const XalanDOMString&
getString() const
{
return m_outputString;
@@ -115,18 +115,18 @@
// If the length is UINT_MAX, then the array is assumed to be null-terminated.
virtual void
- write(const XMLCh* s,
- unsigned int theOffset = 0,
- unsigned int theLength = UINT_MAX);
+ write(const XalanDOMChar* s,
+ unsigned int theOffset = 0,
+ unsigned int theLength = UINT_MAX);
virtual void
- write(XMLCh c);
+ write(XalanDOMChar c);
// If the length is UINT_MAX, then the entire string is printed.
virtual void
- write(const DOMString& s,
- unsigned int theOffset = 0,
- unsigned int theLength = UINT_MAX);
+ write(const XalanDOMString& s,
+ unsigned int theOffset = 0,
+ unsigned int theLength = UINT_MAX);
virtual void
print(bool b);
@@ -139,8 +139,8 @@
unsigned int theLength = UINT_MAX);
virtual void
- print(const XMLCh* s,
- unsigned int theLength = UINT_MAX);
+ print(const XalanDOMChar* s,
+ unsigned int theLength = UINT_MAX);
virtual void
print(double d);
@@ -152,7 +152,7 @@
print(long l);
virtual void
- print(const DOMString& s);
+ print(const XalanDOMString& s);
virtual void
println();
@@ -168,8 +168,8 @@
unsigned int theLength = UINT_MAX);
virtual void
- println(const XMLCh* s,
- unsigned int theLength = UINT_MAX);
+ println(const XalanDOMChar* s,
+ unsigned int theLength = UINT_MAX);
virtual void
println(double d);
@@ -181,11 +181,11 @@
println(long l);
virtual void
- println(const DOMString& s);
+ println(const XalanDOMString& s);
protected:
- DOMString m_outputString;
+ XalanDOMString m_outputString;
private:
1.2 +29 -13 xml-xalan/c/src/PlatformSupport/DecimalFormat.cpp
Index: DecimalFormat.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/DecimalFormat.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DecimalFormat.cpp 1999/12/18 19:47:49 1.1
+++ DecimalFormat.cpp 2000/04/11 14:35:29 1.2
@@ -58,12 +58,12 @@
#include "DOMStringHelper.hpp"
-const DOMString DecimalFormat::s_defaultPatternString;
+const XalanDOMString DecimalFormat::s_defaultPatternString;
DecimalFormat::DecimalFormat(
- const DOMString& thePatternString,
+ const XalanDOMString& thePatternString,
const DecimalFormatSymbols& theSymbols) :
NumberFormat(),
m_patternString(length(thePatternString) == 0 ? s_defaultPatternString : thePatternString),
@@ -79,7 +79,7 @@
-DOMString
+XalanDOMString
DecimalFormat::format(double theValue)
{
// $$$ ToDo: Fix this!!!
@@ -88,7 +88,7 @@
-DOMString
+XalanDOMString
DecimalFormat::format(int theValue)
{
// $$$ ToDo: Fix this!!!
@@ -97,7 +97,7 @@
-DOMString
+XalanDOMString
DecimalFormat::format(unsigned int theValue)
{
// $$$ ToDo: Fix this!!!
@@ -106,7 +106,7 @@
-DOMString
+XalanDOMString
DecimalFormat::format(long theValue)
{
// $$$ ToDo: Fix this!!!
@@ -115,7 +115,7 @@
-DOMString
+XalanDOMString
DecimalFormat::format(unsigned long theValue)
{
// $$$ ToDo: Fix this!!!
@@ -124,22 +124,38 @@
-DOMString
-DecimalFormat::getNormalizedPattern(const DOMString& thePattern)
+void
+DecimalFormat::applyPattern(const XalanDOMString& thePattern)
{
+ // $$$ ToDo: Fix this!!!
+}
+
+
+
+void
+DecimalFormat::applyLocalizedPattern(const XalanDOMString& thePattern)
+{
+ // $$$ ToDo: Fix this!!!
+}
+
+
+
+XalanDOMString
+DecimalFormat::getNormalizedPattern(const XalanDOMString& thePattern)
+{
// A pattern may not have an explicit specification for
// negative numbers. If there is no pattern separator,
// and therefore no explicit specification for negative
// numbers, then assume that the pattern for negative
// numbers is the same as that for positive numbers.
- const XMLCh thePatternSeparatorChar =
+ const XalanDOMChar thePatternSeparatorChar =
m_decimalFormatSymbols.getPatternSeparator();
// Is the a separator?
- const int theSeparatorIndex =
+ const unsigned int theSeparatorIndex =
indexOf(thePattern, thePatternSeparatorChar);
- if (theSeparatorIndex != -1)
+ if (theSeparatorIndex < length(thePattern))
{
// There is, so the pattern is already normalized.
return thePattern;
@@ -147,7 +163,7 @@
else
{
// There isn't, so
- DOMString theNewPattern(thePattern);
+ XalanDOMString theNewPattern(thePattern);
theNewPattern += thePatternSeparatorChar;
theNewPattern += m_decimalFormatSymbols.getMinusSign();
1.3 +18 -12 xml-xalan/c/src/PlatformSupport/DecimalFormat.hpp
Index: DecimalFormat.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/DecimalFormat.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DecimalFormat.hpp 2000/02/23 20:23:11 1.2
+++ DecimalFormat.hpp 2000/04/11 14:35:29 1.3
@@ -64,7 +64,7 @@
-#include <dom/DOMString.hpp>
+#include <XalanDOM/XalanDOMString.hpp>
@@ -87,26 +87,26 @@
*/
explicit
DecimalFormat(
- const DOMString& thePatternString = DOMString(),
+ const XalanDOMString& thePatternString = XalanDOMString(),
const DecimalFormatSymbols& theSymbols = DecimalFormatSymbols());
virtual
~DecimalFormat();
// From NumberFormat...
- virtual DOMString
+ virtual XalanDOMString
format(double theValue);
- virtual DOMString
+ virtual XalanDOMString
format(int theValue);
- virtual DOMString
+ virtual XalanDOMString
format(unsigned int theValue);
- virtual DOMString
+ virtual XalanDOMString
format(long theValue);
- virtual DOMString
+ virtual XalanDOMString
format(unsigned long theValue);
@@ -136,10 +136,16 @@
m_decimalFormatSymbols = theDecimalFormatSymbols;
}
+ void
+ applyPattern(const XalanDOMString& thePattern);
+
+ void
+ applyLocalizedPattern(const XalanDOMString& thePattern);
+
protected:
- DOMString
- getNormalizedPattern(const DOMString& thePattern);
+ XalanDOMString
+ getNormalizedPattern(const XalanDOMString& thePattern);
private:
@@ -154,11 +160,11 @@
// Data members...
- DOMString m_patternString;
+ XalanDOMString m_patternString;
- DecimalFormatSymbols m_decimalFormatSymbols;
+ DecimalFormatSymbols m_decimalFormatSymbols;
- static const DOMString s_defaultPatternString;
+ static const XalanDOMString s_defaultPatternString;
};
1.6 +4 -4 xml-xalan/c/src/PlatformSupport/DecimalFormatSymbols.cpp
Index: DecimalFormatSymbols.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/DecimalFormatSymbols.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DecimalFormatSymbols.cpp 2000/02/17 20:27:26 1.5
+++ DecimalFormatSymbols.cpp 2000/04/11 14:35:30 1.6
@@ -59,17 +59,17 @@
-static XMLCh theNaNDefault[] = { 0xFFFD, 0 };
-static XMLCh theInfinityDefault[] = { 0x221E, 0 };
+static XalanDOMChar theNaNDefault[] = { 0xFFFD, 0 };
+static XalanDOMChar theInfinityDefault[] = { 0x221E, 0 };
DecimalFormatSymbols::DecimalFormatSymbols() :
- m_currencySymbol("$"),
+ m_currencySymbol(XALAN_STATIC_UCODE_STRING("$")),
m_decimalSeparator('.'),
m_digit(0),
m_groupingSeparator(','),
m_infinity(theInfinityDefault),
- m_internationalCurrencySymbol(""),
+ m_internationalCurrencySymbol(),
m_minusSign('-'),
m_monetaryDecimalSeparator('.'),
m_NaN(theNaNDefault),
1.5 +40 -40 xml-xalan/c/src/PlatformSupport/DecimalFormatSymbols.hpp
Index: DecimalFormatSymbols.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/DecimalFormatSymbols.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DecimalFormatSymbols.hpp 2000/02/23 20:23:11 1.4
+++ DecimalFormatSymbols.hpp 2000/04/11 14:35:30 1.5
@@ -64,7 +64,7 @@
-#include <dom/DOMString.hpp>
+#include <XalanDOM/XalanDOMString.hpp>
@@ -90,7 +90,7 @@
*
* @return string used for local currency
*/
- DOMString
+ const XalanDOMString&
getCurrencySymbol() const
{
return m_currencySymbol;
@@ -101,7 +101,7 @@
*
* @return character used for decimal sign
*/
- XMLCh
+ XalanDOMChar
getDecimalSeparator() const
{
return m_decimalSeparator;
@@ -112,7 +112,7 @@
*
* @return character used for a digit in a pattern
*/
- XMLCh
+ XalanDOMChar
getDigit() const
{
return m_digit;
@@ -123,7 +123,7 @@
*
* @return character used for thousands separator
*/
- XMLCh
+ XalanDOMChar
getGroupingSeparator() const
{
return m_groupingSeparator;
@@ -134,7 +134,7 @@
*
* @return string used to represent infinity
*/
- DOMString
+ const XalanDOMString&
getInfinity() const
{
return m_infinity;
@@ -145,7 +145,7 @@
*
* @return international string denoting the local currency
*/
- DOMString
+ const XalanDOMString&
getInternationalCurrencySymbol() const
{
return m_internationalCurrencySymbol;
@@ -156,7 +156,7 @@
*
* @return character used to represent minus sign
*/
- XMLCh
+ XalanDOMChar
getMinusSign() const
{
return m_minusSign;
@@ -167,7 +167,7 @@
*
* @return character used to separate decimal portion of currency
*/
- XMLCh
+ XalanDOMChar
getMonetaryDecimalSeparator() const
{
return m_monetaryDecimalSeparator;
@@ -179,7 +179,7 @@
*
* @return string representing "not a number" value
*/
- DOMString
+ const XalanDOMString&
getNaN() const
{
return m_NaN;
@@ -191,7 +191,7 @@
*
* @return character used to separate positive and negative subpatterns
*/
- XMLCh
+ XalanDOMChar
getPatternSeparator() const
{
return m_patternSeparator;
@@ -202,7 +202,7 @@
*
* @return character used for percent sign
*/
- XMLCh
+ XalanDOMChar
getPercent() const
{
return m_percent;
@@ -213,7 +213,7 @@
*
* @return character used for per thousand sign
*/
- XMLCh
+ XalanDOMChar
getPerMill() const
{
return m_perMill;
@@ -224,7 +224,7 @@
*
* @return character used for zero
*/
- XMLCh
+ XalanDOMChar
getZeroDigit() const
{
return m_zeroDigit;
@@ -236,7 +236,7 @@
* @param theCurrencySymbol symbol used for local currency
*/
void
- setCurrencySymbol(const DOMString& theCurrencySymbol)
+ setCurrencySymbol(const XalanDOMString& theCurrencySymbol)
{
m_currencySymbol = theCurrencySymbol;
}
@@ -247,7 +247,7 @@
* @param theDecimalSeparator character used for decimal sign
*/
void
- setDecimalSeparator(XMLCh theDecimalSeparator)
+ setDecimalSeparator(XalanDOMChar theDecimalSeparator)
{
m_decimalSeparator = theDecimalSeparator;
}
@@ -258,7 +258,7 @@
* @param theDigit character used for a digit in a pattern
*/
void
- setDigit(XMLCh theDigit)
+ setDigit(XalanDOMChar theDigit)
{
m_digit = theDigit;
}
@@ -269,7 +269,7 @@
* @param theGroupingSeparator character used for thousands separator
*/
void
- setGroupingSeparator(XMLCh theGroupingSeparator)
+ setGroupingSeparator(XalanDOMChar theGroupingSeparator)
{
m_groupingSeparator = theGroupingSeparator;
}
@@ -280,7 +280,7 @@
* @param theInfinity string used to represent infinity
*/
void
- setInfinity(const DOMString& theInfinity)
+ setInfinity(const XalanDOMString& theInfinity)
{
m_infinity = theInfinity;
}
@@ -292,7 +292,7 @@
* local currency
*/
void
- setInternationalCurrencySymbol(const DOMString& theInternationalCurrencySymbol)
+ setInternationalCurrencySymbol(const XalanDOMString& theInternationalCurrencySymbol)
{
m_internationalCurrencySymbol = theInternationalCurrencySymbol;
}
@@ -303,7 +303,7 @@
* @param theMinusSign character used to represent minus sign
*/
void
- setMinusSign(XMLCh theMinusSign)
+ setMinusSign(XalanDOMChar theMinusSign)
{
m_minusSign = theMinusSign;
}
@@ -315,7 +315,7 @@
* portion of currency
*/
void
- setMonetaryDecimalSeparator(XMLCh theMonetaryDecimalSeparator)
+ setMonetaryDecimalSeparator(XalanDOMChar theMonetaryDecimalSeparator)
{
m_monetaryDecimalSeparator = theMonetaryDecimalSeparator;
}
@@ -327,7 +327,7 @@
* @param theNaN string representing "not a number" value
*/
void
- setNaN(const DOMString& theNaN)
+ setNaN(const XalanDOMString& theNaN)
{
m_NaN = theNaN;
}
@@ -340,7 +340,7 @@
* negative subpatterns
*/
void
- setPatternSeparator(XMLCh thePatternSeparator)
+ setPatternSeparator(XalanDOMChar thePatternSeparator)
{
m_patternSeparator = thePatternSeparator;
}
@@ -351,7 +351,7 @@
* @param thePercent character used for percent sign
*/
void
- setPercent(XMLCh thePercent)
+ setPercent(XalanDOMChar thePercent)
{
m_percent = thePercent;
}
@@ -362,7 +362,7 @@
* @param thePerMill character used for per thousand sign
*/
void
- setPerMill(XMLCh thePerMill)
+ setPerMill(XalanDOMChar thePerMill)
{
m_perMill = thePerMill;
}
@@ -373,7 +373,7 @@
* @param theZeroDigit character used for zero
*/
void
- setZeroDigit(XMLCh theZeroDigit)
+ setZeroDigit(XalanDOMChar theZeroDigit)
{
m_zeroDigit = theZeroDigit;
}
@@ -384,24 +384,24 @@
bool
operator==(const DecimalFormatSymbols&);
- DOMString m_currencySymbol;
+ XalanDOMString m_currencySymbol;
- XMLCh m_decimalSeparator;
- XMLCh m_digit;
- XMLCh m_groupingSeparator;
+ XalanDOMChar m_decimalSeparator;
+ XalanDOMChar m_digit;
+ XalanDOMChar m_groupingSeparator;
- DOMString m_infinity;
- DOMString m_internationalCurrencySymbol;
+ XalanDOMString m_infinity;
+ XalanDOMString m_internationalCurrencySymbol;
- XMLCh m_minusSign;
- XMLCh m_monetaryDecimalSeparator;
+ XalanDOMChar m_minusSign;
+ XalanDOMChar m_monetaryDecimalSeparator;
- DOMString m_NaN;
+ XalanDOMString m_NaN;
- XMLCh m_patternSeparator;
- XMLCh m_percent;
- XMLCh m_perMill;
- XMLCh m_zeroDigit;
+ XalanDOMChar m_patternSeparator;
+ XalanDOMChar m_percent;
+ XalanDOMChar m_perMill;
+ XalanDOMChar m_zeroDigit;
};
1.6 +3 -3 xml-xalan/c/src/PlatformSupport/DirectoryEnumerator.hpp
Index: DirectoryEnumerator.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/DirectoryEnumerator.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DirectoryEnumerator.hpp 2000/02/23 20:23:11 1.5
+++ DirectoryEnumerator.hpp 2000/04/11 14:35:30 1.6
@@ -80,7 +80,7 @@
-#include <dom/DOMString.hpp>
+#include <XalanDOM/XalanDOMString.hpp>
@@ -109,7 +109,7 @@
*
* @return file name
*/
- const XMLCh*
+ const XalanDOMChar*
getName() const
{
return name;
@@ -250,7 +250,7 @@
template<class CollectionType,
class FilterPredicateType = FilesOnlyFilterPredicate,
- class StringType = DOMString,
+ class StringType = XalanDOMString,
class StringConversionFunction = c_wstr_functor>
#if defined(XALAN_NO_NAMESPACES)
struct DirectoryEnumeratorFunctor : public unary_function<StringType, CollectionType>
1.3 +15 -11 xml-xalan/c/src/PlatformSupport/ExecutionContext.hpp
Index: ExecutionContext.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/ExecutionContext.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ExecutionContext.hpp 2000/02/23 20:23:11 1.2
+++ ExecutionContext.hpp 2000/04/11 14:35:30 1.3
@@ -64,11 +64,15 @@
-#include <dom/DOM_Node.hpp>
-#include <dom/DOM_Document.hpp>
+// $$$ ToDo: Needed for now, since XalanDOMString is still a typedef...
+#include <XalanDOM/XalanDOMString.hpp>
+class XalanNode;
+
+
+
//
// An abstract class which provides support for execution.
//
@@ -91,9 +95,9 @@
*/
virtual void
error(
- const DOMString& msg,
- const DOM_Node& sourceNode = DOM_Node(),
- const DOM_Node& styleNode = DOM_Node()) const = 0;
+ const XalanDOMString& msg,
+ const XalanNode* sourceNode = 0,
+ const XalanNode* styleNode = 0) const = 0;
/**
* Tell the user of an warning, and probably throw an exception.
@@ -104,9 +108,9 @@
*/
virtual void
warn(
- const DOMString& msg,
- const DOM_Node& sourceNode = DOM_Node(),
- const DOM_Node& styleNode = DOM_Node()) const = 0;
+ const XalanDOMString& msg,
+ const XalanNode* sourceNode = 0,
+ const XalanNode* styleNode = 0) const = 0;
/**
* Output a message.
@@ -117,9 +121,9 @@
*/
virtual void
message(
- const DOMString& msg,
- const DOM_Node& sourceNode = DOM_Node(),
- const DOM_Node& styleNode = DOM_Node()) const = 0;
+ const XalanDOMString& msg,
+ const XalanNode* sourceNode = 0,
+ const XalanNode* styleNode = 0) const = 0;
};
1.7 +31 -31 xml-xalan/c/src/PlatformSupport/NamedNodeMapAttributeList.cpp
Index: NamedNodeMapAttributeList.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/NamedNodeMapAttributeList.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- NamedNodeMapAttributeList.cpp 2000/02/17 20:27:26 1.6
+++ NamedNodeMapAttributeList.cpp 2000/04/11 14:35:30 1.7
@@ -58,9 +58,8 @@
#include "NamedNodeMapAttributeList.hpp"
-#include <dom/DOM_Attr.hpp>
-#include <util/Janitor.hpp>
-#include <util/XMLString.hpp>
+#include <XalanDOM/XalanAttr.hpp>
+#include <XalanDOM/XalanNamedNodeMap.hpp>
@@ -68,7 +67,7 @@
-NamedNodeMapAttributeList::NamedNodeMapAttributeList(DOM_NamedNodeMap& theMap) :
+NamedNodeMapAttributeList::NamedNodeMapAttributeList(const XalanNamedNodeMap& theMap) :
m_nodeMap(theMap),
m_lastIndex(theMap.getLength() - 1),
m_cachedData()
@@ -96,28 +95,32 @@
{
// We have to return a pointer to a something, but the Xerces
// DOM classes return strings by value, so we have to get
- // the value from the node and store the DOMString somewhere
- // safe, so we have a vector of DOMStrings to hold everything.
+ // the value from the node and store the data somewhere
+ // safe, so we have a vector to hold everything.
+ const XalanAttr* const theAttribute =
#if defined(XALAN_OLD_STYLE_CASTS)
- m_cachedData.push_back(((const DOM_Attr&)((DOM_NamedNodeMap&)m_nodeMap).item(m_lastIndex - index)).getName());
+ (const XalanAttr*)m_nodeMap.item(m_lastIndex - index)
#else
- m_cachedData.push_back(static_cast<const DOM_Attr&>(const_cast<DOM_NamedNodeMap&>(m_nodeMap).item(m_lastIndex - index)).getName());
+ static_cast<const XalanAttr*>(m_nodeMap.item(m_lastIndex - index));
#endif
+ assert(theAttribute != 0);
+ m_cachedData.push_back(theAttribute->getName());
+
return c_wstr(m_cachedData.back());
}
// This is out here so we don't have to worry about multithreading issues.
-static const DOMString theType(XALAN_STATIC_UCODE_STRING("CDATA"));
+static const XalanDOMCharVectorType theType(MakeXalanDOMCharVector(XALAN_STATIC_UCODE_STRING("CDATA")));
const XMLCh*
NamedNodeMapAttributeList::getType(const unsigned int /* index */) const
{
- return c_wstr(theType);
+ return &theType.front();
}
@@ -125,16 +128,16 @@
const XMLCh*
NamedNodeMapAttributeList::getValue(const unsigned int index) const
{
- // We have to return a pointer to a something, but the Xerces
- // DOM classes return strings by value, so we have to get
- // the value from the node and store the DOMString somewhere
- // safe, so we have a vector of DOMStrings to hold everything.
+ const XalanAttr* const theAttribute =
#if defined(XALAN_OLD_STYLE_CASTS)
- m_cachedData.push_back(((const DOM_Attr&)((DOM_NamedNodeMap&)m_nodeMap).item(m_lastIndex - index)).getValue());
+ (const XalanAttr*)m_nodeMap.item(m_lastIndex - index)
#else
- m_cachedData.push_back(static_cast<const DOM_Attr&>(const_cast<DOM_NamedNodeMap&>(m_nodeMap).item(m_lastIndex - index)).getValue());
+ static_cast<const XalanAttr*>(m_nodeMap.item(m_lastIndex - index));
#endif
+ assert(theAttribute != 0);
+ m_cachedData.push_back(theAttribute->getValue());
+
return c_wstr(m_cachedData.back());
}
@@ -143,7 +146,7 @@
const XMLCh*
NamedNodeMapAttributeList::getType(const XMLCh* const /* name */) const
{
- return c_wstr(theType);
+ return &theType.front();
}
@@ -153,13 +156,9 @@
{
// We have to return a pointer to a something, but the Xerces
// DOM classes return strings by value, so we have to get
- // the value from the node and store the DOMString somewhere
- // safe, so we have a vector of DOMStrings to hold everything.
-#if defined(XALAN_OLD_STYLE_CASTS)
- const DOM_Node theNode = ((DOM_NamedNodeMap&)m_nodeMap).getNamedItem(name);
-#else
- const DOM_Node theNode = const_cast<DOM_NamedNodeMap&>(m_nodeMap).getNamedItem(name);
-#endif
+ // the value from the node and store the XalanDOMString somewhere
+ // safe, so we have a vector of XalanDOMStrings to hold everything.
+ const XalanNode* theNode = m_nodeMap.getNamedItem(name);
if (theNode == 0)
{
@@ -167,12 +166,15 @@
}
else
{
+ const XalanAttr* const theAttribute =
#if defined(XALAN_OLD_STYLE_CASTS)
- m_cachedData.push_back(((const DOM_Attr&)theNode).getValue());
+ (const XalanAttr*)theNode;
#else
- m_cachedData.push_back(static_cast<const DOM_Attr&>(theNode).getValue());
+ static_cast<const XalanAttr*>(theNode);
#endif
+ m_cachedData.push_back(theAttribute->getValue());
+
return c_wstr(m_cachedData.back());
}
}
@@ -182,10 +184,8 @@
const XMLCh*
NamedNodeMapAttributeList::getValue(const char* const name) const
{
- XMLCh* const theTranscodedName =
- XMLString::transcode(name);
-
- ArrayJanitor<XMLCh> theJanitor(theTranscodedName);
+ const XalanDOMCharVectorType theName =
+ MakeXalanDOMCharVector(name);
- return getValue(theTranscodedName);
+ return getValue(theName.front());
}
1.3 +14 -7 xml-xalan/c/src/PlatformSupport/NamedNodeMapAttributeList.hpp
Index: NamedNodeMapAttributeList.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/NamedNodeMapAttributeList.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- NamedNodeMapAttributeList.hpp 2000/02/17 20:27:26 1.2
+++ NamedNodeMapAttributeList.hpp 2000/04/11 14:35:30 1.3
@@ -68,19 +68,24 @@
-#include <dom/DOM_Node.hpp>
-#include <dom/DOM_NamedNodeMap.hpp>
-#include <dom/DOMString.hpp>
#include <sax/AttributeList.hpp>
+#include <XalanDOM/XalanDOMString.hpp>
+
+
+
+class XalanNamedNodeMap;
+
+
+
class XALAN_PLATFORMSUPPORT_EXPORT NamedNodeMapAttributeList : public AttributeList
{
public:
explicit
- NamedNodeMapAttributeList(DOM_NamedNodeMap& theMap);
+ NamedNodeMapAttributeList(const XalanNamedNodeMap& theMap);
virtual
~NamedNodeMapAttributeList();
@@ -117,14 +122,16 @@
operator==(const NamedNodeMapAttributeList&);
// Data members...
- const DOM_NamedNodeMap m_nodeMap;
+ const XalanNamedNodeMap& m_nodeMap;
const int m_lastIndex;
#if defined(XALAN_NO_NAMESPACES)
- typedef vector<DOMString> CacheType;
+ typedef XalanDOMString CacheEntryType;
+ typedef vector<CacheEntryType> CacheType;
#else
- typedef std::vector<DOMString> CacheType;
+ typedef XalanDOMString CacheEntryType;
+ typedef std::vector<CacheEntryType> CacheType;
#endif
mutable CacheType m_cachedData;
1.3 +14 -14 xml-xalan/c/src/PlatformSupport/NullPrintWriter.cpp
Index: NullPrintWriter.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/NullPrintWriter.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- NullPrintWriter.cpp 2000/02/17 20:27:26 1.2
+++ NullPrintWriter.cpp 2000/04/11 14:35:30 1.3
@@ -106,16 +106,16 @@
void
NullPrintWriter::write(
- const XMLCh* /* s */,
- unsigned int /* theOffset */,
- unsigned int /* theLength */)
+ const XalanDOMChar* /* s */,
+ unsigned int /* theOffset */,
+ unsigned int /* theLength */)
{
}
void
-NullPrintWriter::write(XMLCh /* c */)
+NullPrintWriter::write(XalanDOMChar /* c */)
{
}
@@ -123,9 +123,9 @@
void
NullPrintWriter::write(
- const DOMString& /* s */,
- unsigned int /* theOffset */,
- unsigned int /* theLength */)
+ const XalanDOMString& /* s */,
+ unsigned int /* theOffset */,
+ unsigned int /* theLength */)
{
}
@@ -146,7 +146,7 @@
void
NullPrintWriter::print(
- const char* /* s */,
+ const char* /* s */,
unsigned int /* theLength */)
{
}
@@ -155,8 +155,8 @@
void
NullPrintWriter::print(
- const XMLCh* /* s */,
- unsigned int /* theLength */)
+ const XalanDOMChar* /* s */,
+ unsigned int /* theLength */)
{
}
@@ -184,7 +184,7 @@
void
-NullPrintWriter::print(const DOMString& /* s */)
+NullPrintWriter::print(const XalanDOMString& /* s */)
{
}
@@ -222,8 +222,8 @@
void
NullPrintWriter::println(
- const XMLCh* /* s */,
- unsigned int /* theLength */)
+ const XalanDOMChar* /* s */,
+ unsigned int /* theLength */)
{
}
@@ -251,6 +251,6 @@
void
-NullPrintWriter::println(const DOMString& /* s */)
+NullPrintWriter::println(const XalanDOMString& /* s */)
{
}
1.3 +11 -11 xml-xalan/c/src/PlatformSupport/NullPrintWriter.hpp
Index: NullPrintWriter.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/NullPrintWriter.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- NullPrintWriter.hpp 2000/02/17 20:27:26 1.2
+++ NullPrintWriter.hpp 2000/04/11 14:35:30 1.3
@@ -98,18 +98,18 @@
// If the length is UINT_MAX, then the array is assumed to be null-terminated.
virtual void
- write(const XMLCh* s,
+ write(const XalanDOMChar* s,
unsigned int theOffset = 0,
unsigned int theLength = UINT_MAX);
virtual void
- write(XMLCh c);
+ write(XalanDOMChar c);
// If the length is UINT_MAX, then the entire string is printed.
virtual void
- write(const DOMString& s,
- unsigned int theOffset = 0,
- unsigned int theLength = UINT_MAX);
+ write(const XalanDOMString& s,
+ unsigned int theOffset = 0,
+ unsigned int theLength = UINT_MAX);
virtual void
print(bool b);
@@ -122,8 +122,8 @@
unsigned int theLength = UINT_MAX);
virtual void
- print(const XMLCh* s,
- unsigned int theLength = UINT_MAX);
+ print(const XalanDOMChar* s,
+ unsigned int theLength = UINT_MAX);
virtual void
print(double d);
@@ -135,7 +135,7 @@
print(long l);
virtual void
- print(const DOMString& s);
+ print(const XalanDOMString& s);
virtual void
println();
@@ -151,8 +151,8 @@
unsigned int theLength = UINT_MAX);
virtual void
- println(const XMLCh* s,
- unsigned int theLength = UINT_MAX);
+ println(const XalanDOMChar* s,
+ unsigned int theLength = UINT_MAX);
virtual void
println(double x);
@@ -164,7 +164,7 @@
println(long x);
virtual void
- println(const DOMString& s);
+ println(const XalanDOMString& s);
private:
1.3 +54 -22 xml-xalan/c/src/PlatformSupport/NumberFormat.cpp
Index: NumberFormat.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/NumberFormat.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- NumberFormat.cpp 2000/02/17 20:27:26 1.2
+++ NumberFormat.cpp 2000/04/11 14:35:30 1.3
@@ -61,7 +61,7 @@
NumberFormat::NumberFormat() :
m_isGroupingUsed(false),
- m_groupingSeparator(","),
+ m_groupingSeparator(XALAN_STATIC_UCODE_STRING(",")),
m_groupingSize(3) // Default to US values
{
}
@@ -74,7 +74,7 @@
-DOMString
+XalanDOMString
NumberFormat::format(double theValue)
{
// $$$ ToDo: Fix this!
@@ -83,7 +83,7 @@
-DOMString
+XalanDOMString
NumberFormat::format(int theValue)
{
// $$$ ToDo: Fix this!
@@ -92,7 +92,7 @@
-DOMString
+XalanDOMString
NumberFormat::format(unsigned int theValue)
{
// $$$ ToDo: Fix this!
@@ -101,7 +101,7 @@
-DOMString
+XalanDOMString
NumberFormat::format(long theValue)
{
// $$$ ToDo: Fix this!
@@ -109,62 +109,94 @@
}
-DOMString NumberFormat::applyGrouping(const DOMString& value)
+
+XalanDOMString
+NumberFormat::applyGrouping(const XalanDOMString& value)
/*
* Convert a string value using the currently active values for grouping size
* and separator; returns the converted string
*/
{
- if (!m_isGroupingUsed) return value;
- int len = value.length();
- if (len == 0) return value;
-
- int bufsize = len + len/m_groupingSize + 1;
- XMLCh* buffer = new XMLCh[bufsize];
+ if (!m_isGroupingUsed)
+ {
+ return value;
+ }
+
+ const unsigned int len = length(value);
+
+ if (len == 0)
+ {
+ return value;
+ }
- XMLCh* p = buffer + bufsize -1;
+ const unsigned int bufsize = len + len/m_groupingSize + 1;
+
+ XalanDOMChar* const buffer = new XalanDOMChar[bufsize];
+
+ XalanDOMChar* p = buffer + bufsize - 1;
+
*p-- = 0; // null terminate
- for (int i= 0, ix = len-1; i < len; i++, ix--)
+
+ for (unsigned int i = 0, ix = len - 1; i < len; i++, ix--)
{
- const XMLCh c = charAt(value, ix);
+ const XalanDOMChar c = charAt(value, ix);
+
if (i && !(i% m_groupingSize))
{
// Could be a multiple character separator??
for (int j= m_groupingSeparator.length()-1; j>=0; j--)
*p-- = charAt(m_groupingSeparator, j);
}
+
*p-- = c;
}
- DOMString s(++p);
+
+ XalanDOMString s(++p);
+
delete [] buffer;
+
return s;
}
+
-DOMString
+
+XalanDOMString
NumberFormat::format(unsigned long theValue)
{
// $$$ ToDo: Fix this!
return UnsignedLongToDOMString(theValue);
}
+
-bool NumberFormat::isGroupingUsed() const
+bool
+NumberFormat::isGroupingUsed() const
{
return m_isGroupingUsed;
}
+
-void NumberFormat::setGroupingUsed(bool bUsed)
+
+void
+NumberFormat::setGroupingUsed(bool bUsed)
{
m_isGroupingUsed = bUsed;
}
+
+
-void NumberFormat::setGroupingSize(const DOMString& s)
+void
+NumberFormat::setGroupingSize(const XalanDOMString& s)
{
m_groupingSize = DOMStringToInt(s);
- assert(m_groupingSize >= 0); // Can't be zero
+
+ assert(m_groupingSize > 0); // Can't be zero
}
+
+
-void NumberFormat::setGroupingSeparator(const DOMString& s)
+void
+NumberFormat::setGroupingSeparator(const XalanDOMString& s)
{
m_groupingSeparator = s;
}
1.3 +24 -15 xml-xalan/c/src/PlatformSupport/NumberFormat.hpp
Index: NumberFormat.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/NumberFormat.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- NumberFormat.hpp 2000/03/06 20:23:11 1.2
+++ NumberFormat.hpp 2000/04/11 14:35:30 1.3
@@ -64,7 +64,7 @@
-#include <dom/DOMString.hpp>
+#include <XalanDOM/XalanDOMString.hpp>
@@ -84,7 +84,7 @@
* @param theValue number to format
* @return string representation of number
*/
- virtual DOMString
+ virtual XalanDOMString
format(double theValue);
/**
@@ -93,7 +93,7 @@
* @param theValue number to format
* @return string representation of number
*/
- virtual DOMString
+ virtual XalanDOMString
format(int theValue);
/**
@@ -102,7 +102,7 @@
* @param theValue number to format
* @return string representation of number
*/
- virtual DOMString
+ virtual XalanDOMString
format(unsigned int theValue);
/**
@@ -111,7 +111,7 @@
* @param theValue number to format
* @return string representation of number
*/
- virtual DOMString
+ virtual XalanDOMString
format(long theValue);
/**
@@ -120,7 +120,7 @@
* @param theValue number to format
* @return string representation of number
*/
- virtual DOMString
+ virtual XalanDOMString
format(unsigned long theValue);
/**
@@ -128,21 +128,24 @@
*
* @return true if grouping used
*/
- virtual bool isGroupingUsed() const;
+ virtual bool
+ isGroupingUsed() const;
/**
* Change whether groupings are used for numbers, for example, "234,678"
*
* @param bUsed true to use grouping
*/
- virtual void setGroupingUsed(bool bUsed);
+ virtual void
+ setGroupingUsed(bool bUsed);
/**
* Change the size of groupings, for example, "234,678" uses a size of "3"
*
* @param s string representation of grouping size
*/
- virtual void setGroupingSize(const DOMString& s);
+ virtual void
+ setGroupingSize(const XalanDOMString& s);
/**
* Change the separator string used for groupings, for example, "234,678"
@@ -150,11 +153,16 @@
*
* @param s grouping separator string
*/
- virtual void setGroupingSeparator(const DOMString& s);
+ virtual void
+ setGroupingSeparator(const XalanDOMString& s);
private:
- // Not implemented
+ XalanDOMString
+ applyGrouping(const XalanDOMString& value);
+
+
+ // Not implemented...
NumberFormat(const NumberFormat&);
NumberFormat&
@@ -162,12 +170,13 @@
bool
operator==(const NumberFormat&);
+
+ // Data members...
+ bool m_isGroupingUsed;
- bool m_isGroupingUsed;
- DOMString m_groupingSeparator;
- int m_groupingSize;
+ XalanDOMString m_groupingSeparator;
- DOMString applyGrouping(const DOMString& value);
+ int m_groupingSize;
};
1.7 +13 -17 xml-xalan/c/src/PlatformSupport/PrintWriter.hpp
Index: PrintWriter.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/PrintWriter.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- PrintWriter.hpp 2000/03/21 03:22:43 1.6
+++ PrintWriter.hpp 2000/04/11 14:35:30 1.7
@@ -69,10 +69,6 @@
-#include <util/XercesDefs.hpp>
-
-
-
class XALAN_PLATFORMSUPPORT_EXPORT PrintWriter : public Writer
{
public:
@@ -115,18 +111,18 @@
// If the length is UINT_MAX, then the array is assumed to be null-terminated.
virtual void
- write(const XMLCh* s,
- unsigned int theOffset = 0,
- unsigned int theLength = UINT_MAX) = 0;
+ write(const XalanDOMChar* s,
+ unsigned int theOffset = 0,
+ unsigned int theLength = UINT_MAX) = 0;
virtual void
- write(XMLCh c) = 0;
+ write(XalanDOMChar c) = 0;
// If the length is UINT_MAX, then the entire string is printed.
virtual void
- write(const DOMString& s,
- unsigned int theOffset = 0,
- unsigned int theLength = UINT_MAX) = 0;
+ write(const XalanDOMString& s,
+ unsigned int theOffset = 0,
+ unsigned int theLength = UINT_MAX) = 0;
// Output functions which are new...
@@ -141,8 +137,8 @@
unsigned int theLength = UINT_MAX) = 0;
virtual void
- print(const XMLCh* s,
- unsigned int theLength = UINT_MAX) = 0;
+ print(const XalanDOMChar* s,
+ unsigned int theLength = UINT_MAX) = 0;
virtual void
print(double d) = 0;
@@ -154,7 +150,7 @@
print(long l) = 0;
virtual void
- print(const DOMString& s) = 0;
+ print(const XalanDOMString& s) = 0;
virtual void
println() = 0;
@@ -170,8 +166,8 @@
unsigned int theLength = UINT_MAX) = 0;
virtual void
- println(const XMLCh* s,
- unsigned int theLength = UINT_MAX) = 0;
+ println(const XalanDOMChar* s,
+ unsigned int theLength = UINT_MAX) = 0;
virtual void
println(double x) = 0;
@@ -183,7 +179,7 @@
println(long x) = 0;
virtual void
- println(const DOMString& s) = 0;
+ println(const XalanDOMString& s) = 0;
protected:
1.5 +79 -2 xml-xalan/c/src/PlatformSupport/STLHelper.hpp
Index: STLHelper.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/STLHelper.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- STLHelper.hpp 2000/03/06 20:23:11 1.4
+++ STLHelper.hpp 2000/04/11 14:35:30 1.5
@@ -90,6 +90,45 @@
};
+
+template<class T>
+class array_auto_ptr
+{
+public:
+
+ array_auto_ptr(T* thePointer) :
+ m_pointer(thePointer)
+ {
+ }
+
+ ~array_auto_ptr()
+ {
+ delete [] m_pointer;
+ }
+
+ T*
+ get() const
+ {
+ return m_pointer;
+ }
+
+ T*
+ release()
+ {
+ T* const temp = m_pointer;
+
+ m_pointer = 0;
+
+ return temp;
+ }
+
+private:
+
+ T* m_pointer;
+};
+
+
+
#if ! defined(__GNUC__)
/**
@@ -155,7 +194,6 @@
struct PairIsolatorOutputIterator
{
-// $$$ This doesn't seem to be used anywhere ???
/*
#if defined(XALAN_NO_NAMESPACES)
typedef output_iterator_tag iterator_category;
@@ -166,7 +204,6 @@
typedef typename PairMemberSelectType::value_type value_type;
-// $$$ This doesn't seem to be used anywhere ???
/*
typedef void difference_type;
typedef void pointer;
@@ -261,6 +298,46 @@
delete thePair.second;
}
};
+
+
+
+template<class T>
+MapValueDeleteFunctor<T>
+makeMapValueDeleteFunctor(const T& /* theMap */)
+{
+ return MapValueDeleteFunctor<T>();
+}
+
+
+
+template <class T>
+#if defined(XALAN_NO_NAMESPACES)
+struct MapKeyDeleteFunctor : public unary_function<const T::value_type&, void>
+#else
+struct MapKeyDeleteFunctor : public std::unary_function<const typename T::value_type&, void>
+#endif
+{
+ /**
+ * Delete the value object in a map value pair. The value of the pair must
+ * be of pointer type.
+ *
+ * @param thePair key-value pair
+ */
+ result_type
+ operator()(argument_type thePair)
+ {
+ delete thePair.first;
+ }
+};
+
+
+
+template<class T>
+MapKeyDeleteFunctor<T>
+makeMapKeyDeleteFunctor(const T& /* theMap */)
+{
+ return MapKeyDeleteFunctor<T>();
+}
1.2 +35 -88 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- StringTokenizer.cpp 1999/12/18 19:47:50 1.1
+++ StringTokenizer.cpp 2000/04/11 14:35:30 1.2
@@ -68,112 +68,58 @@
StringTokenizer::StringTokenizer(
- const DOMString& theString,
- const DOMString& theTokens,
- bool fReturnTokens) :
+ const XalanDOMString& theString,
+ const XalanDOMString& theTokens,
+ bool fReturnTokens) :
m_String(theString),
m_Tokens(theTokens),
m_fReturnTokens(fReturnTokens),
m_CurrentIndex(0),
- m_StringLength(theString.length())
+ m_StringLength(length(theString)),
+ m_tokensLength(length(theTokens))
{
}
-StringTokenizer::~StringTokenizer()
+StringTokenizer::StringTokenizer(
+ const XalanDOMChar* theString,
+ const XalanDOMChar* theTokens,
+ bool fReturnTokens) :
+ m_String(theString),
+ m_Tokens(theTokens),
+ m_fReturnTokens(fReturnTokens),
+ m_CurrentIndex(0),
+ m_StringLength(length(theString)),
+ m_tokensLength(length(theTokens))
{
}
-bool
-StringTokenizer::hasMoreTokens() const
+StringTokenizer::~StringTokenizer()
{
- return countTokens() > 0 ? true : false;
}
bool
-FindCharInTokens(XMLCh theChar,
- const DOMString& theTokens)
+StringTokenizer::hasMoreTokens() const
{
- bool fFound = false;
-
- const int theLength = theTokens.length();
-
- for(int i = 0; i < theLength; i++)
- {
- if (charAt(theTokens, i) == theChar)
- {
- fFound = true;
- break;
- }
- }
-
- return fFound;
+ return countTokens() > 0 ? true : false;
}
-#if 0
-DOMString
-StringTokenizer::nextToken()
-{
- assert(m_CurrentIndex < m_StringLength);
-
- DOMString theToken;
-
- // Find the index of the next delimiter.
- int theIndex = FindNextDelimiterIndex(m_CurrentIndex);
-
- if (theIndex == m_CurrentIndex &&
- 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.
- theToken = substring(m_String,
- theIndex,
- theIndex + 1);
-
- m_CurrentIndex = theIndex + 1;
- }
- else
- {
- if (theIndex == m_CurrentIndex)
- {
- theIndex = FindNextDelimiterIndex(m_CurrentIndex + 1);
- }
- assert(theIndex > m_CurrentIndex);
-
- theToken = substring(m_String,
- m_CurrentIndex,
- theIndex);
-
- if (m_fReturnTokens == true)
- {
- m_CurrentIndex = theIndex;
- }
- else
- {
- m_CurrentIndex = theIndex + 1;
- }
- }
-
- return theToken;
-}
-#else
-DOMString
+XalanDOMString
StringTokenizer::nextToken()
{
assert(m_CurrentIndex < m_StringLength);
- DOMString theToken;
+ XalanDOMString theToken;
// Find the index of the next delimiter.
- int theIndex = FindNextDelimiterIndex(m_CurrentIndex);
+ unsigned int theIndex = FindNextDelimiterIndex(m_CurrentIndex);
if (theIndex == m_CurrentIndex)
{
@@ -210,20 +156,20 @@
return theToken;
}
-#endif
+
-int
+unsigned int
StringTokenizer::countTokens() const
{
- int theCount = 0;
- int theCurrentIndex = m_CurrentIndex;
+ unsigned int theCount = 0;
+ unsigned int theCurrentIndex = m_CurrentIndex;
if (theCurrentIndex < m_StringLength)
{
while(theCurrentIndex < m_StringLength)
{
- const int theNextIndex = FindNextDelimiterIndex(theCurrentIndex);
+ const unsigned int theNextIndex = FindNextDelimiterIndex(theCurrentIndex);
if (theNextIndex == theCurrentIndex)
{
@@ -248,20 +194,21 @@
-int
-StringTokenizer::FindNextDelimiterIndex(int theStartIndex) const
+unsigned int
+StringTokenizer::FindNextDelimiterIndex(unsigned int theStartIndex) const
{
- bool fTokenFound = false;
- int theIndex = theStartIndex;
+ bool fTokenFound = false;
+ unsigned int theIndex = theStartIndex;
while(theIndex < m_StringLength &&
fTokenFound == false)
{
- const XMLCh theCurrentChar = charAt(m_String,
- theIndex);
+ const XalanDOMChar theCurrentChar =
+ charAt(m_String,
+ theIndex);
- if (FindCharInTokens(theCurrentChar,
- m_Tokens) == true)
+ if (indexOf(m_Tokens,
+ theCurrentChar) < m_tokensLength)
{
fTokenFound = true;
}
1.4 +35 -13 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- StringTokenizer.hpp 2000/02/29 20:54:19 1.3
+++ StringTokenizer.hpp 2000/04/11 14:35:31 1.4
@@ -64,10 +64,14 @@
-#include <dom/DOMString.hpp>
+#include <XalanDOM/XalanDOMString.hpp>
+#include <PlatformSupport/DOMStringHelper.hpp>
+
+
+
class XALAN_PLATFORMSUPPORT_EXPORT StringTokenizer
{
public:
@@ -80,10 +84,24 @@
* is "\t\n\r\f"
* @param fReturnTokens if true, delimiter characters are also returned
* as tokens, default is false
+ */
+ StringTokenizer(const XalanDOMString& theString,
+ const XalanDOMString& theTokens = XalanDOMString(XALAN_STATIC_UCODE_STRING("\t\n\r\f")),
+ bool fReturnTokens = false);
+
+ /**
+ * Constructs a tokenizer for the target string. This version constructs
+ * from null-terminated wide strings, like those we get from SAX-like APIs.
+ *
+ * @param theString string to tokenize
+ * @param theTokens string of delimiters used to parse target, default
+ * is "\t\n\r\f"
+ * @param fReturnTokens if true, delimiter characters are also returned
+ * as tokens, default is false
*/
- StringTokenizer(const DOMString& theString,
- const DOMString& theTokens = DOMString("\t\n\r\f"),
- bool fReturnTokens = false);
+ StringTokenizer(const XalanDOMChar* theString,
+ const XalanDOMChar* theTokens = XALAN_STATIC_UCODE_STRING("\t\n\r\f"),
+ bool fReturnTokens = false);
virtual
~StringTokenizer();
@@ -102,7 +120,7 @@
*
* @return next token string
*/
- virtual DOMString
+ virtual XalanDOMString
nextToken();
/**
@@ -110,23 +128,27 @@
*
* @return number of remaining tokens
*/
- virtual int
+ virtual unsigned int
countTokens() const;
protected:
- int
- FindNextDelimiterIndex(int theStartIndex) const;
+ unsigned int
+ FindNextDelimiterIndex(unsigned int theStartIndex) const;
private:
+
+ const XalanDOMString m_String;
+
+ const XalanDOMString m_Tokens;
+
+ const bool m_fReturnTokens;
- const DOMString m_String;
- const DOMString m_Tokens;
+ unsigned int m_CurrentIndex;
- const bool m_fReturnTokens;
+ const unsigned int m_StringLength;
- int m_CurrentIndex;
- const int m_StringLength;
+ const unsigned int m_tokensLength;
};
1.8 +9 -12 xml-xalan/c/src/PlatformSupport/Writer.hpp
Index: Writer.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/Writer.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Writer.hpp 2000/03/21 03:22:43 1.7
+++ Writer.hpp 2000/04/11 14:35:31 1.8
@@ -68,14 +68,11 @@
-#include <util/XercesDefs.hpp>
+// $$$ ToDo: Necessary will XalanDOMString is still a typedef.
+#include <XalanDOM/XalanDOMString.hpp>
-class DOMString;
-
-
-
class XALAN_PLATFORMSUPPORT_EXPORT Writer
{
public:
@@ -124,9 +121,9 @@
* null-terminated. Default is UINT_MAX.
*/
virtual void
- write(const XMLCh* s,
- unsigned int theOffset = 0,
- unsigned int theLength = UINT_MAX) = 0;
+ write(const XalanDOMChar* s,
+ unsigned int theOffset = 0,
+ unsigned int theLength = UINT_MAX) = 0;
/**
* Writes a character
@@ -134,7 +131,7 @@
* @param c character to write
*/
virtual void
- write(XMLCh c) = 0;
+ write(XalanDOMChar c) = 0;
/**
* Writes a string
@@ -146,9 +143,9 @@
* is UINT_MAX.
*/
virtual void
- write(const DOMString& s,
- unsigned int theOffset = 0,
- unsigned int theLength = UINT_MAX) = 0;
+ write(const XalanDOMString& s,
+ unsigned int theOffset = 0,
+ unsigned int theLength = UINT_MAX) = 0;
private:
1.2 +4 -5 xml-xalan/c/src/PlatformSupport/XSLException.cpp
Index: XSLException.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/XSLException.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XSLException.cpp 1999/12/18 19:47:50 1.1
+++ XSLException.cpp 2000/04/11 14:35:31 1.2
@@ -63,8 +63,10 @@
XSLException::XSLException(
- const DOMString& theMessage,
- const DOMString& theType) : m_message(theMessage), m_type(theType)
+ const XalanDOMString& theMessage,
+ const XalanDOMString& theType) :
+ m_message(theMessage),
+ m_type(theType)
{
}
@@ -73,6 +75,3 @@
XSLException::~XSLException()
{
}
-
-
-
1.4 +9 -8 xml-xalan/c/src/PlatformSupport/XSLException.hpp
Index: XSLException.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/XSLException.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XSLException.hpp 2000/02/23 20:23:11 1.3
+++ XSLException.hpp 2000/04/11 14:35:31 1.4
@@ -64,8 +64,7 @@
-#include <dom/DOMString.hpp>
-#include <util/XMLException.hpp>
+#include <PlatformSupport/DOMStringHelper.hpp>
@@ -80,8 +79,8 @@
* @param theType type of exception, default is "XSLException"
*/
XSLException(
- const DOMString& theMessage,
- const DOMString& theType = DOMString("XSLException"));
+ const XalanDOMString& theMessage,
+ const XalanDOMString& theType = XalanDOMString(XALAN_STATIC_UCODE_STRING("XSLException")));
virtual
~XSLException();
@@ -91,7 +90,8 @@
*
* @return type of exception
*/
- DOMString getType() const
+ const XalanDOMString&
+ getType() const
{
return m_type;
}
@@ -101,15 +101,16 @@
*
* @return exception message
*/
- DOMString getMessage() const
+ const XalanDOMString&
+ getMessage() const
{
return m_message;
}
private:
- DOMString m_type;
- DOMString m_message;
+ const XalanDOMString m_type;
+ const XalanDOMString m_message;
};