Author: hdu
Date: Wed May  8 15:17:19 2013
New Revision: 1480318

URL: http://svn.apache.org/r1480318
Log:
#i122208# use rtl::CStringHash and rtl::CStringEqual instead of relying on 
pre-tr1-stl specializations

In stlport<=4 the functors hash and equal_to had specializions for conveniently 
handling c-strings.
For consistency reasons this specialization was not included in the TR1 report 
and the C++11 standard.
The two new helper functors are drop-in replacements for the old 
specializations.

Modified:
    openoffice/trunk/main/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx
    openoffice/trunk/main/oox/inc/oox/export/shapes.hxx
    openoffice/trunk/main/oox/source/export/shapes.cxx
    openoffice/trunk/main/sal/inc/rtl/string.hxx
    openoffice/trunk/main/sdext/source/minimizer/pppoptimizertoken.cxx
    
openoffice/trunk/main/svx/source/customshapes/EnhancedCustomShapeTypeNames.cxx
    openoffice/trunk/main/vcl/source/glyphs/gcach_ftyp.cxx
    openoffice/trunk/main/writerfilter/source/resourcemodel/TagLogger.cxx
    openoffice/trunk/main/xmloff/source/draw/EnhancedCustomShapeToken.cxx

Modified: openoffice/trunk/main/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx?rev=1480318&r1=1480317&r2=1480318&view=diff
==============================================================================
--- openoffice/trunk/main/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx 
(original)
+++ openoffice/trunk/main/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx Wed 
May  8 15:17:19 2013
@@ -33,22 +33,6 @@ using namespace com::sun::star;
 using namespace com::sun::star::uno;
 using namespace com::sun::star::lang;
 
