From 13952154a109a69f665a1549b613721384f2599f Mon Sep 17 00:00:00 2001 From: Bernhard Amann Date: Tue, 24 Jul 2012 09:19:20 -0700 Subject: [PATCH] add comparator functor to the info maps of readerbackend and readerwriteend. This is required, because after the recent changes the info map containst a char* as key. Without the comparator the map will compare the char addresses for all operations - which is not really what we want. --- src/input/ReaderBackend.h | 2 +- src/logging/WriterBackend.h | 2 +- src/util.h | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/input/ReaderBackend.h b/src/input/ReaderBackend.h index 7626cc25ed..8ee14c808a 100644 --- a/src/input/ReaderBackend.h +++ b/src/input/ReaderBackend.h @@ -74,7 +74,7 @@ public: struct ReaderInfo { // Structure takes ownership of the strings. - typedef std::map config_map; + typedef std::map config_map; /** * A string left to the interpretation of the reader diff --git a/src/logging/WriterBackend.h b/src/logging/WriterBackend.h index 1ca5650057..d5f2be225e 100644 --- a/src/logging/WriterBackend.h +++ b/src/logging/WriterBackend.h @@ -49,7 +49,7 @@ public: struct WriterInfo { // Structure takes ownership of these strings. - typedef std::map config_map; + typedef std::map config_map; /** * A string left to the interpretation of the writer diff --git a/src/util.h b/src/util.h index a695c6df6a..030a704092 100644 --- a/src/util.h +++ b/src/util.h @@ -345,4 +345,15 @@ inline int safe_vsnprintf(char* str, size_t size, const char* format, va_list al extern void get_memory_usage(unsigned int* total, unsigned int* malloced); +// class to be used as a third argument for stl maps to be able to use +// char*'s as keys. Otherwise the pointer values will be compared instead +// of the actual string values. +struct CompareString + { + bool operator()(char const *a, char const *b) const + { + return std::strcmp(a, b) < 0; + } + }; + #endif