b3371e63cd0b7269092eb4597d6cf22943d9158f
[jabaws.git] / binaries / src / clustalw / src / general / Utility.h
1 /**
2  * Author: Mark Larkin
3  * 
4  * Copyright (c) 2007 Des Higgins, Julie Thompson and Toby Gibson.  
5  */
6 #ifndef UTILITY_H
7 #define UTILITY_H
8
9 #include <cstdlib>
10 #include <stdio.h>
11 #include <string.h>
12 #include <errno.h>
13 #include <stdarg.h>
14 #include <ctype.h>
15 #include "clustalw.h"
16 class QLabel;
17 using namespace std;
18
19 namespace clustalw
20 {
21 class Utility
22 {
23     public:
24         Utility();
25         virtual ~Utility(){};
26
27         char* rTrim(char *str);
28         void rTrim(string *str);
29         char* blankToUnderscore(char *str);
30         string blankToUnderscore(string str);
31         void getStr(string instr, string& outstr);
32         char getChoice(string instr);
33         double getReal(const char *instr, double minx, double maxx, double def);
34         int getInt(const char *instr,int minx,int maxx, int def);
35         unsigned long getUniqueSequenceIdentifier();
36         bool lineType(char *line, const char *code);
37
38         bool blankLine(char *line);
39         
40         void getPath(string str, string *path);
41         
42         virtual char promptForYesNo(char *title, const char *prompt);
43         virtual char promptForYesNo(const char *title, const char *prompt);
44         virtual void error( char *msg,...);
45         virtual void error( const char *msg,...);
46         virtual void warning( char *msg,...);
47         virtual void warning( const char *msg,...);
48         virtual void info( char *msg,...);
49         virtual void info( const char *msg,...);
50         virtual void myname( char *myname );
51         template <class T> T MIN(T x, T y){if (x <= y){return x;}return y;}
52         template <class T> T MAX(T x, T y){if (x >= y){return x;}return y;}
53         // Note the following function will never be used from this class. It is for the
54         // QT version. I need it here so that I can add the function to QTUtility.
55         virtual void setInfoLabelPtr(QLabel* ptrToLabelObj);
56         bool isNumeric(char ch);
57         double average(std::vector<double>& v);
58         double stdDev(std::vector<double>& v);
59         double median(std::vector<double> v);
60         /* Attributes */
61         void beQuiet(bool b) {quiet=b;};
62         
63     private:
64         /* Functions */
65
66
67         /* Attributes */
68         bool quiet;
69
70 };
71 }
72 #endif
73