* mln/convert/from_to.hxx: Add forward declarations.
* mln/convert/impl/all.hh: Include from_to_builtins.hh.
* mln/convert/impl/from_to_builtins.hh: New. Add new from_to
overloads for builtin types.
---
milena/ChangeLog | 11 +++
milena/mln/convert/from_to.hxx | 17 ++++-
milena/mln/convert/impl/all.hh | 4 +-
.../{from_int_to_value.hh => from_to_builtins.hh} | 82 ++++++++------------
4 files changed, 61 insertions(+), 53 deletions(-)
copy milena/mln/convert/impl/{from_int_to_value.hh => from_to_builtins.hh} (56%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 23fa923..7268baf 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,14 @@
+2011-01-13 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Add more from_to overloads.
+
+ * mln/convert/from_to.hxx: Add forward declarations.
+
+ * mln/convert/impl/all.hh: Include from_to_builtins.hh.
+
+ * mln/convert/impl/from_to_builtins.hh: New. Add new from_to
+ overloads for builtin types.
+
2010-04-07 Guillaume Lazzara <z(a)lrde.epita.fr>
Add an image loader in the anapath GUI.
diff --git a/milena/mln/convert/from_to.hxx b/milena/mln/convert/from_to.hxx
index cc7cc15..b6ecfc5 100644
--- a/milena/mln/convert/from_to.hxx
+++ b/milena/mln/convert/from_to.hxx
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2010 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2010, 2011 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -211,6 +211,21 @@ namespace mln
template <unsigned n>
void from_to_(const value::int_u<n>& from, double& to_);
+ /// float -> double
+ template <typename V>
+ void
+ from_to(const float& from, double& to);
+
+ /// bool -> double
+ template <typename V>
+ void
+ from_to(const bool& from, double& to);
+
+ /// unsigned -> double
+ template <typename V>
+ void
+ from_to(const unsigned& from, double& to);
+
// label -> int_u.
template <unsigned n>
void
diff --git a/milena/mln/convert/impl/all.hh b/milena/mln/convert/impl/all.hh
index 7c3405b..10a98ed 100644
--- a/milena/mln/convert/impl/all.hh
+++ b/milena/mln/convert/impl/all.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -36,6 +37,7 @@
# include <mln/convert/impl/from_image_to_site_set.hh>
# include <mln/convert/impl/from_int_to_value.hh>
# include <mln/convert/impl/from_site_set_to_image.hh>
+# include <mln/convert/impl/from_to_builtins.hh>
# include <mln/convert/impl/from_unsigned_to_value.hh>
# include <mln/convert/impl/from_value_to_value.hh>
diff --git a/milena/mln/convert/impl/from_int_to_value.hh
b/milena/mln/convert/impl/from_to_builtins.hh
similarity index 56%
copy from milena/mln/convert/impl/from_int_to_value.hh
copy to milena/mln/convert/impl/from_to_builtins.hh
index 30840b3..ddad7b9 100644
--- a/milena/mln/convert/impl/from_int_to_value.hh
+++ b/milena/mln/convert/impl/from_to_builtins.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,89 +23,69 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_CONVERT_IMPL_FROM_INT_TO_VALUE_HH
-# define MLN_CONVERT_IMPL_FROM_INT_TO_VALUE_HH
+#ifndef MLN_CONVERT_IMPL_FROM_TO_BUILTINS_HH
+# define MLN_CONVERT_IMPL_FROM_TO_BUILTINS_HH
/// \file
///
-/// General conversion procedure from a int to a value.
+/// Conversion procedure from builtins to builtins.
///
/// \todo Augment code + add checks.
-# include <utility>
-# include <mln/value/concept/integer.hh>
-# include <mln/core/concept/value.hh>
-# include <mln/math/round.hh>
-
-
-
-
namespace mln
{
namespace convert
{
- /// Conversion of a int \p from towards a value \p to.
+ /// Conversion of a float \p from towards a double \p to.
+ template <typename V>
+ void
+ from_to(const float& from, double& to);
+
+ /// Conversion of a bool \p from towards a double \p to.
template <typename V>
void
- from_to(const int& from, Value<V>& to);
+ from_to(const bool& from, double& to);
+
+ /// Conversion of an unsigned \p from towards a double \p to.
+ template <typename V>
+ void
+ from_to(const unsigned& from, double& to);
# ifndef MLN_INCLUDE_ONLY
- namespace impl
+ namespace over_load
{
- // Case 1:
-
- template <typename V>
- inline
- void
- from_int_to_value(const int& from,
- mln::value::Integer<V>& to)
- {
- exact(to) = from;
- }
+ // Facades.
- // Default: no conversion defined.
- template <typename V>
+ // float->double
inline
void
- from_int_to_value(const int& from,
- Value<V>& to)
+ from_to_(const float& from, double& to)
{
- mlc_abort(V)::check();
+ to = from;
}
- } // end of namespace mln::convert::impl
-
-
- namespace internal
- {
-
- template <typename V>
+ // bool->double
inline
void
- from_int_to_value_dispatch(const int& from, Value<V>& to)
+ from_to_(const bool& from,
+ double& to)
{
- impl::from_int_to_value(from, exact(to));
+ to = from;
}
- } // end of namespace mln::convert::internal
-
-
- namespace over_load
- {
-
- // Facades.
- // int-> Value
- template <typename V>
+ // unsigned->double
+ inline
void
- from_to_(const int& from, Value<V>& to)
+ from_to_(const unsigned& from,
+ double& to)
{
- internal::from_int_to_value_dispatch(from, to);
+ to = from;
}
} // end of namespace mln::convert::over_load
@@ -117,4 +97,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_CONVERT_IMPL_FROM_INT_TO_VALUE_HH
+#endif // ! MLN_CONVERT_IMPL_FROM_TO_BUILTINS_HH
--
1.5.6.5
Show replies by date