forked from CBDD/rDock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRbt.h
127 lines (108 loc) · 5.33 KB
/
Rbt.h
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
/***********************************************************************
* The rDock program was developed from 1998 - 2006 by the software team
* at RiboTargets (subsequently Vernalis (R&D) Ltd).
* In 2006, the software was licensed to the University of York for
* maintenance and distribution.
* In 2012, Vernalis and the University of York agreed to release the
* program as Open Source software.
* This version is licensed under GNU-LGPL version 3.0 with support from
* the University of Barcelona.
* http://rdock.sourceforge.net/
***********************************************************************/
//Miscellaneous non-member functions in Rbt namespace
#ifndef _RBT_H_
#define _RBT_H_
#include "RbtTypes.h"
#include "RbtContainers.h"
#include "RbtError.h"
namespace Rbt
{
////////////////////////////////////////////////////////////////
//RESOURCE HANDLING FUNCTIONS
//
//GetRbtRoot - returns value of RBT_ROOT env variable
RbtString GetRbtRoot();
//GetRbtHome - returns value of RBT_HOME env variable
//(or HOME if RBT_HOME is undefined)
RbtString GetRbtHome();
//GetCopyright - returns legalese statement
RbtString GetCopyright();
//GetVersion - returns current library version
RbtString GetVersion();
//GetBuildNum - returns current library build number
RbtString GetBuild();
//GetProduct - returns library product name
RbtString GetProduct();
//GetTime - returns current time and date as an RbtString
RbtString GetTime();
//GetCurrentDirectory - returns current working directory
RbtString GetCurrentDirectory();
//
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
//FILE/DIRECTORY HANDLING FUNCTIONS
//
//GetRbtDirName
//Returns the full path to a subdirectory in the rDock directory structure
//
//For example, if RBT_ROOT environment variable is ~dave/ribodev/molmod/ribodev
//then GetRbtDirName("data") would return ~dave/ribodev/molmod/ribodev/data/
//
//If RBT_ROOT is not set, then GetRbtDirName returns ./ irrespective of the
//subdirectory asked for. Thus the fall-back position is that parameter files
//are read from the current directory if RBT_ROOT is not defined.
RbtString GetRbtDirName(const RbtString& strSubdir="");
//GetRbtFileName
//As GetRbtDirName but returns the full path to a file in the rDock directory structure
RbtString GetRbtFileName(const RbtString& strSubdir, const RbtString& strFile);
//GetFileType
//Returns the string following the last "." in the file name.
//e.g. GetFileType("receptor.psf") would return "psf"
RbtString GetFileType(const RbtString& strFile);
//GetDirList
//Returns a list of files in a directory (strDir) whose names begin with strFilePrefix (optional)
//and whose type is strFileType (optional, as returned by GetFileType)
RbtStringList GetDirList(const RbtString& strDir, const RbtString& strFilePrefix="", const RbtString& strFileType="");
//
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
//CONVERSION ROUTINES
//
//Converts (comma)-delimited string of segment names to segment map
RbtSegmentMap ConvertStringToSegmentMap(const RbtString& strSegments, const RbtString& strDelimiter=",");
//Converts segment map to (comma)-delimited string of segment names
RbtString ConvertSegmentMapToString(const RbtSegmentMap& segmentMap, const RbtString& strDelimiter=",");
//Returns a segment map containing the members of map1 which are not in map2
//I know, should really be a template so as to be more universal...one day maybe.
//Or maybe there is already an STL algorithm for doing this.
RbtSegmentMap SegmentDiffMap(const RbtSegmentMap& map1, const RbtSegmentMap& map2);
//DM 30 Mar 1999
//Converts (comma)-delimited string to string list (similar to ConvertStringToSegmentMap, but returns list not map)
RbtStringList ConvertDelimitedStringToList(const RbtString& strValues, const RbtString& strDelimiter=",");
//Converts string list to (comma)-delimited string (inverse of above)
RbtString ConvertListToDelimitedString(const RbtStringList& listOfValues, const RbtString& strDelimiter=",");
//
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
//I/O ROUTINES
//
//PrintStdHeader
//Print a standard header to an output stream (for log files etc)
//Contains copyright info, library version, date, time etc
//DM 19 Feb 1999 - include executable information
std::ostream& PrintStdHeader(std::ostream& s, const RbtString& strExecutable="");
//Helper functions to read/write chars from iostreams
//Throws error if stream state is not Good() before and after the read/write
//It appears the STL ios_base exception throwing is not yet implemented
//at least on RedHat 6.1, so this is a temporary workaround (yeah right)
//
//DM 25 Sep 2000 - with MIPSPro CC compiler, streamsize is not defined,
//at least with the iostreams library we are using, so typedef it here
// it is not in gcc 3.2.1 either SJ
//#ifdef __sgi
typedef int streamsize;
//#endif
void WriteWithThrow(std::ostream& ostr, const char* p, streamsize n) throw (RbtError);
void ReadWithThrow(std::istream& istr, char* p, streamsize n) throw (RbtError);
}
#endif //_RBT_H_