Commit 5c414c5d authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

Fix invalid value type names in dump format.

	* milena/mln/value/internal/make_generic_name.hh: New.

	* milena/mln/value/int_u.hh,
	* milena/mln/value/label.hh,
	* milena/mln/value/rgb.hh: Make use of the new routine to print a
	correct type names in dump format.
parent c9b6114c
2010-02-16 Guillaume Lazzara <z@lrde.epita.fr>
Fix invalid value type names in dump format.
* milena/mln/value/internal/make_generic_name.hh: New.
* milena/mln/value/int_u.hh,
* milena/mln/value/label.hh,
* milena/mln/value/rgb.hh: Make use of the new routine to print a
correct type names in dump format.
2009-11-18 Guillaume Lazzara <z@lrde.epita.fr>
 
* doc/white_paper/white_paper.tex: Fix an invalid URL.
// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
//
......@@ -41,6 +42,7 @@
# include <mln/trait/value_.hh>
# include <mln/debug/format.hh>
# include <mln/value/internal/make_generic_name.hh>
namespace mln
......@@ -98,7 +100,8 @@ namespace mln
static const char* name()
{
static std::string s = std::string("int_u").append(1, n + '0');
static std::string
s = mln::value::internal::make_generic_name("int_u", n);
return s.c_str();
}
......@@ -107,6 +110,23 @@ namespace mln
} // end of namespace mln::trait
namespace convert
{
namespace over_load
{
// int_u -> unsigned.
template <unsigned n>
void
from_to_(const value::int_u<n>& from, unsigned& to_);
} // end of namespace mln::convert::over_load
} // end of namespace mln::convert
namespace value
{
......@@ -178,9 +198,33 @@ namespace mln
template <unsigned n>
std::istream& operator>>(std::istream& istr, int_u<n>& i);
} // end of namespace mln::value
# ifndef MLN_INCLUDE_ONLY
namespace convert
{
namespace over_load
{
// int_u -> unsigned.
template <unsigned n>
inline
void
from_to_(const value::int_u<n>& from, unsigned& to_)
{
to_ = from;
}
} // end of namespace mln::convert::over_load
} // end of namespace mln::convert
namespace value
{
template <unsigned n>
inline
int_u<n>::int_u()
......@@ -277,11 +321,12 @@ namespace mln
return istr >> i.handle_();
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::value
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
#endif // ! MLN_VALUE_INT_U_HH
// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
// Olena is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation, version 2 of the License.
//
// Olena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
//
// As a special exception, you may use this file as part of a free
// software project without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to produce
// an executable, this file does not by itself cause the resulting
// executable to be covered by the GNU General Public License. This
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
#ifndef MLN_VALUE_INTERNAL_MAKE_GENERIC_NAME_HH
# define MLN_VALUE_INTERNAL_MAKE_GENERIC_NAME_HH
/// \file
///
/// Construct a type name as string.
# include <cstring>
# include <sstream>
namespace mln
{
namespace value
{
namespace internal
{
/// Construct a type name as string.
std::string make_generic_name(const char *name, int quantification);
# ifndef MLN_INCLUDE_ONLY
std::string make_generic_name(const char *name, int quantification)
{
std::stringstream out;
out << name;
out << quantification;
return out.str();
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::value::internal
} // end of namespace mln::value
} // end of namespace mln
#endif // ! MLN_VALUE_INTERNAL_MAKE_GENERIC_NAME_HH
// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
//
......@@ -38,6 +39,7 @@
# include <mln/value/internal/convert.hh>
# include <mln/value/internal/encoding.hh>
# include <mln/value/internal/make_generic_name.hh>
namespace mln
{
......@@ -79,7 +81,8 @@ namespace mln
static const char* name()
{
static std::string s = std::string("label_").append(1, n + '0');
static std::string
s = mln::value::internal::make_generic_name("label_", n);
return s.c_str();
}
......@@ -100,6 +103,12 @@ namespace mln
void
from_to_(const value::int_u<n>& from, value::label<n>& to_);
// label -> int_u.
template <unsigned n>
void
from_to_(const value::label<n>& from, value::int_u<n>& to_);
// int_u -> label.
template <unsigned n, unsigned m>
void
......@@ -204,6 +213,15 @@ namespace mln
to_ = from;
}
// label -> int_u.
template <unsigned n>
void
from_to_(const value::label<n>& from, value::int_u<n>& to_)
{
to_ = from;
}
// int_u<n> -> label<m> with n < m.
template <unsigned n, unsigned m>
inline
......
// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
//
......@@ -34,6 +35,8 @@
# include <mln/value/int_u.hh>
# include <mln/algebra/vec.hh>
# include <mln/value/internal/make_generic_name.hh>
namespace mln
{
......@@ -220,7 +223,8 @@ namespace mln
static const char* name()
{
static std::string s = std::string("rgb").append(1, n + '0');
static std::string
s = mln::value::internal::make_generic_name("rgb", n);
return s.c_str();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment