1 | // ----------------------------------------------------------------------- |
---|
2 | // duchamp.cc: Warning and Error messages. |
---|
3 | // ----------------------------------------------------------------------- |
---|
4 | // Copyright (C) 2006, Matthew Whiting, ATNF |
---|
5 | // |
---|
6 | // This program is free software; you can redistribute it and/or modify it |
---|
7 | // under the terms of the GNU General Public License as published by the |
---|
8 | // Free Software Foundation; either version 2 of the License, or (at your |
---|
9 | // option) any later version. |
---|
10 | // |
---|
11 | // Duchamp is distributed in the hope that it will be useful, but WITHOUT |
---|
12 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
13 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
---|
14 | // for more details. |
---|
15 | // |
---|
16 | // You should have received a copy of the GNU General Public License |
---|
17 | // along with Duchamp; if not, write to the Free Software Foundation, |
---|
18 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA |
---|
19 | // |
---|
20 | // Correspondence concerning Duchamp may be directed to: |
---|
21 | // Internet email: Matthew.Whiting [at] atnf.csiro.au |
---|
22 | // Postal address: Dr. Matthew Whiting |
---|
23 | // Australia Telescope National Facility, CSIRO |
---|
24 | // PO Box 76 |
---|
25 | // Epping NSW 1710 |
---|
26 | // AUSTRALIA |
---|
27 | // ----------------------------------------------------------------------- |
---|
28 | #include <iostream> |
---|
29 | #include <iomanip> |
---|
30 | #include <string> |
---|
31 | #include <duchamp.hh> |
---|
32 | |
---|
33 | void duchampWarning(std::string subroutine, std::string warning) |
---|
34 | { |
---|
35 | /** |
---|
36 | * Prints a WARNING message to the standard error stream, quoting |
---|
37 | * the subroutine that the problem occurred in, and a descriptive |
---|
38 | * warning text. |
---|
39 | * |
---|
40 | * Format: WARNING \<function\> : Something happened that you should be aware of. |
---|
41 | */ |
---|
42 | std::string preamble = "WARNING <" + subroutine + "> : "; |
---|
43 | std::cerr << preamble; |
---|
44 | for(int i=0;i<warning.size();i++){ |
---|
45 | std::cerr << warning[i]; |
---|
46 | if((i!=warning.size()-1)&&(warning[i]=='\n')) |
---|
47 | std::cerr << std::setw(preamble.size()) <<": "; |
---|
48 | } |
---|
49 | } |
---|
50 | |
---|
51 | void duchampError(std::string subroutine, std::string error) |
---|
52 | { |
---|
53 | /** |
---|
54 | * Prints an ERROR message to the standard error stream, quoting |
---|
55 | * the subroutine that the problem occurred in, a descriptive |
---|
56 | * warning text, and sounding the bell. |
---|
57 | * |
---|
58 | * Format: ERROR \<function\> : Something bad happened. |
---|
59 | */ |
---|
60 | std::string preamble = "\aERROR <" + subroutine + "> : "; |
---|
61 | std::cerr << preamble; |
---|
62 | for(int i=0;i<error.size();i++){ |
---|
63 | std::cerr << error[i]; |
---|
64 | if((i!=error.size()-1)&&(error[i]=='\n')) |
---|
65 | std::cerr << std::setw(preamble.size()-1) <<": "; |
---|
66 | } |
---|
67 | } |
---|