[Lemon-commits] Alpar Juttner: Merge

Lemon HG hg at lemon.cs.elte.hu
Fri Feb 20 23:02:43 CET 2009


details:   http://lemon.cs.elte.hu/hg/lemon/rev/2b6d5d22bb23
changeset: 531:2b6d5d22bb23
user:      Alpar Juttner <alpar [at] cs.elte.hu>
date:      Fri Feb 20 21:37:19 2009 +0000
description:
	Merge

diffstat:

12 files changed, 249 insertions(+), 397 deletions(-)
.hgignore                |    1 
CMakeLists.txt           |    3 
configure.ac             |    8 +
lemon/bits/default_map.h |    2 
lemon/bits/windows.cc    |   34 +++---
lemon/config.h.cmake     |    7 -
lemon/config.h.in        |    3 
lemon/lgf_reader.h       |  136 +++++++++++++++------------
lemon/lgf_writer.h       |  154 ++++++++++++++++++-------------
lemon/path.h             |   42 +++++---
lemon/random.h           |   28 +----
lemon/tolerance.h        |  228 +---------------------------------------------

diffs (truncated from 953 to 300 lines):

diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -22,6 +22,7 @@
 lemon/libemon.la
 lemon/stamp-h2
 doc/Doxyfile
+cmake/cmake.version
 .dirstamp
 .libs/*
 .deps/*
diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -32,6 +32,9 @@
   SET(HAVE_GLPK TRUE)
 ENDIF(GLPK_FOUND)
 
+INCLUDE(CheckTypeSize)
+CHECK_TYPE_SIZE("long long" LONG_LONG)
+
 ENABLE_TESTING()
 
 ADD_SUBDIRECTORY(lemon)
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -22,6 +22,12 @@
 dnl Do compilation tests using the C++ compiler.
 AC_LANG([C++])
 
+dnl Check the existence of long long type.
+AC_CHECK_TYPE(long long, [long_long_found=yes], [long_long_found=no])
+if test x"$long_long_found" = x"yes"; then
+  AC_DEFINE([HAVE_LONG_LONG], [1], [Define to 1 if you have long long.])
+fi
+
 dnl Checks for programs.
 AC_PROG_CXX
 AC_PROG_CXXCPP
@@ -119,6 +125,8 @@
 echo C++ compiler.................. : $CXX
 echo C++ compiles flags............ : $WARNINGCXXFLAGS $CXXFLAGS
 echo
+echo Compiler supports long long... : $long_long_found
+echo
 echo GLPK support.................. : $lx_glpk_found
 echo CPLEX support................. : $lx_cplex_found
 echo SOPLEX support................ : $lx_soplex_found
diff --git a/lemon/bits/default_map.h b/lemon/bits/default_map.h
--- a/lemon/bits/default_map.h
+++ b/lemon/bits/default_map.h
@@ -96,7 +96,7 @@
   };
 
 
-#if defined __GNUC__ && !defined __STRICT_ANSI__
+#if defined HAVE_LONG_LONG
 
   // long long
   template <typename _Graph, typename _Item>
diff --git a/lemon/bits/windows.cc b/lemon/bits/windows.cc
--- a/lemon/bits/windows.cc
+++ b/lemon/bits/windows.cc
@@ -28,7 +28,15 @@
 #ifndef NOMINMAX
 #define NOMINMAX
 #endif
+#ifdef UNICODE
+#undef UNICODE
+#endif
 #include <windows.h>
+#ifdef LOCALE_INVARIANT
+#define MY_LOCALE LOCALE_INVARIANT
+#else
+#define MY_LOCALE LOCALE_NEUTRAL
+#endif
 #else
 #include <unistd.h>
 #include <ctime>
@@ -87,27 +95,15 @@
 #ifdef WIN32
       SYSTEMTIME time;
       GetSystemTime(&time);
-#if defined(_MSC_VER) && (_MSC_VER < 1500)
-      LPWSTR buf1, buf2, buf3;
-      if (GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
-                        L"ddd MMM dd", buf1, 11) &&
-          GetTimeFormat(LOCALE_USER_DEFAULT, 0, &time,
-                        L"HH':'mm':'ss", buf2, 9) &&
-          GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
-                        L"yyyy", buf3, 5)) {
+      char buf1[11], buf2[9], buf3[5];
+	  if (GetDateFormat(MY_LOCALE, 0, &time,
+                        ("ddd MMM dd"), buf1, 11) &&
+          GetTimeFormat(MY_LOCALE, 0, &time,
+                        ("HH':'mm':'ss"), buf2, 9) &&
+          GetDateFormat(MY_LOCALE, 0, &time,
+                        ("yyyy"), buf3, 5)) {
         os << buf1 << ' ' << buf2 << ' ' << buf3;
       }
-#else
-      char buf1[11], buf2[9], buf3[5];
-      if (GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
-                        "ddd MMM dd", buf1, 11) &&
-          GetTimeFormat(LOCALE_USER_DEFAULT, 0, &time,
-                        "HH':'mm':'ss", buf2, 9) &&
-          GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
-                        "yyyy", buf3, 5)) {
-        os << buf1 << ' ' << buf2 << ' ' << buf3;
-      }
-#endif
       else os << "unknown";
 #else
       timeval tv;
diff --git a/lemon/config.h.cmake b/lemon/config.h.cmake
--- a/lemon/config.h.cmake
+++ b/lemon/config.h.cmake
@@ -1,3 +1,4 @@
-#cmakedefine HAVE_LP 1
-#cmakedefine HAVE_MIP 1
-#cmakedefine HAVE_GLPK 1
+#cmakedefine HAVE_LONG_LONG 1
+#cmakedefine HAVE_LP 1
+#cmakedefine HAVE_MIP 1
+#cmakedefine HAVE_GLPK 1
diff --git a/lemon/config.h.in b/lemon/config.h.in
--- a/lemon/config.h.in
+++ b/lemon/config.h.in
@@ -1,3 +1,6 @@
+/* Define to 1 if you have long long */
+#undef HAVE_LONG_LONG
+
 /* Define to 1 if you have any LP solver. */
 #undef HAVE_LP
 
