summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx18
-rw-r--r--include/rtl/string.hxx14
-rw-r--r--oox/source/export/shapes.cxx20
-rw-r--r--sdext/source/minimizer/pppoptimizertoken.cxx16
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeTypeNames.cxx17
-rw-r--r--vcl/generic/glyphs/gcach_ftyp.cxx5
-rw-r--r--xmloff/source/draw/EnhancedCustomShapeToken.cxx16
7 files changed, 23 insertions, 83 deletions
diff --git a/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx b/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx
index 5f6467eeb856..3a5c8cf1ea20 100644
--- a/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx
+++ b/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx
@@ -34,22 +34,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 {
@@ -254,7 +238,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] =
{
diff --git a/include/rtl/string.hxx b/include/rtl/string.hxx
index e3d5afbc895a..00baeec9b8d5 100644
--- a/include/rtl/string.hxx
+++ b/include/rtl/string.hxx
@@ -1672,6 +1672,20 @@ struct OStringHash
{ return (size_t)rString.hashCode(); }
};
+/** Equality functor for classic c-strings (i.e. null-terminated char* strings) */
+struct CStringEqual
+{
+ bool operator()( const char* p1, const char* p2) const
+ { return rtl_str_compare(p1, p2) == 0; }
+};
+
+/** Hashing functor for classic c-strings (i.e. null-terminated char* strings) */
+struct CStringHash
+{
+ size_t operator()(const char* p) const
+ { return rtl_str_hashCode(p); }
+};
+
/* ======================================================================= */
/**
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index dab14ce6ad16..2f918c2460fc 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -509,23 +509,7 @@ static const CustomShapeTypeTranslationTable pCustomShapeTypeTranslationTable[]
{ "ooxml-ribbon", "ribbon" },
};
-struct StringHash
-{
- size_t operator()( const char* s ) const
- {
- return rtl_str_hashCode(s);
- }
-};
-
-struct StringCheck
-{
- bool operator()( const char* s1, const char* s2 ) const
- {
- return strcmp( s1, s2 ) == 0;
- }
-};
-
-typedef boost::unordered_map< const char*, const char*, StringHash, StringCheck> CustomShapeTypeTranslationHashMap;
+typedef boost::unordered_map< const char*, const char*, rtl::CStringHash, rtl::CStringEqual> CustomShapeTypeTranslationHashMap;
static CustomShapeTypeTranslationHashMap* pCustomShapeTypeTranslationHashMap = NULL;
static const char* lcl_GetPresetGeometry( const char* sShapeType )
@@ -1109,7 +1093,7 @@ ShapeExport& ShapeExport::WriteRectangleShape( Reference< XShape > xShape )
}
typedef ShapeExport& (ShapeExport::*ShapeConverter)( Reference< XShape > );
-typedef boost::unordered_map< const char*, ShapeConverter, StringHash, StringCheck> NameToConvertMapType;
+typedef boost::unordered_map< const char*, ShapeConverter, rtl::CStringHash, rtl::CStringEqual> NameToConvertMapType;
static const NameToConvertMapType& lcl_GetConverters()
{
diff --git a/sdext/source/minimizer/pppoptimizertoken.cxx b/sdext/source/minimizer/pppoptimizertoken.cxx
index 78ae022b4d9c..f4d8b40bdc1d 100644
--- a/sdext/source/minimizer/pppoptimizertoken.cxx
+++ b/sdext/source/minimizer/pppoptimizertoken.cxx
@@ -24,21 +24,7 @@
#include <boost/unordered_map.hpp>
#include <string.h>
-struct THash
-{
- size_t operator()( const char* s ) const
- {
- return rtl_str_hashCode(s);
- }
-};
-struct TCheck
-{
- bool operator()( const char* s1, const char* s2 ) const
- {
- return strcmp( s1, s2 ) == 0;
- }
-};
-typedef boost::unordered_map< const char*, PPPOptimizerTokenEnum, THash, TCheck> TypeNameHashMap;
+typedef boost::unordered_map< const char*, PPPOptimizerTokenEnum, rtl::CStringHash, rtl::CStringEqual> TypeNameHashMap;
static TypeNameHashMap* pHashMap = NULL;
static ::osl::Mutex& getHashMapMutex()
{
diff --git a/svx/source/customshapes/EnhancedCustomShapeTypeNames.cxx b/svx/source/customshapes/EnhancedCustomShapeTypeNames.cxx
index 9c06dab28a9f..ca8dfdea2415 100644
--- a/svx/source/customshapes/EnhancedCustomShapeTypeNames.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeTypeNames.cxx
@@ -21,21 +21,8 @@
#include <osl/mutex.hxx>
#include <boost/unordered_map.hpp>
-struct THash
-{
- size_t operator()( const char* s ) const
- {
- return rtl_str_hashCode(s);
- }
-};
-struct TCheck
-{
- bool operator()( const char* s1, const char* s2 ) const
- {
- return strcmp( s1, s2 ) == 0;
- }
-};
-typedef boost::unordered_map< const char*, MSO_SPT, THash, TCheck> TypeNameHashMap;
+typedef boost::unordered_map< const char*, MSO_SPT, rtl::CStringHash, rtl::CStringEqual> TypeNameHashMap;
+
static TypeNameHashMap* pHashMap = NULL;
static ::osl::Mutex& getHashMapMutex()
{
diff --git a/vcl/generic/glyphs/gcach_ftyp.cxx b/vcl/generic/glyphs/gcach_ftyp.cxx
index 75564d18b999..13e6aa98dd49 100644
--- a/vcl/generic/glyphs/gcach_ftyp.cxx
+++ b/vcl/generic/glyphs/gcach_ftyp.cxx
@@ -135,9 +135,8 @@ void (*pFTEmbolden)(FT_GlyphSlot);
static FT_UInt (*pFT_Face_GetCharVariantIndex)(FT_Face, FT_ULong, FT_ULong);
static bool bEnableSizeFT = false;
-struct EqStr{ bool operator()(const char* a, const char* b) const { return !strcmp(a,b); } };
-struct HashStr { size_t operator()( const char* s ) const { return rtl_str_hashCode(s); } };
-typedef ::boost::unordered_map<const char*,boost::shared_ptr<FtFontFile>,HashStr, EqStr> FontFileList;
+typedef ::boost::unordered_map<const char*, boost::shared_ptr<FtFontFile>, rtl::CStringHash, rtl::CStringEqual> FontFileList;
+
namespace { struct vclFontFileList : public rtl::Static< FontFileList, vclFontFileList > {}; }
// -----------------------------------------------------------------------
diff --git a/xmloff/source/draw/EnhancedCustomShapeToken.cxx b/xmloff/source/draw/EnhancedCustomShapeToken.cxx
index 6f9c520e0211..d9c45ea1698a 100644
--- a/xmloff/source/draw/EnhancedCustomShapeToken.cxx
+++ b/xmloff/source/draw/EnhancedCustomShapeToken.cxx
@@ -24,21 +24,7 @@
namespace xmloff { namespace EnhancedCustomShapeToken {
-struct THash
-{
- size_t operator()( const char* s ) const
- {
- return rtl_str_hashCode(s);
- }
-};
-struct TCheck
-{
- bool operator()( const char* s1, const char* s2 ) const
- {
- return strcmp( s1, s2 ) == 0;
- }
-};
-typedef boost::unordered_map< const char*, EnhancedCustomShapeTokenEnum, THash, TCheck> TypeNameHashMap;
+typedef boost::unordered_map< const char*, EnhancedCustomShapeTokenEnum, rtl::CStringHash, rtl::CStringEqual> TypeNameHashMap;
static TypeNameHashMap* pHashMap = NULL;
static ::osl::Mutex& getHashMapMutex()
{