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...@apache.org on 2001/01/08 19:19:55 UTC

cvs commit: xml-xalan/c/src/XalanDOM XalanDOMString.cpp XalanDOMString.hpp

dbertoni    01/01/08 10:19:55

  Modified:    c/src/XalanDOM XalanDOMString.cpp XalanDOMString.hpp
  Log:
  Removed support for Xerces' DOMString.  Cleaned up some functions.
  
  Revision  Changes    Path
  1.5       +41 -14    xml-xalan/c/src/XalanDOM/XalanDOMString.cpp
  
  Index: XalanDOMString.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XalanDOM/XalanDOMString.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XalanDOMString.cpp	2000/11/27 21:46:26	1.4
  +++ XalanDOMString.cpp	2001/01/08 18:19:55	1.5
  @@ -67,15 +67,7 @@
   
   
   
  -#if defined(XALAN_USE_XERCES_DOMSTRING)
  -
  -static const char foo;
  -
  -#elif defined(XALAN_USE_STD_STRING)
  -
  -
  -
  -#elif defined(XALAN_USE_CUSTOM_STRING)
  +#if defined(XALAN_USE_CUSTOM_STRING)
   
   
   
  @@ -83,10 +75,6 @@
   
   
   
  -#include <dom/DOMString.hpp>
  -
  -
  -
   const XalanDOMChar	XalanDOMString::s_empty = 0;
   
   
  @@ -406,6 +394,45 @@
   
   
   
  +bool
  +XalanDOMString::equals(
  +			const XalanDOMChar*		theLHS,
  +			unsigned int			theLHSLength,
  +			const XalanDOMChar*		theRHS,
  +			unsigned int			theRHSLength)
  +{
  +	if (theLHSLength != theRHSLength)
  +	{
  +		return false;
  +	}
  +	else if (theLHSLength == 0)
  +	{
  +		return true;
  +	}
  +	else
  +	{
  +		const XalanDOMChar* const	theEnd = theLHS + theLHSLength;
  +
  +		while(*theLHS == *theRHS)
  +		{
  +			++theLHS;
  +
  +			if (theLHS == theEnd)
  +			{
  +				return true;
  +			}
  +			else
  +			{
  +				++theRHS;
  +			}
  +		}
  +
  +		return false;
  +	}
  +}
  +
  +
  +
   XalanDOMString::size_type
   XalanDOMString::length(const XalanDOMChar*	theString)
   {
  @@ -636,7 +663,7 @@
   
   
   
  -#if defined(XALAN_USE_XERCES_DOMSTRING) || defined(XALAN_USE_STD_STRING)
  +#if defined(XALAN_USE_STD_STRING)
   XALAN_DOM_EXPORT_FUNCTION(const XalanDOMString)
   TranscodeFromLocalCodePage(
   			const char*		theSourceString,
  
  
  
  1.8       +57 -27    xml-xalan/c/src/XalanDOM/XalanDOMString.hpp
  
  Index: XalanDOMString.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XalanDOM/XalanDOMString.hpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- XalanDOMString.hpp	2000/12/01 22:01:04	1.7
  +++ XalanDOMString.hpp	2001/01/08 18:19:55	1.8
  @@ -67,26 +67,19 @@
   
   
   
  -#if defined(XALAN_USE_XERCES_DOMSTRING)
  +// UTF-16 character...
  +typedef unsigned short	XalanDOMChar;
   
  -#include <dom/DOMString.hpp>
   
  -typedef XMLCh		XalanDOMChar;
  -typedef DOMString	XalanDOMString;
   
  -#elif defined(XALAN_USE_STD_STRING)
  +#if defined(XALAN_USE_STD_STRING)
   
   #include <string>
   
  -#include <util/XercesDefs.hpp>
  -
  -typedef XMLCh								XalanDOMChar;
   typedef std::basic_string<XalanDOMChar>		XalanDOMString;
   
   #else
   
  -
  -
   #define XALAN_USE_CUSTOM_STRING
   
   
  @@ -95,14 +88,6 @@
   
   
   
  -#include <util/XercesDefs.hpp>
  -
  -
  -
  -typedef XMLCh	XalanDOMChar;
  -
  -
  -
   class XALAN_DOM_EXPORT XalanDOMString
   {
   public:
  @@ -568,8 +553,55 @@
   	CharVectorType
   	transcode() const;
   
  -protected:
  +	static bool
  +	equals(
  +			const XalanDOMChar*		theLHS,
  +			unsigned int			theLHSLength,
  +			const XalanDOMChar*		theRHS,
  +			unsigned int			theRHSLength);
  +
  +	static bool
  +	equals(
  +			const XalanDOMChar*		theLHS,
  +			const XalanDOMChar*		theRHS)
  +	{
  +		return equals(theLHS, length(theLHS), theRHS, length(theRHS));
  +	}
  +
  +	static bool
  +	equals(
  +			const XalanDOMString&	theLHS,
  +			const XalanDOMString&	theRHS)
  +	{
  +		const unsigned int	theLHSLength = theLHS.size();
  +		const unsigned int	theRHSLength = theRHS.size();
   
  +		if (theLHSLength != theRHSLength)
  +		{
  +			return false;
  +		}
  +		else
  +		{
  +			return equals(theLHS.c_str(), theLHSLength, theRHS.c_str(), theRHSLength);
  +		}
  +	}
  +
  +	static bool
  +	equals(
  +			const XalanDOMString&	theLHS,
  +			const XalanDOMChar*		theRHS)
  +	{
  +		return equals(theLHS.c_str(), theRHS);
  +	}
  +
  +	static bool
  +	equals(
  +			const XalanDOMChar*		theLHS,
  +			const XalanDOMString&	theRHS)
  +	{
  +		return equals(theLHS, theRHS.c_str());
  +	}
  +
   	/*
   	 * Helper function to determine the length of a null-
   	 * terminated string.
  @@ -580,6 +612,8 @@
   	static size_type
   	length(const XalanDOMChar*	theString);
   
  +protected:
  +
   	/*
   	 * Get an iterator to the position of the terminating null.
   	 *
  @@ -623,7 +657,7 @@
   			const XalanDOMString&	theLHS,
   			const XalanDOMString&	theRHS)
   {
  -	return theLHS.compare(theRHS) == 0 ? true : false;
  +	return XalanDOMString::equals(theLHS, theRHS);
   }
   
   
  @@ -633,7 +667,7 @@
   			const XalanDOMString&	theLHS,
   			const XalanDOMChar*		theRHS)
   {
  -	return theLHS.compare(theRHS) == 0 ? true : false;
  +	return XalanDOMString::equals(theLHS, theRHS);
   }
   
   
  @@ -644,7 +678,7 @@
   			const XalanDOMString&	theRHS)
   {
   	// Note reversing of operands...
  -	return theRHS.compare(theLHS) == 0 ? true : false;
  +	return XalanDOMString::equals(theLHS, theRHS);
   }
   
   
  @@ -824,11 +858,7 @@
   			CharVectorType&			targetVector,
   			bool					terminate = false)
   {
  -#if defined(XALAN_USE_CUSTOM_STRING) || defined(XALAN_USE_STD_STRING)
   	return TranscodeToLocalCodePage(theSourceString.c_str(), targetVector, terminate);
  -#else
  -	return TranscodeToLocalCodePage(theSourceString.rawBuffer(), theSourceString.length(), targetVector, terminate);
  -#endif
   }
   
   
  @@ -861,7 +891,7 @@
    * @param theSourceStringLength The source string length.
    * @return The new string.
    */
  -#if defined(XALAN_USE_XERCES_DOMSTRING) || defined(XALAN_USE_STD_STRING)
  +#if defined(XALAN_USE_STD_STRING)
   XALAN_DOM_EXPORT_FUNCTION(const XalanDOMString)
   TranscodeFromLocalCodePage(
   			const char*		theSourceString,