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/05/08 19:13:15 UTC
cvs commit: xml-xalan/c/src/ICUBridge FunctionICUFormatNumber.cpp FunctionICUFormatNumber.hpp ICUBridge.cpp ICUBridge.hpp ICUBridgeDefinitions.hpp ICUXalanNumberFormatFactory.cpp ICUXalanNumberFormatFactory.hpp ICUXalanNumberFormatProxy.cpp ICUXalanNumberFormatProxy.hpp
dbertoni 00/05/08 10:13:15
Added: c/src/ICUBridge FunctionICUFormatNumber.cpp
FunctionICUFormatNumber.hpp ICUBridge.cpp
ICUBridge.hpp ICUBridgeDefinitions.hpp
ICUXalanNumberFormatFactory.cpp
ICUXalanNumberFormatFactory.hpp
ICUXalanNumberFormatProxy.cpp
ICUXalanNumberFormatProxy.hpp
Log:
Initial revision.
Revision Changes Path
1.1 xml-xalan/c/src/ICUBridge/FunctionICUFormatNumber.cpp
Index: FunctionICUFormatNumber.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "FunctionICUFormatNumber.hpp"
#include <PlatformSupport/XalanDecimalFormatSymbols.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <XPath/XPath.hpp>
#include <XPath/XPathExecutionContext.hpp>
#include <ICUBridge/ICUBridge.hpp>
FunctionICUFormatNumber::FunctionICUFormatNumberInstaller::FunctionICUFormatNumberInstaller()
{
XPath::installFunction(
XALAN_STATIC_UCODE_STRING("format-number"),
FunctionICUFormatNumber());
}
FunctionICUFormatNumber::FunctionICUFormatNumberInstaller::~FunctionICUFormatNumberInstaller()
{
}
FunctionICUFormatNumber::FunctionICUFormatNumber() :
FunctionFormatNumber()
{
}
FunctionICUFormatNumber::~FunctionICUFormatNumber()
{
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionICUFormatNumber*
#endif
FunctionICUFormatNumber::clone() const
{
return new FunctionICUFormatNumber(*this);
}
ICUBridge::UTF16VectorType
makeUTF16VectorType(const XalanDOMString& theString)
{
return ICUBridge::UTF16VectorType(
c_wstr(theString),
c_wstr(theString) + length(theString));
}
XalanDOMString
FunctionICUFormatNumber::doFormat(
XPathExecutionContext& executionContext,
XalanNode* context,
double theNumber,
const XalanDOMString& thePattern,
const XalanDecimalFormatSymbols* theDFS)
{
ICUBridge::UTF16VectorType theResultString;
unsigned long theResult = 0;
if (theDFS == 0)
{
// Nothing special, so use the default call...
theResult = ICUBridge::FormatNumber(
makeUTF16VectorType(thePattern),
theNumber,
theResultString);
}
else
{
// DecimalFormatSymbols specified, so use those values...
theResult = ICUBridge::FormatNumber(
makeUTF16VectorType(thePattern),
theNumber,
makeUTF16VectorType(theDFS->getCurrencySymbol()),
theDFS->getDecimalSeparator(),
theDFS->getDigit(),
theDFS->getGroupingSeparator(),
makeUTF16VectorType(theDFS->getInfinity()),
makeUTF16VectorType(theDFS->getInternationalCurrencySymbol()),
theDFS->getMinusSign(),
theDFS->getMonetaryDecimalSeparator(),
makeUTF16VectorType(theDFS->getNaN()),
theDFS->getPatternSeparator(),
theDFS->getPercent(),
theDFS->getPerMill(),
theDFS->getZeroDigit(),
theResultString);
}
if (theResult != 0)
{
executionContext.warn(
XALAN_STATIC_UCODE_STRING("Warning! ICUBridge::FormatNumber failed. (") +
UnsignedLongToDOMString(theResult) +
XALAN_STATIC_UCODE_STRING(")."),
context);
return FunctionFormatNumber::doFormat(
executionContext,
context,
theNumber,
thePattern,
theDFS);
}
else
{
return XalanDOMString(theResultString.begin(), theResultString.size());
}
}
1.1 xml-xalan/c/src/ICUBridge/FunctionICUFormatNumber.hpp
Index: FunctionICUFormatNumber.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(FUNCTIONICUFORMATNUMBER_HEADER_GUARD_1357924680)
#define FUNCTIONICUFORMATNUMBER_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <ICUBridge/ICUBridgeDefinitions.hpp>
#include <XSLT/FunctionFormatNumber.hpp>
// Class that implements the XSLT function format-number using the ICU.
//
class XALAN_ICUBRIDGE_EXPORT FunctionICUFormatNumber : public FunctionFormatNumber
{
public:
class XALAN_ICUBRIDGE_EXPORT FunctionICUFormatNumberInstaller
{
public:
FunctionICUFormatNumberInstaller();
~FunctionICUFormatNumberInstaller();
};
FunctionICUFormatNumber();
virtual
~FunctionICUFormatNumber();
// These methods are inherited from XPath/FunctionFormatNumber ...
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual Function*
#else
virtual FunctionICUFormatNumber*
#endif
clone() const;
protected:
virtual XalanDOMString
doFormat(
XPathExecutionContext& executionContext,
XalanNode* context,
double theNumber,
const XalanDOMString& thePattern,
const XalanDecimalFormatSymbols* theDFS);
private:
// Not implemented...
FunctionICUFormatNumber&
operator=(const FunctionICUFormatNumber&);
bool
operator==(const FunctionICUFormatNumber&) const;
};
#endif // FUNCTIONICUFORMATNUMBER_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/ICUBridge/ICUBridge.cpp
Index: ICUBridge.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include <ICUBridge/ICUBridge.hpp>
#include <unicode/dcfmtsym.h>
#include <unicode/decimfmt.h>
unsigned long
ICUBridge::FormatNumber(
const UTF16VectorType& thePattern,
double theNumber,
UTF16VectorType& theResult)
{
const UnicodeString theUnicodePattern(&thePattern[0], thePattern.size());
UErrorCode theStatus = U_ZERO_ERROR;
UnicodeString theUnicodeResult;
DecimalFormat theFormatter(theUnicodePattern, theStatus);
if (theStatus == U_ZERO_ERROR)
{
// Do the format...
theFormatter.format(theNumber, theUnicodeResult);
const int32_t theLength = theUnicodeResult.length();
// Resize the vector to the appropriate length...
theResult.clear();
theResult.resize(theLength);
theUnicodeResult.extract(0, theLength, &theResult[0]);
}
return theStatus;
}
unsigned long
ICUBridge::FormatNumber(
const UTF16VectorType& thePattern,
double theNumber,
const UTF16VectorType& theCurrencySymbolString,
unsigned short theDecimalSeparatorChar,
unsigned short theDigitChar,
unsigned short theGroupingSeparatorChar,
const UTF16VectorType& theInfinityString,
const UTF16VectorType& theInternationalCurrencySymbolString,
unsigned short theMinusSignChar,
unsigned short theMonetaryDecimalSeparatorChar,
const UTF16VectorType& theNaNString,
unsigned short thePatternSeparatorChar,
unsigned short thePercentChar,
unsigned short thePerMillChar,
unsigned short theZeroDigitChar,
UTF16VectorType& theResult)
{
const UnicodeString theUnicodePattern(&thePattern[0], thePattern.size());
UErrorCode theStatus = U_ZERO_ERROR;
UnicodeString theUnicodeResult;
DecimalFormatSymbols theDFS(theStatus);
theDFS.setZeroDigit(theZeroDigitChar);
theDFS.setGroupingSeparator(theGroupingSeparatorChar);
theDFS.setDecimalSeparator(theDecimalSeparatorChar);
theDFS.setPerMill(thePerMillChar);
theDFS.setPercent(thePercentChar);
theDFS.setDigit(theDigitChar);
theDFS.setPatternSeparator(thePatternSeparatorChar);
theDFS.setInfinity(UnicodeString(&theInfinityString[0], theInfinityString.size()));
theDFS.setNaN(UnicodeString(&theNaNString[0], theNaNString.size()));
// theDFS.setPlusSign(theZeroDigitChar);
theDFS.setMinusSign(theMinusSignChar);
// theDFS.setExponentialSymbol(theZeroDigitChar);
theDFS.setCurrencySymbol(UnicodeString(&theCurrencySymbolString[0], theCurrencySymbolString.size()));
theDFS.setInternationalCurrencySymbol(UnicodeString(&theInternationalCurrencySymbolString[0], theInternationalCurrencySymbolString.size()));
theDFS.setMonetaryDecimalSeparator(theMonetaryDecimalSeparatorChar);
if (theStatus == U_ZERO_ERROR)
{
DecimalFormat theFormatter(theUnicodePattern, theDFS, theStatus);
if (theStatus == U_ZERO_ERROR)
{
// Do the format...
theFormatter.format(theNumber, theUnicodeResult);
const int32_t theLength = theUnicodeResult.length();
// Resize the vector to the appropriate length...
theResult.clear();
theResult.resize(theLength);
theUnicodeResult.extract(0, theLength, &theResult[0]);
}
}
return theStatus;
}
1.1 xml-xalan/c/src/ICUBridge/ICUBridge.hpp
Index: ICUBridge.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(ICUBRIDGE_HEADER_GUARD_1357924680)
#define ICUBRIDGE_HEADER_GUARD_1357924680
#include <ICUBridge/ICUBridgeDefinitions.hpp>
#include <vector>
class XALAN_ICUBRIDGE_EXPORT ICUBridge
{
public:
#if defined(XALAN_NO_NAMESPACES
typedef vector<unsigned short> UTF16VectorType;
#else
typedef std::vector<unsigned short> UTF16VectorType;
#endif
static unsigned long
FormatNumber(
const UTF16VectorType& thePattern,
double theNumber,
UTF16VectorType& theResult);
static unsigned long
FormatNumber(
const UTF16VectorType& thePattern,
double theNumber,
const UTF16VectorType& theCurrencySymbolString,
unsigned short theDecimalSeparatorChar,
unsigned short theDigitChar,
unsigned short theGroupingSeparatorChar,
const UTF16VectorType& theInfinityString,
const UTF16VectorType& theInternationalCurrencySymbolString,
unsigned short theMinusSignChar,
unsigned short theMonetaryDecimalSeparatorChar,
const UTF16VectorType& theNaNString,
unsigned short thePatternSeparatorChar,
unsigned short thePercentChar,
unsigned short thePerMillChar,
unsigned short theZeroDigitChar,
UTF16VectorType& theResult);
};
#endif // ICUBRIDGE_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/ICUBridge/ICUBridgeDefinitions.hpp
Index: ICUBridgeDefinitions.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(ICUBRIDGEDEFINITIONS_HEADER_GUARD_1357924680)
#define ICUBRIDGEDEFINITIONS_HEADER_GUARD_1357924680
#include <Include/PlatformDefinitions.hpp>
#if defined(XALAN_ICUBRIDGE_BUILD_DLL)
#define XALAN_ICUBRIDGE_EXPORT XALAN_PLATFORM_EXPORT
#define XALAN_ICUBRIDGE_EXPORT_FUNCTION(T) XALAN_PLATFORM_EXPORT_FUNCTION(T)
#else
#define XALAN_ICUBRIDGE_EXPORT XALAN_PLATFORM_IMPORT
#define XALAN_ICUBRIDGE_EXPORT_FUNCTION(T) XALAN_PLATFORM_IMPORT_FUNCTION(T)
#endif
#endif // ICUBRIDGEDEFINITIONS_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/ICUBridge/ICUXalanNumberFormatFactory.cpp
Index: ICUXalanNumberFormatFactory.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "ICUXalanNumberFormatFactory.hpp"
#include "ICUXalanNumberFormatProxy.hpp"
ICUXalanNumberFormatFactory::ICUXalanNumberFormatFactory() :
XalanNumberFormatFactory()
{
}
ICUXalanNumberFormatFactory::~ICUXalanNumberFormatFactory()
{
}
XalanNumberFormat*
ICUXalanNumberFormatFactory::create()
{
return new ICUXalanNumberFormatProxy;
}
1.1 xml-xalan/c/src/ICUBridge/ICUXalanNumberFormatFactory.hpp
Index: ICUXalanNumberFormatFactory.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(ICUXALANNUMBERFORMATFACTORY_HEADER_GUARD_1357924680)
#define ICUXALANNUMBERFORMATFACTORY_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <ICUBridge/ICUBridgeDefinitions.hpp>
#include <XSLT/StylesheetExecutionContextDefault.hpp>
// Class that implements the XSLT function format-number using the ICU.
//
class XALAN_ICUBRIDGE_EXPORT ICUXalanNumberFormatFactory : public StylesheetExecutionContextDefault::XalanNumberFormatFactory
{
public:
ICUXalanNumberFormatFactory();
virtual
~ICUXalanNumberFormatFactory();
virtual XalanNumberFormat*
create();
};
#endif // ICUXALANNUMBERFORMATFACTORY_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/ICUBridge/ICUXalanNumberFormatProxy.cpp
Index: ICUXalanNumberFormatProxy.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "ICUXalanNumberFormatProxy.hpp"
#include <vector>
#include <unicode/dcfmtsym.h>
#include <unicode/decimfmt.h>
#include <PlatformSupport/DOMStringHelper.hpp>
inline UnicodeString
XalanDOMStringToUnicodeString(const XalanDOMString& theString)
{
const XalanDOMChar* const theBuffer = c_wstr(theString);
if (theBuffer == 0)
{
return UnicodeString();
}
else
{
return UnicodeString(theBuffer, length(theBuffer));
}
}
inline XalanDOMString
UnicodeStringToXalanDOMString(const UnicodeString& theString)
{
#if !defined(XALAN_NO_NAMESPACES)
using std::vector;
#endif
vector<XalanDOMChar> theBuffer(theString.length(), ' ');
XalanDOMString theResult(&theBuffer[0], theBuffer.size());
const unsigned int theLength = length(theResult);
XalanDOMChar* thePointer = toCharArray(theResult);
for (unsigned int i = 0; i < theLength; ++i)
{
thePointer[i] = theString[i];
}
return theResult;
}
ICUXalanNumberFormatProxy::ICUXalanNumberFormatProxy() :
XalanNumberFormat(),
m_decimalFormat(0)
{
UErrorCode theResult = U_ZERO_ERROR;
m_decimalFormat = new DecimalFormat(theResult);
}
ICUXalanNumberFormatProxy::~ICUXalanNumberFormatProxy()
{
delete m_decimalFormat;
}
XalanDOMString
ICUXalanNumberFormatProxy::format(double theValue)
{
UnicodeString theResult;
m_decimalFormat->format(theValue, theResult);
return UnicodeStringToXalanDOMString(theResult);
}
XalanDOMString
ICUXalanNumberFormatProxy::format(int theValue)
{
UnicodeString theResult;
m_decimalFormat->format(static_cast<long int>(theValue), theResult);
return UnicodeStringToXalanDOMString(theResult);
}
XalanDOMString
ICUXalanNumberFormatProxy::format(unsigned int theValue)
{
UnicodeString theResult;
m_decimalFormat->format(static_cast<long int>(theValue), theResult);
return UnicodeStringToXalanDOMString(theResult);
}
XalanDOMString
ICUXalanNumberFormatProxy::format(long theValue)
{
UnicodeString theResult;
m_decimalFormat->format(theValue, theResult);
return UnicodeStringToXalanDOMString(theResult);
}
XalanDOMString
ICUXalanNumberFormatProxy::format(unsigned long theValue)
{
UnicodeString theResult;
m_decimalFormat->format(static_cast<long int>(theValue), theResult);
return UnicodeStringToXalanDOMString(theResult);
}
bool
ICUXalanNumberFormatProxy::isGroupingUsed() const
{
return m_decimalFormat->isGroupingUsed() ? true : false;
}
void
ICUXalanNumberFormatProxy::setGroupingUsed(bool bUsed)
{
m_decimalFormat->setGroupingUsed(bUsed);
}
void
ICUXalanNumberFormatProxy::setGroupingSize(unsigned long size)
{
assert(size > 0);
m_decimalFormat->setGroupingSize(size);
}
void
ICUXalanNumberFormatProxy::setGroupingSeparator(const XalanDOMString& s)
{
const DecimalFormatSymbols* const theCurrentSymbols =
m_decimalFormat->getDecimalFormatSymbols();
assert(theCurrentSymbols != 0);
DecimalFormatSymbols* const theNewSymbols =
new DecimalFormatSymbols(*theCurrentSymbols);
theNewSymbols->setGroupingSeparator(charAt(s, 0));
m_decimalFormat->adoptDecimalFormatSymbols(theNewSymbols);
}
1.1 xml-xalan/c/src/ICUBridge/ICUXalanNumberFormatProxy.hpp
Index: ICUXalanNumberFormatProxy.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(ICUXALANNUMBERFORMATPROXY_HEADER_GUARD_1357924680)
#define ICUXALANNUMBERFORMATPROXY_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <ICUBridge/ICUBridgeDefinitions.hpp>
#include <PlatformSupport/XalanNumberFormat.hpp>
class DecimalFormat;
// Class that implements the XSLT function format-number using the ICU.
//
class XALAN_ICUBRIDGE_EXPORT ICUXalanNumberFormatProxy : public XalanNumberFormat
{
public:
explicit
ICUXalanNumberFormatProxy();
virtual
~ICUXalanNumberFormatProxy();
virtual XalanDOMString
format(double theValue);
virtual XalanDOMString
format(int theValue);
virtual XalanDOMString
format(unsigned int theValue);
virtual XalanDOMString
format(long theValue);
virtual XalanDOMString
format(unsigned long theValue);
virtual bool
isGroupingUsed() const;
virtual void
setGroupingUsed(bool bUsed);
virtual void
setGroupingSize(unsigned long size);
virtual void
setGroupingSeparator(const XalanDOMString& s);
private:
DecimalFormat* m_decimalFormat;
};
#endif // ICUXALANNUMBERFORMATPROXY_HEADER_GUARD_1357924680