]> git.lyx.org Git - lyx.git/blobdiff - src/support/translator.h
* lyxfunctional.h: delete compare_memfun and helper classes
[lyx.git] / src / support / translator.h
index 756c3e0c1dfd65402fab072c9453c9cbd15fc150..4d4020dafa8c4a1977d1ec9ee6d275fcfafda374 100644 (file)
@@ -1,30 +1,32 @@
 // -*- C++ -*-
-/* This file is part of
- * =================================================
+/**
+ * \file translator.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- *          LyX, The Document Processor
- *          Copyright 1995 Matthias Ettrich.
- *          Copyright 1995-2001 The LyX Team.
+ * \author Baruch Even
  *
- *          This file Copyright 2000 Baruch Even
- * ================================================= */
+ * Full author contact details are available in file CREDITS.
+ */
 
 #ifndef TRANSLATOR_H
 #define TRANSLATOR_H
 
+#include <boost/assert.hpp>
+
 #include <vector>
 #include <utility>
 #include <algorithm>
 #include <functional>
 
-#include "support/LAssert.h"
 #include "support/lyxfunctional.h"
-/** This class template is used to translate between two elements, specifically
-    it was worked out to translate between an enum and strings when reading
-    the lyx file.
-
-    The two template arguments should be of different types.
-*/
+/**
+ * This class template is used to translate between two elements, specifically
+ * it was worked out to translate between an enum and strings when reading
+ * the lyx file.
+ *
+ * The two template arguments should be of different types.
+ */
 template<typename T1, typename T2>
 class Translator {
 public:
@@ -46,10 +48,16 @@ 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 {
-               lyx::Assert(!map.empty());
+               BOOST_ASSERT(!map.empty());
 
                // For explanation see the next find() function.
                typename Map::const_iterator it =
@@ -66,7 +74,7 @@ public:
 
        /// Find the mapping for the second argument
        T1 const & find(T2 const & second) const {
-               lyx::Assert(!map.empty());
+               BOOST_ASSERT(!map.empty());
 
                // The idea is as follows:
                // find_if() will try to compare the data in the vector with
@@ -99,4 +107,4 @@ private:
        T2 const default_t2;
 };
 
-#endif
+#endif // TRANSLATOR_H