~ubuntu-branches/ubuntu/raring/voxbo/raring

« back to all changes in this revision

Viewing changes to lib/genericexcep.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michael Hanke
  • Date: 2010-06-06 11:33:11 UTC
  • Revision ID: james.westby@ubuntu.com-20100606113311-v3c13imdkkd5n7ae
Tags: upstream-1.8.5~svn1172
ImportĀ upstreamĀ versionĀ 1.8.5~svn1172

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
// genericexcep.cpp
 
3
// 
 
4
// Copyright (c) 1998-2002 by The VoxBo Development Team
 
5
 
 
6
// This file is part of VoxBo
 
7
// 
 
8
// VoxBo is free software: you can redistribute it and/or modify it
 
9
// under the terms of the GNU General Public License as published by
 
10
// the Free Software Foundation, either version 3 of the License, or
 
11
// (at your option) any later version.
 
12
// 
 
13
// VoxBo is distributed in the hope that it will be useful, but
 
14
// WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
// General Public License for more details.
 
17
// 
 
18
// You should have received a copy of the GNU General Public License
 
19
// along with VoxBo.  If not, see <http://www.gnu.org/licenses/>.
 
20
// 
 
21
// For general information on VoxBo, including the latest complete
 
22
// source code and binary distributions, manual, and associated files,
 
23
// see the VoxBo home page at: http://www.voxbo.org/
 
24
// 
 
25
// original version written by Kosh Banerjee
 
26
 
 
27
using namespace std;
 
28
 
 
29
#include "genericexcep.h"
 
30
#include "string.h"
 
31
 
 
32
/********************************************************************
 
33
* The GenericExcep class:                                           *
 
34
********************************************************************/
 
35
 
 
36
/********************************************************************
 
37
* Initializing the static data members.                             *
 
38
********************************************************************/
 
39
string GenericExcep::error = "[E] ";
 
40
string GenericExcep::file = " In File: [";
 
41
string GenericExcep::lineNumb = "] Line Number: [";
 
42
string GenericExcep::func = "] In function: [";
 
43
 
 
44
/********************************************************************
 
45
* Constructors for GenericExcep:                                    *
 
46
********************************************************************/
 
47
GenericExcep::GenericExcep(const int line, const char *fileNm, const char *func, const char *mesg)
 
48
{
 
49
  this->init(line, fileNm, func);
 
50
  this->message = string(mesg);
 
51
 
 
52
} // GenericExcep::GenericExcep(const int line, const char *fileNm, const char *func, const char *mesg)
 
53
 
 
54
GenericExcep::GenericExcep(const int line, const char *fileNm, const char *func, const string mesg)
 
55
{
 
56
  this->init(line, fileNm, func);
 
57
        this->message = mesg;
 
58
  
 
59
} // GenericExcep::GenericExcep(const int line, const char *fileNm, const char *func, const string mesg)
 
60
 
 
61
void GenericExcep::init(const int line, const char *fileNm, const char *func)
 
62
{
 
63
  this->lineNo = line;
 
64
  this->fileName = fileNm;
 
65
  this->funcName = func;
 
66
  this->errMsg = "";
 
67
  this->caller = "";
 
68
} // GenericExcep::init(const int line, const char *fileNm, const char *func)
 
69
 
 
70
void GenericExcep::what(int line, string file, string function) 
 
71
{
 
72
        this->whatNoExit(line, file, function);
 
73
  exit(1);
 
74
 
 
75
} // virtual void GenericExcep::what(int, string, string) const
 
76
 
 
77
void GenericExcep::whatAbort(int line, string file, string function) 
 
78
{
 
79
        this->whatNoExit(line, file, function);
 
80
  abort();
 
81
} // virtual void GenericExcep::whatAbort(int line, string file, string function) 
 
82
 
 
83
void GenericExcep::whatNoExit(int line, string file, string function) 
 
84
{
 
85
  return;  // FIXME DYK: this quick and dirty fix eliminates all those
 
86
           // spurious console messages from vb_vector
 
87
  char intString[INT_STRING_SIZE];
 
88
  (void) memset (intString, 0, sizeof(intString));
 
89
  (void) sprintf (intString, "%d", this->lineNo);
 
90
 
 
91
  errMsg = this->error + this->message + this->file + this->fileName 
 
92
  + this->lineNumb + intString + this->func + this->funcName + "]"; 
 
93
 
 
94
  (void) memset (intString, 0, sizeof(intString));
 
95
  (void) sprintf (intString, "%d", line);
 
96
  caller = "[X] FROM: Line Number [" + (string) intString 
 
97
  + "] Function [" + function + "] File [" + file + "]"; 
 
98
 
 
99
  cerr << caller << endl;
 
100
  cerr << errMsg << endl;
 
101
 
 
102
} // virtual void GenericExcep::whatNoExit(int, string, string) const
 
103
 
 
104
void GenericExcep::what()
 
105
{
 
106
  this->what(0, "UNKNOWN", "UNKNOWN");
 
107
} // virtual void GenericExcep::what() const