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/02/08 22:39:37 UTC
cvs commit: xml-xalan/c/src/PlatformSupport DOMStringHelper.cpp DOMStringHelper.hpp NamedNodeMapAttributeList.cpp NamedNodeMapAttributeList.hpp PlatformSupportInit.cpp PrintWriter.cpp PrintWriter.hpp URISupport.cpp URISupport.hpp XalanNumberFormat.cpp XalanNumberFormat.hpp XalanOutputStream.cpp XalanTranscodingServices.cpp XalanTranscodingServices.hpp XalanUnicode.hpp
dbertoni 01/02/08 13:39:36
Modified: c/src/PlatformSupport DOMStringHelper.cpp
DOMStringHelper.hpp NamedNodeMapAttributeList.cpp
NamedNodeMapAttributeList.hpp
PlatformSupportInit.cpp PrintWriter.cpp
PrintWriter.hpp URISupport.cpp URISupport.hpp
XalanNumberFormat.cpp XalanNumberFormat.hpp
XalanOutputStream.cpp XalanTranscodingServices.cpp
XalanTranscodingServices.hpp XalanUnicode.hpp
Log:
Cleaned up some strings. Changed some DOMStringHelper functions to do the right thing.
Revision Changes Path
1.51 +5 -65 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.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- DOMStringHelper.cpp 2001/01/16 02:42:13 1.50
+++ DOMStringHelper.cpp 2001/02/08 21:38:54 1.51
@@ -185,11 +185,11 @@
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void)
DOMStringHelperTerminate()
{
- clear(theNaNString);
- clear(theNegativeInfinityString);
- clear(thePositiveInfinityString);
- clear(theNegativeZeroString);
- clear(thePositiveZeroString);
+ releaseMemory(theNaNString);
+ releaseMemory(theNegativeInfinityString);
+ releaseMemory(thePositiveInfinityString);
+ releaseMemory(theNegativeZeroString);
+ releaseMemory(thePositiveZeroString);
}
@@ -597,44 +597,7 @@
{
assert(theStartIndex + theLength <= theStringLength);
-#if defined(XALAN_USE_CUSTOM_STRING) || defined(XALAN_USE_STD_STRING)
return theString.substr(theStartIndex, theLength);
-#else
- // @@ 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 XalanDOMChar* const ptr = toCharArray(theString);
-
- vector<XalanDOMChar> theBuffer;
-
- // Reserve the buffer now. We don't have to null-terminate,
- // because the XalanDOMString constructor will take a size
- // parameter.
- theBuffer.reserve(theLength);
-
-#if defined(XALAN_NO_ALGORITHMS_WITH_BUILTINS)
- XalanCopy(
- ptr,
- ptr + theLength,
- back_inserter(theBuffer));
-#else
- copy(
- ptr,
- ptr + theLength,
- back_inserter(theBuffer));
-#endif
-
- return XalanDOMString(&*theBuffer.begin(), theBuffer.size());
- }
- else
- {
- return theString.substringData(theStartIndex, theLength);
- }
-#endif // defined(XALAN_USE_CUSTOM_STRING) || defined(XALAN_USE_STD_STRING)
}
}
}
@@ -675,17 +638,6 @@
{
assert(theInputString != 0);
-#if defined(XALAN_USE_STD_STRING) && defined(XALAN_OLD_STD_STRING)
- vector<XalanDOMChar> theConvertedString;
-
- TransformString(
- theInputString,
- theInputString + theInputStringLength,
- back_inserter(theConvertedString),
- theFunction);
-
- return XalanDOMString(&*theConvertedString.begin(), theConvertedString.size());
-#else
XalanDOMString theConvertedString;
TransformString(
@@ -695,7 +647,6 @@
theFunction);
return theConvertedString;
-#endif
}
@@ -1574,23 +1525,12 @@
++theCharsWritten;
}
-#if defined(XALAN_USE_STD_STRING) && defined(XALAN_OLD_STD_STRING)
- XalanDOMChar theTemp[sizeof(theBuffer)];
-
- TranscodeNumber(
- theBuffer,
- theBuffer + theCharsWritten,
- theTemp);
-
- theResult = XalanDOMString(theTemp, theCharsWritten);
-#else
reserve(theResult, theCharsWritten + 1);
TranscodeNumber(
theBuffer,
theBuffer + theCharsWritten,
back_inserter(theResult));
-#endif
}
return theResult;
1.42 +56 -66 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.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- DOMStringHelper.hpp 2001/01/08 18:15:31 1.41
+++ DOMStringHelper.hpp 2001/02/08 21:38:57 1.42
@@ -546,11 +546,7 @@
{
return startsWith(
theString,
-#if defined(XALAN_USE_STD_STRING)
- TranscodeFromLocalCodePage(theSubstring));
-#else
XalanDOMString(theSubstring));
-#endif
}
@@ -1821,14 +1817,7 @@
const XalanDOMString& theLHS,
const XalanDOMString& theRHS)
{
-#if defined(XALAN_USE_STD_STRING)
- const unsigned int theLHSLength = length(theLHS);
-
- return theLHSLength != length(theRHS) ? false :
- equals(toCharArray(theLHS), toCharArray(theRHS), theLHSLength);
-#else
return theLHS == theRHS;
-#endif
}
@@ -1847,12 +1836,8 @@
{
assert(theLHS != 0);
-#if defined(XALAN_USE_STD_STRING)
- return equals(theLHS, c_wstr(theRHS));
-#else
// Swap them...
return theRHS == theLHS;
-#endif
}
@@ -1894,11 +1879,7 @@
}
else
{
-#if defined(XALAN_USE_STD_STRING)
- return theLHS == TranscodeFromLocalCodePage(theRHS);
-#else
return theLHS == XalanDOMString(theRHS, theRHSLength);
-#endif
}
}
@@ -1942,11 +1923,7 @@
}
else
{
-#if defined(XALAN_USE_STD_STRING)
- return equals(TranscodeFromLocalCodePage(theRHS), theLHS);
-#else
return equals(XalanDOMString(theRHS, theRHSLength), theLHS);
-#endif
}
}
@@ -2195,49 +2172,6 @@
-#if defined(XALAN_USE_STD_STRING)
-
-inline const XalanDOMString
-operator+(
- const char* theLHS,
- const XalanDOMString& theRHS)
-{
- return TranscodeFromLocalCodePage(theLHS) + theRHS;
-}
-
-
-
-inline const XalanDOMString
-operator+(
- const XalanDOMString& theLHS,
- const char* theRHS)
-{
- return theLHS + TranscodeFromLocalCodePage(theRHS);
-}
-
-
-
-inline const XalanDOMString
-operator+(
- const XalanDOMChar* theLHS,
- const XalanDOMString& theRHS)
-{
- return XalanDOMString(theLHS) + theRHS;
-}
-
-
-
-inline const XalanDOMString
-operator+(
- const XalanDOMString& theLHS,
- const XalanDOMChar* theRHS)
-{
- return theLHS + XalanDOMString(theRHS);
-}
-#endif
-
-
-
/**
* Assign one string to another
*
@@ -2395,6 +2329,14 @@
+/**
+ * Insert a string into another string.
+ *
+ * @param theString target string
+ * @param thePosition The position in the target string to insert
+ * @param theStringToInsert The string to insert
+ * @return A reference to the target string
+ */
inline XalanDOMString&
insert(
XalanDOMString& theString,
@@ -2409,6 +2351,27 @@
/**
+ * Insert a string into another string.
+ *
+ * @param theString target string
+ * @param thePosition The position in the target string to insert
+ * @param theStringToInsert The string to insert
+ * @return A reference to the target string
+ */
+inline XalanDOMString&
+insert(
+ XalanDOMString& theString,
+ unsigned int thePosition,
+ const XalanDOMChar* theStringToInsert)
+{
+ theString.insert(thePosition, theStringToInsert);
+
+ return theString;
+}
+
+
+
+/**
* Remove trailing whitespace
*
* @param theString target string
@@ -2427,7 +2390,34 @@
inline void
clear(XalanDOMString& theString)
{
+ theString.clear();
+}
+
+
+
+/**
+ * Remove all elements from target string
+ *
+ * @param theString target string
+ */
+inline void
+erase(XalanDOMString& theString)
+{
theString.erase();
+}
+
+
+
+/**
+ * Remove all elements from target string
+ * and frees all allocated memory.
+ *
+ * @param theString target string
+ */
+inline void
+releaseMemory(XalanDOMString& theString)
+{
+ XalanDOMString().swap(theString);
}
1.13 +14 -25 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.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- NamedNodeMapAttributeList.cpp 2001/01/23 23:18:39 1.12
+++ NamedNodeMapAttributeList.cpp 2001/02/08 21:38:59 1.13
@@ -64,9 +64,22 @@
#include "DOMStringHelper.hpp"
+#include "XalanUnicode.hpp"
+const XalanDOMChar NamedNodeMapAttributeList::s_typeString[] =
+{
+ XalanUnicode::charLetter_C,
+ XalanUnicode::charLetter_D,
+ XalanUnicode::charLetter_A,
+ XalanUnicode::charLetter_T,
+ XalanUnicode::charLetter_A,
+ 0
+};
+
+
+
NamedNodeMapAttributeList::NamedNodeMapAttributeList(const XalanNamedNodeMap& theMap) :
m_nodeMap(theMap),
m_lastIndex(theMap.getLength() - 1)
@@ -114,7 +127,7 @@
{
assert(length(s_typeString) > 0);
- return c_wstr(s_typeString);
+ return s_typeString;
}
@@ -177,28 +190,4 @@
NamedNodeMapAttributeList::getValue(const char* const name) const
{
return getValue(c_wstr(TranscodeFromLocalCodePage(name)));
-}
-
-
-
-static XalanDOMString s_typeString;
-
-
-
-const XalanDOMString& NamedNodeMapAttributeList::s_typeString = ::s_typeString;
-
-
-
-void
-NamedNodeMapAttributeList::initialize()
-{
- ::s_typeString = XALAN_STATIC_UCODE_STRING("CDATA");
-}
-
-
-
-void
-NamedNodeMapAttributeList::terminate()
-{
- clear(::s_typeString);
}
1.7 +11 -26 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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- NamedNodeMapAttributeList.hpp 2001/01/23 23:18:42 1.6
+++ NamedNodeMapAttributeList.hpp 2001/02/08 21:39:01 1.7
@@ -84,21 +84,6 @@
{
public:
- /**
- * Initialize static data. Must be called before any
- * other functions are called. See PlatformSupportInit.
- */
- static void
- initialize();
-
- /**
- * Destroy static data. After thus function is called,
- * no other functions can be called. See PlatformSupportInit.
- */
- static void
- terminate();
-
-
explicit
NamedNodeMapAttributeList(const XalanNamedNodeMap& theMap);
@@ -109,22 +94,22 @@
virtual unsigned int
getLength() const;
- virtual const XMLCh*
+ virtual const XalanDOMChar*
getName(const unsigned int index) const;
- virtual const XMLCh*
+ virtual const XalanDOMChar*
getType(const unsigned int index) const;
- virtual const XMLCh*
+ virtual const XalanDOMChar*
getValue(const unsigned int index) const;
- virtual const XMLCh*
- getType(const XMLCh* const name) const;
+ virtual const XalanDOMChar*
+ getType(const XalanDOMChar* const name) const;
- virtual const XMLCh*
- getValue(const XMLCh* const name) const;
+ virtual const XalanDOMChar*
+ getValue(const XalanDOMChar* const name) const;
- virtual const XMLCh*
+ virtual const XalanDOMChar*
getValue(const char* const name) const;
private:
@@ -137,11 +122,11 @@
operator==(const NamedNodeMapAttributeList&);
// Data members...
- const XalanNamedNodeMap& m_nodeMap;
+ const XalanNamedNodeMap& m_nodeMap;
- const unsigned int m_lastIndex;
+ const unsigned int m_lastIndex;
- static const XalanDOMString& s_typeString;
+ static const XalanDOMChar s_typeString[];
};
1.4 +0 -20 xml-xalan/c/src/PlatformSupport/PlatformSupportInit.cpp
Index: PlatformSupportInit.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/PlatformSupportInit.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PlatformSupportInit.cpp 2000/09/27 16:24:01 1.3
+++ PlatformSupportInit.cpp 2001/02/08 21:39:02 1.4
@@ -60,10 +60,6 @@
#include "DOMStringHelper.hpp"
-#include "NamedNodeMapAttributeList.hpp"
-#include "PrintWriter.hpp"
-#include "URISupport.hpp"
-#include "XalanNumberFormat.hpp"
#include "XalanTranscodingServices.hpp"
@@ -103,14 +99,6 @@
DOMStringHelperInitialize();
XalanTranscodingServices::initialize();
-
- PrintWriter::initialize();
-
- NamedNodeMapAttributeList::initialize();
-
- XalanNumberFormat::initialize();
-
- URISupport::initialize();
}
@@ -118,14 +106,6 @@
void
PlatformSupportInit::terminate()
{
- URISupport::terminate();
-
- XalanNumberFormat::terminate();
-
- NamedNodeMapAttributeList::terminate();
-
- PrintWriter::terminate();
-
XalanTranscodingServices::terminate();
DOMStringHelperTerminate();
1.3 +25 -35 xml-xalan/c/src/PlatformSupport/PrintWriter.cpp
Index: PrintWriter.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/PrintWriter.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PrintWriter.cpp 2000/09/05 02:24:45 1.2
+++ PrintWriter.cpp 2001/02/08 21:39:03 1.3
@@ -60,57 +60,47 @@
#include "DOMStringHelper.hpp"
+#include "XalanUnicode.hpp"
-PrintWriter::PrintWriter(bool fAutoFlush) :
- Writer(),
- m_fAutoFlush(fAutoFlush)
+const XalanDOMChar PrintWriter::s_trueString[] =
{
-}
-
+ XalanUnicode::charLetter_t,
+ XalanUnicode::charLetter_r,
+ XalanUnicode::charLetter_u,
+ XalanUnicode::charLetter_e,
+ 0
+};
-PrintWriter::~PrintWriter()
+const XalanDOMChar PrintWriter::s_falseString[] =
{
-}
-
-
-
-static XalanDOMString s_trueString;
-
-static XalanDOMString s_falseString;
-
-static XalanDOMString s_newlineString;
+ XalanUnicode::charLetter_f,
+ XalanUnicode::charLetter_a,
+ XalanUnicode::charLetter_l,
+ XalanUnicode::charLetter_s,
+ XalanUnicode::charLetter_e,
+ 0
+};
-const XalanDOMString& PrintWriter::s_trueString = ::s_trueString;
-
-const XalanDOMString& PrintWriter::s_falseString = ::s_falseString;
-
-const XalanDOMString& PrintWriter::s_newlineString = ::s_newlineString;
+const XalanDOMChar PrintWriter::s_newlineString[] =
+{
+ XalanUnicode::charLF,
+ 0
+};
-void
-PrintWriter::initialize()
+PrintWriter::PrintWriter(bool fAutoFlush) :
+ Writer(),
+ m_fAutoFlush(fAutoFlush)
{
- ::s_trueString = XALAN_STATIC_UCODE_STRING("true");
-
- ::s_falseString = XALAN_STATIC_UCODE_STRING("false");
-
- // $$$ ToDo: Does this need to be \r\n for some platforms?
- ::s_newlineString = XALAN_STATIC_UCODE_STRING("\n");
}
-void
-PrintWriter::terminate()
+PrintWriter::~PrintWriter()
{
- clear(::s_trueString);
-
- clear(::s_falseString);
-
- clear(::s_newlineString);
}
1.10 +3 -19 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.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- PrintWriter.hpp 2000/09/05 02:24:45 1.9
+++ PrintWriter.hpp 2001/02/08 21:39:04 1.10
@@ -74,21 +74,6 @@
public:
/**
- * Initialize static data. Must be called before any
- * other functions are called. See PlatformSupportInit.
- */
- static void
- initialize();
-
- /**
- * Destroy static data. After thus function is called,
- * no other functions can be called. See PlatformSupportInit.
- */
- static void
- terminate();
-
-
- /**
* Constructor
*
* @param fAutoFlush if true, the output will not be buffered
@@ -98,7 +83,6 @@
virtual
~PrintWriter();
-
/**
* Flush the stream, then check the error status.
*
@@ -205,11 +189,11 @@
const bool m_fAutoFlush;
// Some static strings to help derived classes...
- static const XalanDOMString& s_trueString;
+ static const XalanDOMChar s_trueString[];
- static const XalanDOMString& s_falseString;
+ static const XalanDOMChar s_falseString[];
- static const XalanDOMString& s_newlineString;
+ static const XalanDOMChar s_newlineString[];
private:
1.12 +38 -39 xml-xalan/c/src/PlatformSupport/URISupport.cpp
Index: URISupport.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/URISupport.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- URISupport.cpp 2000/11/02 01:45:37 1.11
+++ URISupport.cpp 2001/02/08 21:39:05 1.12
@@ -72,6 +72,35 @@
+const XalanDOMChar URISupport::s_fileProtocolString1[] =
+{
+ XalanUnicode::charLetter_f,
+ XalanUnicode::charLetter_i,
+ XalanUnicode::charLetter_l,
+ XalanUnicode::charLetter_e,
+ XalanUnicode::charColon,
+ XalanUnicode::charSolidus,
+ XalanUnicode::charSolidus,
+ 0
+};
+
+
+
+const XalanDOMChar URISupport::s_fileProtocolString2[] =
+{
+ XalanUnicode::charLetter_f,
+ XalanUnicode::charLetter_i,
+ XalanUnicode::charLetter_l,
+ XalanUnicode::charLetter_e,
+ XalanUnicode::charColon,
+ XalanUnicode::charSolidus,
+ XalanUnicode::charSolidus,
+ XalanUnicode::charSolidus,
+ 0
+};
+
+
+
URISupport::URLAutoPtrType
URISupport::getURLFromString(const XalanDOMString& urlString)
{
@@ -135,7 +164,7 @@
else
{
// Assume it's a file specification...
- XalanArrayAutoPtr<XMLCh> theFullPath(XMLPlatformUtils::getFullPath(c_wstr(urlString)));
+ XalanArrayAutoPtr<XalanDOMChar> theFullPath(XMLPlatformUtils::getFullPath(c_wstr(urlString)));
assert(theFullPath.get() != 0);
theNormalizedURI = theFullPath.get();
@@ -143,12 +172,14 @@
NormalizeURIText(theNormalizedURI);
- const XalanDOMString theFilePrefix(
- indexOf(theNormalizedURI, XalanUnicode::charSolidus) == 0 ?
- s_fileProtocolString1 :
- s_fileProtocolString2);
-
- theNormalizedURI = theFilePrefix + theNormalizedURI;
+ if (indexOf(theNormalizedURI, XalanUnicode::charSolidus) == 0)
+ {
+ insert(theNormalizedURI, 0, &s_fileProtocolString1[0]);
+ }
+ else
+ {
+ insert(theNormalizedURI, 0, &s_fileProtocolString2[0]);
+ }
}
}
@@ -313,36 +344,4 @@
URISupport::InvalidURIException::~InvalidURIException()
{
-}
-
-
-
-static XalanDOMString s_fileProtocolString1;
-
-static XalanDOMString s_fileProtocolString2;
-
-
-
-const XalanDOMString& URISupport::s_fileProtocolString1 = ::s_fileProtocolString1;
-
-const XalanDOMString& URISupport::s_fileProtocolString2 = ::s_fileProtocolString2;
-
-
-
-void
-URISupport::initialize()
-{
- ::s_fileProtocolString1 = XALAN_STATIC_UCODE_STRING("file://");
-
- ::s_fileProtocolString2 = XALAN_STATIC_UCODE_STRING("file:///");
-}
-
-
-
-void
-URISupport::terminate()
-{
- clear(::s_fileProtocolString1);
-
- clear(::s_fileProtocolString2);
}
1.6 +2 -17 xml-xalan/c/src/PlatformSupport/URISupport.hpp
Index: URISupport.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/URISupport.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- URISupport.hpp 2000/11/02 01:45:37 1.5
+++ URISupport.hpp 2001/02/08 21:39:07 1.6
@@ -87,21 +87,6 @@
typedef XalanAutoPtr<XMLURL> URLAutoPtrType;
/**
- * Initialize static data. Must be called before any
- * other functions are called. See PlatformSupportInit.
- */
- static void
- initialize();
-
- /**
- * Destroy static data. After thus function is called,
- * no other functions can be called. See PlatformSupportInit.
- */
- static void
- terminate();
-
-
- /**
* Determine the fully qualified URI for a string.
*
* @param urlString string to qualify
@@ -212,9 +197,9 @@
};
- static const XalanDOMString& s_fileProtocolString1;
+ static const XalanDOMChar s_fileProtocolString1[];
- static const XalanDOMString& s_fileProtocolString2;
+ static const XalanDOMChar s_fileProtocolString2[];
};
1.7 +9 -24 xml-xalan/c/src/PlatformSupport/XalanNumberFormat.cpp
Index: XalanNumberFormat.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/XalanNumberFormat.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- XalanNumberFormat.cpp 2000/11/02 01:45:38 1.6
+++ XalanNumberFormat.cpp 2001/02/08 21:39:08 1.7
@@ -64,9 +64,18 @@
#include "DOMStringHelper.hpp"
#include "STLHelper.hpp"
+#include "XalanUnicode.hpp"
+const XalanDOMChar XalanNumberFormat::s_defaultGroupingSeparator[] =
+{
+ XalanUnicode::charComma,
+ 0
+};
+
+
+
XalanNumberFormat::XalanNumberFormat() :
m_isGroupingUsed(false),
m_groupingSeparator(s_defaultGroupingSeparator),
@@ -198,28 +207,4 @@
XalanNumberFormat::setGroupingSeparator(const XalanDOMString& s)
{
m_groupingSeparator = s;
-}
-
-
-
-static XalanDOMString s_defaultGroupingSeparator;
-
-
-
-const XalanDOMString& XalanNumberFormat::s_defaultGroupingSeparator = ::s_defaultGroupingSeparator;
-
-
-
-void
-XalanNumberFormat::initialize()
-{
- ::s_defaultGroupingSeparator = XALAN_STATIC_UCODE_STRING(",");
-}
-
-
-
-void
-XalanNumberFormat::terminate()
-{
- clear(::s_defaultGroupingSeparator);
}
1.3 +4 -19 xml-xalan/c/src/PlatformSupport/XalanNumberFormat.hpp
Index: XalanNumberFormat.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/XalanNumberFormat.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XalanNumberFormat.hpp 2000/09/05 02:24:45 1.2
+++ XalanNumberFormat.hpp 2001/02/08 21:39:09 1.3
@@ -72,21 +72,6 @@
{
public:
- /**
- * Initialize static data. Must be called before any
- * other functions are called. See PlatformSupportInit.
- */
- static void
- initialize();
-
- /**
- * Destroy static data. After thus function is called,
- * no other functions can be called. See PlatformSupportInit.
- */
- static void
- terminate();
-
-
explicit
XalanNumberFormat();
@@ -187,13 +172,13 @@
operator==(const XalanNumberFormat&);
// Data members...
- bool m_isGroupingUsed;
+ bool m_isGroupingUsed;
- XalanDOMString m_groupingSeparator;
+ XalanDOMString m_groupingSeparator;
- int m_groupingSize;
+ int m_groupingSize;
- static const XalanDOMString& s_defaultGroupingSeparator;
+ static const XalanDOMChar s_defaultGroupingSeparator[];
};
1.8 +17 -5 xml-xalan/c/src/PlatformSupport/XalanOutputStream.cpp
Index: XalanOutputStream.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/XalanOutputStream.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XalanOutputStream.cpp 2001/01/27 20:38:01 1.7
+++ XalanOutputStream.cpp 2001/02/08 21:39:11 1.8
@@ -112,7 +112,19 @@
void
XalanOutputStream::write(XalanDOMChar theChar)
{
- write(&theChar, 1);
+ if (m_bufferSize == 0)
+ {
+ doWrite(&theChar, 1);
+ }
+ else
+ {
+ if (m_buffer.size() == m_bufferSize)
+ {
+ flushBuffer();
+ }
+
+ m_buffer.push_back(theChar);
+ }
}
@@ -364,17 +376,17 @@
typedef XalanTranscodingServices::XalanXMLByteVectorType XalanXMLByteVectorType;
- const XalanXMLByteVectorType& theProlog =
+ const XalanTranscodingServices::XalanXMLByte* theProlog =
XalanTranscodingServices::getStreamProlog(theEncoding);
- const XalanXMLByteVectorType::size_type theSize = theProlog.size();
+ const unsigned int theSize = XalanTranscodingServices::length(theProlog);
if (theSize > 0)
{
#if defined(XALAN_OLD_STYLE_CASTS)
- write((const char*)&theProlog[0], theProlog.size());
+ write((const char*)theProlog, theSize);
#else
- write(reinterpret_cast<const char*>(&theProlog[0]), theProlog.size());
+ write(reinterpret_cast<const char*>(theProlog), theSize);
#endif
}
}
1.5 +37 -37 xml-xalan/c/src/PlatformSupport/XalanTranscodingServices.cpp
Index: XalanTranscodingServices.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/XalanTranscodingServices.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XalanTranscodingServices.cpp 2000/11/02 01:45:39 1.4
+++ XalanTranscodingServices.cpp 2001/02/08 21:39:12 1.5
@@ -143,6 +143,39 @@
+const XalanTranscodingServices::XalanXMLByte XalanTranscodingServices::s_dummyByteOrderMark[] =
+{
+ XalanXMLByte(0)
+};
+
+
+
+const XalanTranscodingServices::XalanXMLByte XalanTranscodingServices::s_UTF8ByteOrderMark[] =
+{
+ XalanXMLByte(0xEF),
+ XalanXMLByte(0xBB),
+ XalanXMLByte(0xBF),
+ XalanXMLByte(0)
+};
+
+
+
+const XalanTranscodingServices::XalanXMLByte XalanTranscodingServices::s_UTF16ByteOrderMark[] =
+{
+#if defined(XALAN_LITLE_ENDIAN)
+ XalanXMLByte(0xFF),
+ XalanXMLByte(0xFE),
+#elif defined(XALAN_BIG_ENDIAN)
+ XalanXMLByte(0xFE),
+ XalanXMLByte(0xFF),
+#else
+#error The platform must define the byte order!
+#endif
+ XalanXMLByte(0)
+};
+
+
+
static XalanTranscodingServices::eCode
translateCode(XMLTransService::Codes theCode)
{
@@ -246,32 +279,24 @@
}
-
-// Some vectors for containing byte-order marks, or other leading bytes
-// that would indicate the encoding.
-static const XalanTranscodingServices::XalanXMLByteVectorType s_dummyVector;
-static XalanTranscodingServices::XalanXMLByteVectorType s_UTF8Vector;
-static XalanTranscodingServices::XalanXMLByteVectorType s_UTF16Vector;
-
-
-const XalanTranscodingServices::XalanXMLByteVectorType&
+const XalanTranscodingServices::XalanXMLByte*
XalanTranscodingServices::getStreamProlog(const XalanDOMString& theEncodingName)
{
if (compareIgnoreCase(c_wstr(theEncodingName), s_utf16String) == 0)
{
- return s_UTF16Vector;
+ return s_UTF16ByteOrderMark;
}
#if 0
// We won't do this for now...
else if (compareIgnoreCase(c_wstr(theEncodingName), s_utf8String) == 0)
{
- return s_UTF8Vector;
+ return s_UTF8ByteOrderMark;
}
#endif
else
{
- return s_dummyVector;
+ return s_dummyByteOrderMark;
}
}
@@ -406,28 +431,6 @@
void
XalanTranscodingServices::initialize()
{
- s_UTF8Vector.reserve(3);
-
- // These are the characters that comprise the
- // UTF-8 byte-order mark.
- s_UTF8Vector.push_back(0xEF);
- s_UTF8Vector.push_back(0xBB);
- s_UTF8Vector.push_back(0xBF);
-
- s_UTF16Vector.reserve(2);
-
- // The byte order mark varies, since we're writing
- // UTF-16 out in the platform's endian-ness.
-#if defined(XALAN_LITLE_ENDIAN)
- s_UTF16Vector.push_back(0xFF);
- s_UTF16Vector.push_back(0xFE);
-#elif defined(XALAN_BIG_ENDIAN)
- s_UTF16Vector.push_back(0xFE);
- s_UTF16Vector.push_back(0xFF);
-#else
-#error The platform must define the byte order!
-#endif
-
initMaximumCharacterValueMap(::s_maximumCharacterValues);
}
@@ -436,8 +439,5 @@
void
XalanTranscodingServices::terminate()
{
- XalanXMLByteVectorType().swap(s_UTF16Vector);
- XalanXMLByteVectorType().swap(s_UTF8Vector);
-
MaximumCharacterValueMapType().swap(::s_maximumCharacterValues);
}
1.3 +36 -16 xml-xalan/c/src/PlatformSupport/XalanTranscodingServices.hpp
Index: XalanTranscodingServices.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/XalanTranscodingServices.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XalanTranscodingServices.hpp 2000/10/07 15:23:41 1.2
+++ XalanTranscodingServices.hpp 2001/02/08 21:39:14 1.3
@@ -64,6 +64,7 @@
+#include <cassert>
#include <map>
#include <vector>
@@ -85,8 +86,35 @@
{
public:
+ /**
+ * Perform static initialization. See class PlatformSupportInit.
+ */
+ static void
+ initialize();
+
+ /**
+ * Perform static shut down. See class PlatformSupportInit.
+ */
+ static void
+ terminate();
+
typedef unsigned char XalanXMLByte;
+ static unsigned int
+ length(const XalanXMLByte* theBytes)
+ {
+ assert(theBytes != 0);
+
+ const XalanXMLByte* theCurrentByte = theBytes;
+
+ while(*theCurrentByte != 0)
+ {
+ ++theCurrentByte;
+ }
+
+ return theCurrentByte - theBytes;
+ }
+
#if defined(XALAN_NO_NAMESPACES)
typedef map<XalanDOMString,
XalanDOMChar,
@@ -98,18 +126,6 @@
typedef std::vector<XalanXMLByte> XalanXMLByteVectorType;
#endif
- /**
- * Perform static initialization. See class PlatformSupportInit.
- */
- static void
- initialize();
-
- /**
- * Perform static shut down. See class PlatformSupportInit.
- */
- static void
- terminate();
-
enum eCode
{
OK,
@@ -179,17 +195,17 @@
encodingIsUTF16(const XalanDOMString& theEncodingName);
/**
- * Get a vector that contains any leading bytes that should be
+ * Get an array that contains any leading bytes that should be
* written to an XML stream for the specified encoding. For example,
* if the encoding is UTF-16, the vector will contain the appropriate
* byte order mark for the current platform. If there is no
* prolog for the encoding, or the encoding is unknown, an empty
- * vector is returned.
+ * array is returned.
*
* @param theEncodingName The name of the desired output encoding.
- * @return A reference to a vector containing the appropriate bytes.
+ * @return An array containing the appropriate bytes.
*/
- static const XalanXMLByteVectorType&
+ static const XalanXMLByte*
getStreamProlog(const XalanDOMString& theEncodingName);
/**
@@ -260,6 +276,10 @@
};
private:
+
+ static const XalanXMLByte s_dummyByteOrderMark[];
+ static const XalanXMLByte s_UTF8ByteOrderMark[];
+ static const XalanXMLByte s_UTF16ByteOrderMark[];
static const MaximumCharacterValueMapType& s_maximumCharacterValues;
};
1.5 +6 -0 xml-xalan/c/src/PlatformSupport/XalanUnicode.hpp
Index: XalanUnicode.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/XalanUnicode.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XalanUnicode.hpp 2000/12/01 21:36:15 1.4
+++ XalanUnicode.hpp 2001/02/08 21:39:15 1.5
@@ -188,9 +188,12 @@
charLetter_o = 0x6F,
charLetter_p = 0x70,
charLetter_q = 0x71,
+ charLetter_r = 0x72,
charLetter_s = 0x73,
charLetter_t = 0x74,
charLetter_u = 0x75,
+ charLetter_w = 0x77,
+ charLetter_x = 0x78,
charLetter_y = 0x79,
charLetter_z = 0x7A,
@@ -313,9 +316,12 @@
static const XalanDOMChar charLetter_o = 0x6F;
static const XalanDOMChar charLetter_p = 0x70;
static const XalanDOMChar charLetter_q = 0x71;
+ static const XalanDOMChar charLetter_r = 0x72;
static const XalanDOMChar charLetter_s = 0x73;
static const XalanDOMChar charLetter_t = 0x74;
static const XalanDOMChar charLetter_u = 0x75;
+ static const XalanDOMChar charLetter_w = 0x77;
+ static const XalanDOMChar charLetter_x = 0x78;
static const XalanDOMChar charLetter_y = 0x79;
static const XalanDOMChar charLetter_z = 0x7A;