diff --git a/lemon/lgf_reader.h b/lemon/lgf_reader.h
--- a/lemon/lgf_reader.h
+++ b/lemon/lgf_reader.h
@@ -390,37 +390,13 @@
   template <typename Digraph>
   class DigraphReader;
 
-  /// \brief Return a \ref DigraphReader class
-  ///
-  /// This function just returns a \ref DigraphReader class.
-  /// \relates DigraphReader
   template <typename Digraph>
-  DigraphReader<Digraph> digraphReader(Digraph& digraph,
-                                       std::istream& is = std::cin) {
-    DigraphReader<Digraph> tmp(digraph, is);
-    return tmp;
-  }
-
-  /// \brief Return a \ref DigraphReader class
-  ///
-  /// This function just returns a \ref DigraphReader class.
-  /// \relates DigraphReader
+  DigraphReader<Digraph> digraphReader(Digraph& digraph, 
+                                       std::istream& is = std::cin);
   template <typename Digraph>
-  DigraphReader<Digraph> digraphReader(Digraph& digraph,
-                                       const std::string& fn) {
-    DigraphReader<Digraph> tmp(digraph, fn);
-    return tmp;
-  }
-
-  /// \brief Return a \ref DigraphReader class
-  ///
-  /// This function just returns a \ref DigraphReader class.
-  /// \relates DigraphReader
+  DigraphReader<Digraph> digraphReader(Digraph& digraph, const std::string& fn);
   template <typename Digraph>
-  DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) {
-    DigraphReader<Digraph> tmp(digraph, fn);
-    return tmp;
-  }
+  DigraphReader<Digraph> digraphReader(Digraph& digraph, const char *fn);
 
   /// \ingroup lemon_io
   ///
@@ -584,12 +560,13 @@
 
   private:
 
