source: trunk/src/duchamp.cc @ 541

Last change on this file since 541 was 541, checked in by MatthewWhiting, 15 years ago

Changing all calls of uint to unsigned int, as there are sometimes compilers that don't know about that typedef. Also added an include call for stdlib.h to fitsHeader.cc so that it knows about calloc.

File size: 2.6 KB
Line 
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/duchamp.hh>
32
33namespace duchamp
34{
35
36  void duchampWarning(std::string subroutine, std::string warning)
37  {
38    /**
39     * Prints a WARNING message to the standard error stream, quoting
40     * the subroutine that the problem occurred in, and a descriptive
41     * warning text.
42     *
43     * Format: WARNING \<function\> : Something happened that you should be aware of.
44     */
45    std::string preamble = "WARNING <" + subroutine + "> : ";
46    std::cerr << preamble;
47    for(unsigned int i=0;i<warning.size();i++){
48      std::cerr << warning[i];
49      if((i!=warning.size()-1)&&(warning[i]=='\n'))
50        std::cerr << std::setw(preamble.size()) <<": ";
51    }
52  }
53
54  void duchampError(std::string subroutine, std::string error)
55  {
56    /**
57     * Prints an ERROR message to the standard error stream, quoting
58     * the subroutine that the problem occurred in, a descriptive
59     * warning text, and sounding the bell.
60     *
61     * Format: ERROR \<function\> : Something bad happened.
62     */
63    std::string preamble = "\aERROR <" + subroutine + "> : ";
64    std::cerr << preamble;
65    for(unsigned int i=0;i<error.size();i++){
66      std::cerr << error[i];
67      if((i!=error.size()-1)&&(error[i]=='\n'))
68        std::cerr << std::setw(preamble.size()-1) <<": ";
69    }
70  }
71
72}
Note: See TracBrowser for help on using the repository browser.