
* mln/trace/warning.hh: new file. * mln/trace/all.hh: include warning.hh. * mln/trace/resume.hh, * mln/trace/stop.hh: cleanup includes. * mln/debug/put_word.hh: use trace::warning. --- milena/ChangeLog | 14 ++++++++++++++ milena/mln/debug/put_word.hh | 5 +++-- milena/mln/trace/all.hh | 1 + milena/mln/trace/resume.hh | 3 --- milena/mln/trace/stop.hh | 1 - milena/mln/trace/{stop.hh => warning.hh} | 24 ++++++++++++------------ 6 files changed, 30 insertions(+), 18 deletions(-) copy milena/mln/trace/{stop.hh => warning.hh} (78%) diff --git a/milena/ChangeLog b/milena/ChangeLog index 151dd22..80c3f74 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,17 @@ +2008-11-03 Guillaume Lazzara <z@lrde.epita.fr> + + Add trace::warning. + + * mln/trace/warning.hh: new file. + + * mln/trace/all.hh: include warning.hh. + + * mln/trace/resume.hh, + * mln/trace/stop.hh: cleanup includes. + + * mln/debug/put_word.hh: use trace::warning. + + 2008-10-30 Guillaume Lazzara <z@lrde.epita.fr> Improve trace output. diff --git a/milena/mln/debug/put_word.hh b/milena/mln/debug/put_word.hh index 4380e8d..d494c89 100644 --- a/milena/mln/debug/put_word.hh +++ b/milena/mln/debug/put_word.hh @@ -63,11 +63,12 @@ namespace mln point2d word_end = word_start; word_end.last_coord() += word.length() - 1; - mln_precondition(inout.has(word_end)); + if (!inout.has(word_end)) + trace::warning("Cannot write text outside the image domain"); const unsigned n = word.length(); point2d p = word_start; - for (unsigned i = 0; i < n; ++i) + for (unsigned i = 0; i < n && inout.has(p); ++i) { inout(p) = word[i]; p += right; diff --git a/milena/mln/trace/all.hh b/milena/mln/trace/all.hh index 62b9a60..7380f31 100644 --- a/milena/mln/trace/all.hh +++ b/milena/mln/trace/all.hh @@ -48,6 +48,7 @@ namespace mln # include <mln/trace/exiting.hh> # include <mln/trace/stop.hh> # include <mln/trace/resume.hh> +# include <mln/trace/warning.hh> #endif // ! MLN_TRACE_ALL_HH diff --git a/milena/mln/trace/resume.hh b/milena/mln/trace/resume.hh index 3520bd6..7c789ff 100644 --- a/milena/mln/trace/resume.hh +++ b/milena/mln/trace/resume.hh @@ -33,9 +33,6 @@ /// Resume traces. /// \sa mln::trace::stop -# include <string> -# include <iostream> - # include <mln/trace/quiet.hh> diff --git a/milena/mln/trace/stop.hh b/milena/mln/trace/stop.hh index e810c97..4a53dc6 100644 --- a/milena/mln/trace/stop.hh +++ b/milena/mln/trace/stop.hh @@ -32,7 +32,6 @@ /// Stop printing traces except if trace::full_trace is enabled. /// \sa mln::trace::resume -# include <string> # include <iostream> # include <mln/trace/quiet.hh> diff --git a/milena/mln/trace/stop.hh b/milena/mln/trace/warning.hh similarity index 78% copy from milena/mln/trace/stop.hh copy to milena/mln/trace/warning.hh index e810c97..c130da6 100644 --- a/milena/mln/trace/stop.hh +++ b/milena/mln/trace/warning.hh @@ -16,7 +16,7 @@ // Boston, MA 02111-1307, USA. // // As a special exception, you may use this file as part of a free -// software library without restriction. Specificstopy, if other files +// software library without restriction. Specificwarningy, 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 @@ -25,12 +25,11 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef MLN_TRACE_STOP_HH -# define MLN_TRACE_STOP_HH +#ifndef MLN_TRACE_WARNING_HH +# define MLN_TRACE_WARNING_HH -/// \file mln/trace/stop.hh -/// Stop printing traces except if trace::full_trace is enabled. -/// \sa mln::trace::resume +/// \file mln/trace/warning.hh +/// Display warning message in trace output. # include <string> # include <iostream> @@ -44,16 +43,17 @@ namespace mln namespace trace { - void stop(); + void warning(const std::string& message); # ifndef MLN_INCLUDE_ONLY inline - void stop() + void warning(const std::string& message) { - internal::is_quiet = quiet; - if (!full_trace) - quiet = true; + if (!quiet) + std::cout << "Warning: " + << message + << std::endl; } # endif // ! MLN_INCLUDE_ONLY @@ -63,4 +63,4 @@ namespace mln } // end of namespace mln -#endif // ! MLN_TRACE_STOP_HH +#endif // ! MLN_TRACE_WARNING_HH -- 1.5.6.5