-    friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
-                                                  std::istream& is);
-    friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
-                                                  const std::string& fn);
-    friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
-                                                  const char *fn);
+    template <typename DGR>
+    friend DigraphReader<DGR> digraphReader(DGR& digraph, std::istream& is);
+    template <typename DGR>
+    friend DigraphReader<DGR> digraphReader(DGR& digraph, 
+                                            const std::string& fn);
+    template <typename DGR>
+    friend DigraphReader<DGR> digraphReader(DGR& digraph, const char *fn);
 
     DigraphReader(DigraphReader& other)
       : _is(other._is), local_is(other.local_is), _digraph(other._digraph),
@@ -1212,39 +1189,48 @@
 
   };
 
-  template <typename Graph>
-  class GraphReader;
-
-  /// \brief Return a \ref GraphReader class
+  /// \brief Return a \ref DigraphReader class
   ///
-  /// This function just returns a \ref GraphReader class.
-  /// \relates GraphReader
-  template <typename Graph>
-  GraphReader<Graph> graphReader(Graph& graph, std::istream& is = std::cin) {
-    GraphReader<Graph> tmp(graph, is);
+  /// This function just returns a \ref DigraphReader class.
+  /// \relates DigraphReader
+  template <typename Digraph>
+  DigraphReader<Digraph> digraphReader(Digraph& digraph, std::istream& is) {
+    DigraphReader<Digraph> tmp(digraph, is);
     return tmp;
   }
 
-  /// \brief Return a \ref GraphReader class
+  /// \brief Return a \ref DigraphReader class
   ///
-  /// This function just returns a \ref GraphReader class.
-  /// \relates GraphReader
-  template <typename Graph>
-  GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) {
-    GraphReader<Graph> tmp(graph, fn);
+  /// This function just returns a \ref DigraphReader class.
+  /// \relates DigraphReader
+  template <typename Digraph>
+  DigraphReader<Digraph> digraphReader(Digraph& digraph,
+                                       const std::string& fn) {
+    DigraphReader<Digraph> tmp(digraph, fn);
     return tmp;
   }
 
-  /// \brief Return a \ref GraphReader class
+  /// \brief Return a \ref DigraphReader class
   ///
-  /// This function just returns a \ref GraphReader class.
-  /// \relates GraphReader
-  template <typename Graph>
-  GraphReader<Graph> graphReader(Graph& graph, const char* fn) {
-    GraphReader<Graph> tmp(graph, fn);
+  /// This function just returns a \ref DigraphReader class.
+  /// \relates DigraphReader
+  template <typename Digraph>
+  DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) {
+    DigraphReader<Digraph> tmp(digraph, fn);
     return tmp;
   }
 
+  template <typename Graph>
+  class GraphReader;
+ 
+  template <typename Graph>
+  GraphReader<Graph> graphReader(Graph& graph, 
+                                 std::istream& is = std::cin);
+  template <typename Graph>
+  GraphReader<Graph> graphReader(Graph& graph, const std::string& fn);
+  template <typename Graph>
+  GraphReader<Graph> graphReader(Graph& graph, const char *fn);
+
   /// \ingroup lemon_io
   ///
   /// \brief \ref lgf-format "LGF" reader for undirected graphs
@@ -1370,10 +1356,12 @@
     }
 
   private:
-    friend GraphReader<Graph> graphReader<>(Graph& graph, std::istream& is);
-    friend GraphReader<Graph> graphReader<>(Graph& graph,
-                                            const std::string& fn);
-    friend GraphReader<Graph> graphReader<>(Graph& graph, const char *fn);
+    template <typename GR>
+    friend GraphReader<GR> graphReader(GR& graph, std::istream& is);
+    template <typename GR>
+    friend GraphReader<GR> graphReader(GR& graph, const std::string& fn); 
+    template <typename GR>
+    friend GraphReader<GR> graphReader(GR& graph, const char *fn);
 
     GraphReader(GraphReader& other)
       : _is(other._is), local_is(other.local_is), _graph(other._graph),
@@ -2044,6 +2032,36 @@
 
   };
 
+  /// \brief Return a \ref GraphReader class
+  ///
+  /// This function just returns a \ref GraphReader class.
+  /// \relates GraphReader
+  template <typename Graph>
+  GraphReader<Graph> graphReader(Graph& graph, std::istream& is) {
+    GraphReader<Graph> tmp(graph, is);
+    return tmp;



More information about the Lemon-commits mailing list