]> git.lyx.org Git - lyx.git/blobdiff - src/support/translator.h
fix compiler warnings about unused parameter
[lyx.git] / src / support / translator.h
index bdd9d83434b5fa75315171fe3ea9c93fc4f36bc9..005caef2ab6107e66cb268083685a416ecf318af 100644 (file)
@@ -6,19 +6,23 @@
  *
  * \author Baruch Even
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #ifndef TRANSLATOR_H
 #define TRANSLATOR_H
 
+#include <boost/assert.hpp>
+#include <boost/bind.hpp>
+
 #include <vector>
 #include <utility>
 #include <algorithm>
 #include <functional>
 
-#include "support/LAssert.h"
-#include "support/lyxfunctional.h"
+
+namespace lyx {
+
 /**
  * This class template is used to translate between two elements, specifically
  * it was worked out to translate between an enum and strings when reading
@@ -47,15 +51,23 @@ public:
        void addPair(T1 const & first, T2 const & second) {
                map.push_back(MapPair(first, second));
        }
+       // Add the contents of \c other
+       void add(Translator const & other) {
+               if (other.map.empty())
+                       return;
+               map.insert(map.end(), other.map.begin(), other.map.end());
+       }
 
        /// Find the mapping for the first argument
        T2 const & find(T1 const & first) const {
-               Assert(!map.empty());
+               BOOST_ASSERT(!map.empty());
 
                // For explanation see the next find() function.
                typename Map::const_iterator it =
                        std::find_if(map.begin(), map.end(),
-                                    lyx::equal_1st_in_pair<MapPair>(first)
+                                    boost::bind(std::equal_to<T1>(),
+                                                boost::bind(&MapPair::first, _1),
+                                                first)
                                );
 
                if (it != map.end()) {
@@ -67,7 +79,7 @@ public:
 
        /// Find the mapping for the second argument
        T1 const & find(T2 const & second) const {
-               Assert(!map.empty());
+               BOOST_ASSERT(!map.empty());
 
                // The idea is as follows:
                // find_if() will try to compare the data in the vector with
@@ -82,7 +94,9 @@ public:
                // equal_to(select2nd(pair) , second)
                typename Map::const_iterator it =
                        std::find_if(map.begin(), map.end(),
-                                    lyx::equal_2nd_in_pair<MapPair>(second)
+                                    boost::bind(std::equal_to<T2>(),
+                                                boost::bind(&MapPair::second, _1),
+                                                second)
                                );
 
                if (it != map.end())
@@ -100,4 +114,7 @@ private:
        T2 const default_t2;
 };
 
+
+} // namespace lyx
+
 #endif // TRANSLATOR_H