File: delcher.hh

package info (click to toggle)
tigr-glimmer 3.02b-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 13,948 kB
  • sloc: cpp: 24,416; awk: 232; csh: 220; makefile: 147; sh: 51
file content (201 lines) | stat: -rw-r--r-- 3,513 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
//  A. L. Delcher
//
//  File:  delcher.hh
//
//  Last Modified:  23 October 2003
//
//  Common generic routines declarations


#ifndef  __DELCHER_HH_INCLUDED
#define  __DELCHER_HH_INCLUDED

#define  ALLOW_LONG_OPTIONS  1

#include  <stdio.h>
#include  <stdlib.h>
#include  <math.h>
#include  <ctype.h>
#include  <float.h>
#include  <time.h>
#include  <assert.h>
#include  <errno.h>
#include  <getopt.h>
#include  <limits.h>
#include  <algorithm>
#include  <string>
#include  <new>
#include  <cstdlib>
#include  <iostream>
#include  <iomanip>
#include  <fstream>
#include  <vector>
#include  <cstring>

#include  "exceptions.hh"


using namespace  std;


#define  TRUE  1
#define  FALSE  0
#ifndef  EXIT_FAILURE
  #define  EXIT_FAILURE  -1
#endif
#ifndef  EXIT_SUCCESS
  #define  EXIT_SUCCESS  0
#endif


#define  SAFE_CALLOC(x,y)  Safe_calloc (x, y, __FILE__, __LINE__)
#define  SAFE_MALLOC(x)  Safe_malloc (x, __FILE__, __LINE__)
#define  SAFE_REALLOC(x,y)  Safe_realloc (x, y, __FILE__, __LINE__)


const int  MAX_ERROR_MSG_LEN = 1000;
  // Length of longest possible error message


extern char  Clean_Exit_Msg_Line [MAX_ERROR_MSG_LEN];
  // String to write error messages to before exiting
extern int  Verbose;
  // Flag to determine level of debugging output


const char *  Commatize
    (long int  n);
void  Clean_Exit
    (const char * msg, const char * src_fname = NULL, size_t line_num = 0);
FILE *  File_Open
    (const string & fname, const string & mode, const char * src_fname = NULL,
     size_t line_num = 0);
char  First_Non_Blank
    (const char * s);
int  Int_Power
    (int a, int b);
void  Make_Lower_Case
    (char * s);
void  Make_Upper_Case
    (char * s);
const char *  Num_Or_Max
    (int n, int mx = INT_MAX);
double  Percent
    (double a, double b);
const char *  Printable
    (bool b);
const char *  Printable
    (char * s);
double  Pseudo_Normal
    (void);
double  Ratio
    (double a, double b);
void  Reverse_String
    (char * s);
void  Reverse_String
    (string & s);
void *  Safe_calloc
    (size_t n, size_t len, const char * src_fname = NULL,
     size_t line_num = 0);
void *  Safe_malloc
    (size_t len, const char * src_fname = NULL, size_t line_num = 0);
void *  Safe_realloc
    (void * q, size_t len, const char * src_fname = NULL,
     size_t line_num = 0);
char *  Strip_Trailing
    (char * s, char ch);


template <class DT>  void  Incr_Limited
    (DT & A, DT limit);
template <class DT>  DT  Max
    (DT, DT);
template <class DT>  DT  Min
    (DT, DT);
template <class DT>  void  Swap
    (DT &, DT &);



template <class DT>  void  Incr_Limited
    (DT & A, DT limit)

// Increment  A  by 1, but only if it's less than  limit .

  {
   if  (A < limit)
       A ++;

   return;
  }



template <class DT>  DT  Max
    (DT A, DT B)

// Return the larger of  A  and  B .

  {
   if  (A > B)
       return  A;
     else
       return  B;
  }



template <class DT>  DT  Min
    (DT A, DT B)

// Return the smaller of  A  and  B .

  {
   if  (A < B)
       return  A;
     else
       return  B;
  }



template <class DT>  void  Reverse
    (vector <DT> & v)

// Reverse the order of entries in  v .

  {
   DT  s;
   int  i, j, n;

   n = v . size ();
   for  (i = 0, j = n - 1;  i < j;  i ++, j --)
     {
      s = v [i];
      v [i] = v [j];
      v [j] = s;
     }

   return;
  }



template <class DT>  void  Swap
    (DT & A, DT & B)

// Swap the values in  A  and  B .

  {
   DT  Save;

   Save = A;
   A = B;
   B = Save;

   return;
  }



#endif