-
-struct equalStr
-{
-    bool operator()(
-        const char * const &rA,
-        const char * const &rB) const
-        { return !strcmp(rA, rB); }
-};
-struct hashStr
-{
-    size_t operator()( const char * &rName ) const
-    {
-        return rtl::OString(rName).hashCode();
-    }
-};
-
 class ContainerListener;
 
 struct ContainerStats {
@@ -253,7 +237,7 @@ namespace cppu_ifcontainer
         void testOMultiTypeInterfaceContainerHelperVar()
         {
             typedef ::cppu::OMultiTypeInterfaceContainerHelperVar<
-                const char *,hashStr,equalStr> StrContainer;
+                const char*, rtl::CStringHash, rtl::CStringEqual> StrContainer;
 
             const char *pTypes[nTests] =
             {

Modified: openoffice/trunk/main/oox/inc/oox/export/shapes.hxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/oox/inc/oox/export/shapes.hxx?rev=1480318&r1=1480317&r2=1480318&view=diff
==============================================================================
--- openoffice/trunk/main/oox/inc/oox/export/shapes.hxx (original)
+++ openoffice/trunk/main/oox/inc/oox/export/shapes.hxx Wed May  8 15:17:19 2013
@@ -62,7 +62,7 @@ private:
 
     struct ShapeHash
     {
-        std::hash<const char*> maHashFunction;
+        rtl::CStringHash maHashFunction;
 
         size_t operator()( const ::com::sun::star::uno::Reference < 
::com::sun::star::drawing::XShape > ) const;
     };

Modified: openoffice/trunk/main/oox/source/export/shapes.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/oox/source/export/shapes.cxx?rev=1480318&r1=1480317&r2=1480318&view=diff
==============================================================================
--- openoffice/trunk/main/oox/source/export/shapes.cxx (original)
+++ openoffice/trunk/main/oox/source/export/shapes.cxx Wed May  8 15:17:19 2013
@@ -307,15 +307,7 @@ static const CustomShapeTypeTranslationT
     { "mso-spt202", "rect" }
 };
 
-struct StringCheck
-{
-    bool operator()( const char* s1, const char* s2 ) const
-    {
-        return strcmp( s1, s2 ) == 0;
-    }
-};
-
-typedef std::hash_map< const char*, const char*, std::hash<const char*>, 
StringCheck> CustomShapeTypeTranslationHashMap;
+typedef std::hash_map< const char*, const char*, CStringHash, CStringEqual> 
CustomShapeTypeTranslationHashMap;
 static CustomShapeTypeTranslationHashMap* pCustomShapeTypeTranslationHashMap = 
NULL;
 
 static const char* lcl_GetPresetGeometry( const char* sShapeType )
@@ -869,7 +861,7 @@ ShapeExport& ShapeExport::WriteRectangle
 }
 
 typedef ShapeExport& (ShapeExport::*ShapeConverter)( Reference< XShape > );
-typedef std::hash_map< const char*, ShapeConverter, std::hash<const char*>, 
StringCheck> NameToConvertMapType;
+typedef std::hash_map< const char*, ShapeConverter, CStringHash, CStringEqual> 
NameToConvertMapType;
 
 static const NameToConvertMapType& lcl_GetConverters()
 {

Modified: openoffice/trunk/main/sal/inc/rtl/string.hxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sal/inc/rtl/string.hxx?rev=1480318&r1=1480317&r2=1480318&view=diff
==============================================================================
--- openoffice/trunk/main/sal/inc/rtl/string.hxx (original)
+++ openoffice/trunk/main/sal/inc/rtl/string.hxx Wed May  8 15:17:19 2013
@@ -930,8 +930,31 @@ struct OStringHash
 
 /* ======================================================================= */
 
+/** Equality functor for classic c-strings (i.e. null-terminated char* 
strings) */
+struct CStringEqual
+{
+       bool operator()( const char* p1, const char* p2) const {
+               while( *p1)
+                       if( *(p1++) != *(p2++))
+                               return false;
+               return true;
+       }
+};
+
+/** Hashing functor for classic c-strings (i.e. null-terminated char* strings) 
*/
+struct CStringHash
+{
+       size_t operator()( const char* p) const {
+               size_t n = 0;
+               while( *p)
+                       n += 4*n + *(p++);
+               return n;
+       }
+};
+
 } /* Namespace */
 
 #endif /* __cplusplus */
 
 #endif /* _RTL_STRING_HXX_ */
+

Modified: openoffice/trunk/main/sdext/source/minimizer/pppoptimizertoken.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sdext/source/minimizer/pppoptimizertoken.cxx?rev=1480318&r1=1480317&r2=1480318&view=diff
==============================================================================
--- openoffice/trunk/main/sdext/source/minimizer/pppoptimizertoken.cxx 
(original)
+++ openoffice/trunk/main/sdext/source/minimizer/pppoptimizertoken.cxx Wed May  
8 15:17:19 2013
@@ -27,16 +27,9 @@
 #include "pppoptimizertoken.hxx"
 #include <osl/mutex.hxx>
 #include <hash_map>
-#include <string.h>
+#include <rtl/string.hxx>
 
-struct TCheck
-{
-       bool operator()( const char* s1, const char* s2 ) const
-       {
-               return strcmp( s1, s2 ) == 0;
-       }
-};
-typedef std::hash_map< const char*, PPPOptimizerTokenEnum, std::hash<const 
char*>, TCheck> TypeNameHashMap;
+typedef std::hash_map< const char*, PPPOptimizerTokenEnum, rtl::CStringHash, 
rtl::CStringEqual> TypeNameHashMap;
 static TypeNameHashMap* pHashMap = NULL;
 static ::osl::Mutex& getHashMapMutex()
 {

Modified: 
openoffice/trunk/main/svx/source/customshapes/EnhancedCustomShapeTypeNames.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/customshapes/EnhancedCustomShapeTypeNames.cxx?rev=1480318&r1=1480317&r2=1480318&view=diff
==============================================================================
--- 
openoffice/trunk/main/svx/source/customshapes/EnhancedCustomShapeTypeNames.cxx 
(original)
+++ 
openoffice/trunk/main/svx/source/customshapes/EnhancedCustomShapeTypeNames.cxx 
Wed May  8 15:17:19 2013
@@ -26,15 +26,9 @@
 #include "svx/EnhancedCustomShapeTypeNames.hxx"
 #include <osl/mutex.hxx>
 #include <hash_map>
+#include "rtl/string.hxx"
 
-struct TCheck
-{
-       bool operator()( const char* s1, const char* s2 ) const
-       {
-               return strcmp( s1, s2 ) == 0;
-       }
-};
-typedef std::hash_map< const char*, MSO_SPT, std::hash<const char*>, TCheck> 
TypeNameHashMap;
+typedef std::hash_map< const char*, MSO_SPT, rtl::CStringHash, 
rtl::CStringEqual> TypeNameHashMap;
 static TypeNameHashMap* pHashMap = NULL;
 static ::osl::Mutex& getHashMapMutex()
 {

Modified: openoffice/trunk/main/vcl/source/glyphs/gcach_ftyp.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/vcl/source/glyphs/gcach_ftyp.cxx?rev=1480318&r1=1480317&r2=1480318&view=diff
==============================================================================
--- openoffice/trunk/main/vcl/source/glyphs/gcach_ftyp.cxx (original)
+++ openoffice/trunk/main/vcl/source/glyphs/gcach_ftyp.cxx Wed May  8 15:17:19 
2013
@@ -131,8 +131,7 @@ FT_Error (*pFTEmbolden)(FT_GlyphSlot);
 FT_Error (*pFTOblique)(FT_GlyphSlot);
 static bool bEnableSizeFT = false;
 
-struct EqStr{ bool operator()(const char* a, const char* b) const { return 
!strcmp(a,b); } };
-typedef ::std::hash_map<const char*,FtFontFile*,::std::hash<const char*>, 
EqStr> FontFileList;
+typedef ::std::hash_map< const char*, FtFontFile*, CStringHash, CStringEqual> 
FontFileList;
 namespace { struct vclFontFileList : public rtl::Static< FontFileList, 
vclFontFileList > {}; }
 
 // -----------------------------------------------------------------------

Modified: openoffice/trunk/main/writerfilter/source/resourcemodel/TagLogger.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/writerfilter/source/resourcemodel/TagLogger.cxx?rev=1480318&r1=1480317&r2=1480318&view=diff
==============================================================================
--- openoffice/trunk/main/writerfilter/source/resourcemodel/TagLogger.cxx 
(original)
+++ openoffice/trunk/main/writerfilter/source/resourcemodel/TagLogger.cxx Wed 
May  8 15:17:19 2013
@@ -224,15 +224,7 @@ ostream & XMLTag::output(ostream & o, co
     return o;
 }
 
-struct eqstr
-{
-    bool operator()(const char* s1, const char* s2) const
-    {
-        return strcmp(s1, s2) == 0;
-    }
-};
-
-typedef hash_map<const char *, TagLogger::Pointer_t, hash<const char *>, 
eqstr> TagLoggerHashMap_t;
+typedef hash_map< const char*, TagLogger::Pointer_t, rtl::CStringHash, 
rtl::CStringEqual> TagLoggerHashMap_t;
 static TagLoggerHashMap_t * tagLoggers = NULL;
 
 TagLogger::TagLogger()

Modified: openoffice/trunk/main/xmloff/source/draw/EnhancedCustomShapeToken.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/xmloff/source/draw/EnhancedCustomShapeToken.cxx?rev=1480318&r1=1480317&r2=1480318&view=diff
==============================================================================
--- openoffice/trunk/main/xmloff/source/draw/EnhancedCustomShapeToken.cxx 
(original)
+++ openoffice/trunk/main/xmloff/source/draw/EnhancedCustomShapeToken.cxx Wed 
May  8 15:17:19 2013
@@ -26,18 +26,11 @@
 #include "EnhancedCustomShapeToken.hxx"
 #include <osl/mutex.hxx>
 #include <hash_map>
-#include <string.h>
+#include <rtl/string.hxx>
 
 namespace xmloff { namespace EnhancedCustomShapeToken {
 
-struct TCheck
-{
-       bool operator()( const char* s1, const char* s2 ) const
-       {
-               return strcmp( s1, s2 ) == 0;
-       }
-};
-typedef std::hash_map< const char*, EnhancedCustomShapeTokenEnum, 
std::hash<const char*>, TCheck> TypeNameHashMap;
+typedef std::hash_map< const char*, EnhancedCustomShapeTokenEnum, 
rtl::CStringHash, rtl::CStringEqual> TypeNameHashMap;
 static TypeNameHashMap* pHashMap = NULL;
 static ::osl::Mutex& getHashMapMutex()
 {


Reply via email to