| 1 | /* melder_warning.cpp |
| 2 | * |
| 3 | * Copyright (C) 1992-2012,2014-2016,2018,2020 Paul Boersma |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or (at |
| 8 | * your option) any later version. |
| 9 | * |
| 10 | * This code is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 | * See the GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #include "melder.h" |
| 20 | |
| 21 | int MelderWarning::_depth = 0; |
| 22 | |
| 23 | void MelderWarning::_defaultProc (conststring32 message) { |
| 24 | MelderConsole::write (U"Warning: ", true); |
| 25 | MelderConsole::write (message, true); |
| 26 | MelderConsole::write (U"\n", true); |
| 27 | } |
| 28 | |
| 29 | MelderWarning::Proc MelderWarning::_p_currentProc = & MelderWarning::_defaultProc; |
| 30 | |
| 31 | MelderString MelderWarning::_buffer; |
| 32 | |
| 33 | void Melder_warningOff () { MelderWarning::_depth --; } |
| 34 | void Melder_warningOn () { MelderWarning::_depth ++; } |
| 35 | |
| 36 | void Melder_setWarningProc (MelderWarning::Proc p_proc) { |
| 37 | MelderWarning::_p_currentProc = ( p_proc ? p_proc : & MelderWarning::_defaultProc ); |
| 38 | } |
| 39 | |
| 40 | /* End of file melder_warning.cpp */ |