last-svn-commit-184-g77dbb2b Fix output streams uses.

* mln/core/concept/value_set.hh (operator<<(std::ostream&, const Value_Set<E>&)) * mln/morpho/tree/data.hh (operator<< (std::ostream&, const tree::data<I, S>&)): Use the stream passed as argument instead of std::cout. * mln/util/fibonacci_heap.hh (mln::util::internal::fibonacci_heap_node::print_): Take an output stream as argument instead of using the standard output. (mln::util::fibonacci_heap::print_): Rename first argument from `cout' to `ostr' prevent confusions with std::cout. * mln/trace/warning.hh (mln::trace::warning): Print warnings on the standard error instead of the standard ourput. --- milena/ChangeLog | 17 ++++++++++++++ milena/mln/core/concept/value_set.hh | 5 ++- milena/mln/morpho/tree/data.hh | 5 ++- milena/mln/trace/warning.hh | 10 ++++---- milena/mln/util/fibonacci_heap.hh | 40 +++++++++++++++++----------------- 5 files changed, 48 insertions(+), 29 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index b4e98cd..dda6e2c 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,20 @@ +2010-07-29 Roland Levillain <roland@lrde.epita.fr> + + Fix output streams uses. + + * mln/core/concept/value_set.hh + (operator<<(std::ostream&, const Value_Set<E>&)) + * mln/morpho/tree/data.hh + (operator<< (std::ostream&, const tree::data<I, S>&)): + Use the stream passed as argument instead of std::cout. + * mln/util/fibonacci_heap.hh + (mln::util::internal::fibonacci_heap_node::print_): Take an output + stream as argument instead of using the standard output. + (mln::util::fibonacci_heap::print_): Rename first argument from + `cout' to `ostr' prevent confusions with std::cout. + * mln/trace/warning.hh (mln::trace::warning): Print warnings on + the standard error instead of the standard ourput. + 2010-07-19 Roland Levillain <roland@lrde.epita.fr> Fix and improve the Magick++ I/O API wrapper. diff --git a/milena/mln/core/concept/value_set.hh b/milena/mln/core/concept/value_set.hh index 83f9911..b047ab0 100644 --- a/milena/mln/core/concept/value_set.hh +++ b/milena/mln/core/concept/value_set.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2007, 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2007, 2009, 2010 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -104,7 +105,7 @@ namespace mln const E& vs = exact(vs_); ostr << "{ "; for (unsigned i = 0; i < vs.nvalues(); ++i) - std::cout << vs[i] << ' '; + ostr << vs[i] << ' '; return ostr << '}'; } diff --git a/milena/mln/morpho/tree/data.hh b/milena/mln/morpho/tree/data.hh index 91f69ec..1a0c404 100644 --- a/milena/mln/morpho/tree/data.hh +++ b/milena/mln/morpho/tree/data.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2008, 2009, 2010 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -744,7 +745,7 @@ namespace mln typename self_t::depth1st_piter n(t); mln_psite(self_t) old; - std::cout << std::endl << "Hierarchy: " << std::endl; + os << std::endl << "Hierarchy: " << std::endl; n.start(); if (!n.is_valid()) diff --git a/milena/mln/trace/warning.hh b/milena/mln/trace/warning.hh index c06fd7f..01a82a2 100644 --- a/milena/mln/trace/warning.hh +++ b/milena/mln/trace/warning.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2008, 2009, 2010 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -30,8 +31,8 @@ /// /// Display warning message in trace output. -# include <string> # include <iostream> +# include <string> # include <mln/trace/quiet.hh> @@ -44,14 +45,13 @@ namespace mln void warning(const std::string& message); + # ifndef MLN_INCLUDE_ONLY inline void warning(const std::string& message) { - std::cout << "Warning: " - << message - << std::endl; + std::cerr << "Warning: " << message << std::endl; } # endif // ! MLN_INCLUDE_ONLY diff --git a/milena/mln/util/fibonacci_heap.hh b/milena/mln/util/fibonacci_heap.hh index 9742edf..daec0a1 100644 --- a/milena/mln/util/fibonacci_heap.hh +++ b/milena/mln/util/fibonacci_heap.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory (LRDE) // // This file is part of Olena. // @@ -87,7 +87,7 @@ namespace mln bool operator==(fibonacci_heap_node<P,T>& rhs); bool operator<(fibonacci_heap_node<P,T>& rhs); - void print_() const; + void print_(std::ostream& ostr) const; private: @@ -164,7 +164,7 @@ namespace mln - std::ostream& print_(std::ostream& cout, + std::ostream& print_(std::ostream& ostr, internal::fibonacci_heap_node<P,T> *tree = 0, internal::fibonacci_heap_node<P,T> *parent = 0) const; @@ -245,7 +245,7 @@ namespace mln template <typename P, typename T> std::ostream& - operator<<(std::ostream& cout, const fibonacci_heap<P,T>& heap); + operator<<(std::ostream& ostr, const fibonacci_heap<P,T>& heap); @@ -453,9 +453,9 @@ namespace mln template <typename P, typename T> inline - void fibonacci_heap_node<P,T>::print_() const + void fibonacci_heap_node<P,T>::print_(std::ostream& ostr) const { - std::cout << value_ << " (" << priority_ << ")"; + ostr << value_ << " (" << priority_ << ")"; } @@ -767,7 +767,7 @@ namespace mln template <typename P, typename T> std::ostream& - fibonacci_heap<P,T>::print_(std::ostream& cout, + fibonacci_heap<P,T>::print_(std::ostream& ostr, internal::fibonacci_heap_node<P,T> *tree, internal::fibonacci_heap_node<P,T> *parent) const { @@ -781,38 +781,38 @@ namespace mln { do { if (temp->left() == 0) - cout << "(left is 0)"; + ostr << "(left is 0)"; temp->print_(); if (temp->parent() != parent) - cout << "(parent is incorrect)"; + ostr << "(parent is incorrect)"; if (temp->right() == 0) - cout << "(right is 0)"; + ostr << "(right is 0)"; else if (temp->right()->left() != temp) - cout << "(Error in left link left) ->"; + ostr << "(Error in left link left) ->"; else - cout << " <-> "; + ostr << " <-> "; temp = temp->right(); } while (temp != 0 && temp != tree); } else - cout << " <empty>" << std::endl; - cout << std::endl; + ostr << " <empty>" << std::endl; + ostr << std::endl; temp = tree; if (temp != 0) { do { - cout << "children of " << temp->value() << ": "; + ostr << "children of " << temp->value() << ": "; if (temp->child() == 0) - cout << "NONE" << std::endl; - else print_(cout, temp->child(), temp); + ostr << "NONE" << std::endl; + else print_(ostr, temp->child(), temp); temp = temp->right(); } while (temp!=0 && temp != tree); } - return cout; + return ostr; } @@ -1029,9 +1029,9 @@ namespace mln template <typename P, typename T> std::ostream& - operator<<(std::ostream& cout, const fibonacci_heap<P,T>& heap) + operator<<(std::ostream& ostr, const fibonacci_heap<P,T>& heap) { - return heap.print_(cout); + return heap.print_(ostr); } # endif // ! MLN_INCLUDE_ONLY -- 1.5.6.5
participants (1)
-
Roland Levillain