Commit 8df97a59 authored by Vedran Miletić's avatar Vedran Miletić

Replace RbtString with std::string

parent 7467236e
......@@ -2,10 +2,10 @@
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>
const RbtString EXEVERSION = " ($Id$)";
const std::string EXEVERSION = " ($Id$)";
int main(int argc, char **argv) {
RbtString strExeName(argv[0]);
std::string strExeName(argv[0]);
Rbt::PrintStdHeader(std::cout, strExeName + EXEVERSION);
CppUnit::TextUi::TestRunner runner;
CppUnit::TestFactoryRegistry &registry =
......
......@@ -18,10 +18,10 @@ RbtDouble OccupancyTest::TINY = 1E-4;
void OccupancyTest::setUp() {
try {
// Create the docking site, receptor, and ligand objects
const RbtString &wsName = "1YET";
RbtString prmFileName = Rbt::GetRbtFileName("", wsName + ".prm");
RbtString ligFileName = Rbt::GetRbtFileName("", wsName + "_c.sd");
RbtString asFileName = Rbt::GetRbtFileName("", wsName + ".as");
const std::string &wsName = "1YET";
std::string prmFileName = Rbt::GetRbtFileName("", wsName + ".prm");
std::string ligFileName = Rbt::GetRbtFileName("", wsName + "_c.sd");
std::string asFileName = Rbt::GetRbtFileName("", wsName + ".as");
RbtParameterFileSourcePtr spPrmSource(
new RbtParameterFileSource(prmFileName));
RbtMolecularFileSourcePtr spMdlFileSource(
......@@ -194,8 +194,8 @@ RbtBool OccupancyTest::testFlexAtomFactory(RbtModel *pModel,
for (RbtInt mode = 0; mode < 9; ++mode) {
RbtChromElement::eMode eTransMode = (RbtChromElement::eMode)(mode / 3);
RbtChromElement::eMode eRotMode = (RbtChromElement::eMode)(mode % 3);
RbtString strTransMode = RbtChromElement::ModeToStr(eTransMode);
RbtString strRotMode = RbtChromElement::ModeToStr(eRotMode);
std::string strTransMode = RbtChromElement::ModeToStr(eTransMode);
std::string strRotMode = RbtChromElement::ModeToStr(eRotMode);
pFlexData->SetParameter(RbtLigandFlexData::_TRANS_MODE, strTransMode);
pFlexData->SetParameter(RbtLigandFlexData::_ROT_MODE, strRotMode);
pModel->SetFlexData(pFlexData);
......@@ -235,8 +235,8 @@ RbtDouble OccupancyTest::CompareScoresForSolventModes() {
for (RbtInt mode = 0; mode < 9; ++mode) {
RbtChromElement::eMode eTransMode = (RbtChromElement::eMode)(mode / 3);
RbtChromElement::eMode eRotMode = (RbtChromElement::eMode)(mode % 3);
RbtString strTransMode = RbtChromElement::ModeToStr(eTransMode);
RbtString strRotMode = RbtChromElement::ModeToStr(eRotMode);
std::string strTransMode = RbtChromElement::ModeToStr(eTransMode);
std::string strRotMode = RbtChromElement::ModeToStr(eRotMode);
// Change the modes of all except the first solvent model, to ensure a mix
// of tethered / free solvent
for (RbtModelListIter iter = solventList.begin() + 1;
......
......@@ -21,11 +21,11 @@ RbtDouble RbtChromTest::TINY = 1E-4;
void RbtChromTest::setUp() {
try {
// Create a receptor model, ligand model, and docking site
const RbtString &wsName = "1koc";
RbtString prmFileName =
const std::string &wsName = "1koc";
std::string prmFileName =
Rbt::GetRbtFileName("data/receptors", wsName + ".prm");
RbtString ligFileName = Rbt::GetRbtFileName("", wsName + "_c.sd");
RbtString asFileName = Rbt::GetRbtFileName("data/grids", wsName + ".as");
std::string ligFileName = Rbt::GetRbtFileName("", wsName + "_c.sd");
std::string asFileName = Rbt::GetRbtFileName("data/grids", wsName + ".as");
RbtParameterFileSourcePtr spPrmSource(
new RbtParameterFileSource(prmFileName));
RbtMolecularFileSourcePtr spMdlFileSource(
......
......@@ -17,10 +17,10 @@ CPPUNIT_TEST_SUITE_REGISTRATION(SearchTest);
void SearchTest::setUp() {
try {
// Create the docking site, receptor, ligand and solvent objects
const RbtString &wsName = "1YET";
RbtString prmFileName = Rbt::GetRbtFileName("", wsName + ".prm");
RbtString ligFileName = Rbt::GetRbtFileName("", wsName + "_c.sd");
RbtString asFileName = Rbt::GetRbtFileName("", wsName + ".as");
const std::string &wsName = "1YET";
std::string prmFileName = Rbt::GetRbtFileName("", wsName + ".prm");
std::string ligFileName = Rbt::GetRbtFileName("", wsName + "_c.sd");
std::string asFileName = Rbt::GetRbtFileName("", wsName + ".as");
RbtParameterFileSourcePtr spPrmSource(
new RbtParameterFileSource(prmFileName));
RbtMolecularFileSourcePtr spMdlFileSource(
......@@ -173,7 +173,7 @@ void SearchTest::testRestart() {
m_workSpace->Save();
finalScore = m_workSpace->GetSF()->Score();
// Reload the receptor, minimised ligand and solvent
RbtString prmFileName = Rbt::GetRbtFileName("", "1YET.prm");
std::string prmFileName = Rbt::GetRbtFileName("", "1YET.prm");
RbtParameterFileSourcePtr spPrmSource(
new RbtParameterFileSource(prmFileName));
RbtMolecularFileSourcePtr spMdlFileSource(
......
......@@ -49,8 +49,8 @@ public:
}
}
RbtReturnType GetResult() const { return result; }
RbtString GetName() const { return name; }
void SetName(RbtString s) { name = s; }
std::string GetName() const { return name; }
void SetName(std::string s) { name = s; }
void SetResult(RbtReturnType r) {
result = r;
evaluated = true;
......@@ -72,7 +72,7 @@ public:
private:
RbtBool evaluated, constant;
RbtString name;
std::string name;
RbtReturnType result;
// friend ostream& operator<<(ostream& s, const RbtCell &p);
};
......
......@@ -23,9 +23,9 @@ class RbtCommand {
public:
virtual RbtReturnType Execute() = 0;
virtual int GetNArgs() = 0;
virtual RbtString GetName() = 0;
virtual void SetArg(int i, RbtReturnType f) = 0; // { *(Arg[i]) = f;};
virtual void SetNameArg(int i, RbtString &n) = 0; // { NameArg[i] = n;};
virtual std::string GetName() = 0;
virtual void SetArg(int i, RbtReturnType f) = 0; // { *(Arg[i]) = f;};
virtual void SetNameArg(int i, std::string &n) = 0; // { NameArg[i] = n;};
static void Clear() { ntabs = 0; }
///////////////////
......@@ -40,8 +40,8 @@ protected:
// Constructors
///////////////////
RbtCommand() {} // Default constructor disabled
RbtString tabs(RbtInt n) {
RbtString st = "";
std::string tabs(RbtInt n) {
std::string st = "";
for (RbtInt i = 0; i < n; i++)
st += " ";
return st;
......@@ -59,52 +59,54 @@ typedef RbtCommandList::const_iterator RbtCommandListConstIter;
class AddCommand : public RbtCommand {
public:
int GetNArgs() { return 2; }
RbtString GetName() { return ("(" + NameArg[0] + "+ " + NameArg[1] + ")"); }
std::string GetName() { return ("(" + NameArg[0] + "+ " + NameArg[1] + ")"); }
AddCommand() {} //{Arg = RbtReturnType(2);}
void SetArg(int i, RbtReturnType f) { Arg[i] = f; }
void SetNameArg(int i, RbtString &n) { NameArg[i] = n; }
void SetNameArg(int i, std::string &n) { NameArg[i] = n; }
RbtReturnType Execute() { return Arg[0] + Arg[1]; }
private:
RbtReturnType Arg[2];
RbtString NameArg[2];
std::string NameArg[2];
};
class SubCommand : public RbtCommand {
public:
int GetNArgs() { return 2; }
RbtString GetName() { return ("(" + NameArg[0] + "- " + NameArg[1] + ")"); }
std::string GetName() { return ("(" + NameArg[0] + "- " + NameArg[1] + ")"); }
void SetArg(int i, RbtReturnType f) { Arg[i] = f; }
void SetNameArg(int i, RbtString &n) { NameArg[i] = n; }
void SetNameArg(int i, std::string &n) { NameArg[i] = n; }
SubCommand() {}
RbtReturnType Execute() { return Arg[0] - Arg[1]; }
private:
RbtReturnType Arg[2];
RbtString NameArg[2];
std::string NameArg[2];
};
class MulCommand : public RbtCommand {
public:
int GetNArgs() { return 2; }
RbtString GetName() { return ("(" + NameArg[0] + "* " + NameArg[1] + ")"); }
std::string GetName() { return ("(" + NameArg[0] + "* " + NameArg[1] + ")"); }
void SetArg(int i, RbtReturnType f) { Arg[i] = f; }
void SetNameArg(int i, RbtString &n) { NameArg[i] = n; }
void SetNameArg(int i, std::string &n) { NameArg[i] = n; }
MulCommand() {}
RbtReturnType Execute() { return Arg[0] * Arg[1]; }
private:
RbtReturnType Arg[2];
RbtString NameArg[2];
std::string NameArg[2];
};
class DivCommand : public RbtCommand {
public:
int GetNArgs() { return 2; }
RbtString GetName() { return ("(" + NameArg[0] + "div " + NameArg[1] + ")"); }
std::string GetName() {
return ("(" + NameArg[0] + "div " + NameArg[1] + ")");
}
DivCommand() {}
void SetArg(int i, RbtReturnType f) { Arg[i] = f; }
void SetNameArg(int i, RbtString &n) { NameArg[i] = n; }
void SetNameArg(int i, std::string &n) { NameArg[i] = n; }
RbtReturnType Execute() {
if (fabs(Arg[1]) < 0.000001)
return Arg[0];
......@@ -113,13 +115,13 @@ public:
private:
RbtReturnType Arg[2];
RbtString NameArg[2];
std::string NameArg[2];
};
class IfCommand : public RbtCommand {
public:
int GetNArgs() { return 3; }
RbtString GetName() {
std::string GetName() {
// return ("\niff(" + NameArg[0] + "," + NameArg[1] + "," +
// NameArg[2] + ")");};
if (inside)
......@@ -131,7 +133,7 @@ public:
}
IfCommand() {}
void SetArg(int i, RbtReturnType f) { Arg[i] = f; }
void SetNameArg(int i, RbtString &n) { NameArg[i] = n; }
void SetNameArg(int i, std::string &n) { NameArg[i] = n; }
RbtReturnType Execute() {
if (Arg[0] > 0.0)
return Arg[1];
......@@ -140,16 +142,16 @@ public:
private:
RbtReturnType Arg[3];
RbtString NameArg[3];
std::string NameArg[3];
};
class LogCommand : public RbtCommand {
public:
int GetNArgs() { return 1; }
RbtString GetName() { return ("log(" + NameArg[0] + ")"); }
std::string GetName() { return ("log(" + NameArg[0] + ")"); }
LogCommand() {}
void SetArg(int i, RbtReturnType f) { Arg[i] = f; }
void SetNameArg(int i, RbtString &n) { NameArg[i] = n; }
void SetNameArg(int i, std::string &n) { NameArg[i] = n; }
RbtReturnType Execute() {
if (fabs(Arg[0]) < 0.000001)
return 0;
......@@ -158,16 +160,16 @@ public:
private:
RbtReturnType Arg[1];
RbtString NameArg[1];
std::string NameArg[1];
};
class ExpCommand : public RbtCommand {
public:
int GetNArgs() { return 1; }
RbtString GetName() { return ("exp(" + NameArg[0] + ")"); }
std::string GetName() { return ("exp(" + NameArg[0] + ")"); }
ExpCommand() {}
void SetArg(int i, RbtReturnType f) { Arg[i] = f; }
void SetNameArg(int i, RbtString &n) { NameArg[i] = n; }
void SetNameArg(int i, std::string &n) { NameArg[i] = n; }
RbtReturnType Execute() {
if (Arg[0] > 200)
return exp(200);
......@@ -178,6 +180,6 @@ public:
private:
RbtReturnType Arg[2];
RbtString NameArg[2];
std::string NameArg[2];
};
#endif //_RbtCommand_H_
......@@ -22,7 +22,7 @@
class RbtGPChromosome {
public:
static RbtString _CT;
static std::string _CT;
///////////////////
// Constructors
///////////////////
......
......@@ -25,7 +25,7 @@
class RbtGPFFCHK1 : public RbtGPFitnessFunction {
public:
static RbtString _CT;
static std::string _CT;
RbtGPFFCHK1(RbtContextPtr c) : contextp(c) { _RBTOBJECTCOUNTER_CONSTR_(_CT); }
virtual ~RbtGPFFCHK1() { _RBTOBJECTCOUNTER_DESTR_(_CT); }
......
......@@ -24,7 +24,7 @@
class RbtGPFFCrossDock : public RbtGPFitnessFunction {
public:
static RbtString _CT;
static std::string _CT;
void ReadTables(istream &, RbtReturnTypeArray &, RbtReturnTypeArray &);
RbtDouble CalculateFitness(RbtGPGenomePtr, RbtReturnTypeArray &,
......
......@@ -24,7 +24,7 @@
class RbtGPFFGold : public RbtGPFitnessFunction {
public:
static RbtString _CT;
static std::string _CT;
void ReadTables(istream &);
RbtDouble CalculateFitness(RbtGPGenomePtr, RbtReturnTypeArray &,
......
......@@ -24,7 +24,7 @@
class RbtGPFFHSP90 : public RbtGPFitnessFunction {
public:
static RbtString _CT;
static std::string _CT;
RbtGPFFHSP90(RbtContextPtr c) : contextp(c) {
_RBTOBJECTCOUNTER_CONSTR_(_CT);
}
......
......@@ -25,7 +25,7 @@
class RbtGPFFSpike : public RbtGPFitnessFunction {
public:
static RbtString _CT;
static std::string _CT;
RbtGPFFSpike(RbtContextPtr c) : contextp(c) {
_RBTOBJECTCOUNTER_CONSTR_(_CT);
}
......
......@@ -24,7 +24,7 @@
class RbtGPFitnessFunction {
public:
static RbtString _CT;
static std::string _CT;
///////////////////
// Constructors
///////////////////
......
......@@ -22,13 +22,13 @@
class RbtGPGenome {
public:
static RbtString _CT;
static std::string _CT;
///////////////////
// Constructors
///////////////////
RbtGPGenome();
RbtGPGenome(const RbtGPGenome &);
RbtGPGenome(RbtString);
RbtGPGenome(std::string);
RbtGPGenome(istream &);
RbtGPGenome &operator=(const RbtGPGenome &);
......
......@@ -24,7 +24,7 @@
class RbtGPParser {
public:
static RbtString _CT;
static std::string _CT;
///////////////////
// Constructors
///////////////////
......@@ -40,7 +40,7 @@ public:
ostream &Print(ostream &) const;
friend ostream &operator<<(ostream &s, const RbtGPParser &p);
RbtReturnTypeList Parse(RbtGPChromosomePtr, RbtReturnTypeList &);
RbtString PrintParse(istream &, RbtGPChromosomePtr, RbtBool, RbtBool);
std::string PrintParse(istream &, RbtGPChromosomePtr, RbtBool, RbtBool);
RbtBool IsConstantInt(RbtInt i) { return (i == CINT); }
RbtBool IsConstantFloat(RbtInt i) { return (i == CFLOAT); }
......@@ -50,8 +50,8 @@ private:
/////////////////////
RbtReturnType Eval(RbtGPChromosomePtr, RbtInt);
RbtReturnType Parse1Output(RbtGPChromosomePtr, RbtInt);
RbtString PrintEval(RbtGPChromosomePtr, RbtInt, RbtBool, RbtBool);
RbtString PrintParse1Output(RbtGPChromosomePtr, RbtInt, RbtBool, RbtBool);
std::string PrintEval(RbtGPChromosomePtr, RbtInt, RbtBool, RbtBool);
std::string PrintParse1Output(RbtGPChromosomePtr, RbtInt, RbtBool, RbtBool);
// RbtGPChromosomePtr chrom;
// RbtCellList cells;
RbtCommandList commands;
......
......@@ -23,7 +23,7 @@
class RbtGPPopulation {
public:
static RbtString _CT;
static std::string _CT;
///////////////////
// Constructors
///////////////////
......@@ -42,14 +42,14 @@ public:
void Initialise(RbtDouble, RbtBool);
void ScaleFitness();
void Eval(RbtDouble, RbtBool);
RbtGPGenomePtr Select(RbtString) const;
RbtGPGenomePtr Select(std::string) const;
void SelectionUpdate(RbtString);
void SelectionUpdate(std::string);
void GAstep(RbtString, RbtDouble, RbtDouble, RbtDouble, RbtDouble, RbtDouble,
RbtBool) throw(RbtError);
void EPstep(RbtString, RbtDouble, RbtDouble, RbtDouble, RbtDouble, RbtDouble,
RbtBool) throw(RbtError);
void GAstep(std::string, RbtDouble, RbtDouble, RbtDouble, RbtDouble,
RbtDouble, RbtBool) throw(RbtError);
void EPstep(std::string, RbtDouble, RbtDouble, RbtDouble, RbtDouble,
RbtDouble, RbtBool) throw(RbtError);
RbtGPGenomePtr Best() const;
ostream &Print(ostream &) const;
friend ostream &operator<<(ostream &, const RbtGPPopulation &);
......
......@@ -23,22 +23,22 @@ namespace Rbt {
// RESOURCE HANDLING FUNCTIONS
//
// GetRbtRoot - returns value of RBT_ROOT env variable
RbtString GetRbtRoot();
std::string GetRbtRoot();
// GetRbtHome - returns value of RBT_HOME env variable
//(or HOME if RBT_HOME is undefined)
RbtString GetRbtHome();
std::string GetRbtHome();
// GetCopyright - returns legalese statement
RbtString GetCopyright();
std::string GetCopyright();
// GetVersion - returns current library version
RbtString GetVersion();
std::string GetVersion();
// GetBuildNum - returns current library build number
RbtString GetBuild();
std::string GetBuild();
// GetProduct - returns library product name
RbtString GetProduct();
std::string GetProduct();
// GetTime - returns current time and date as an RbtString
RbtString GetTime();
std::string GetTime();
// GetCurrentDirectory - returns current working directory
RbtString GetCurrentDirectory();
std::string GetCurrentDirectory();
//
////////////////////////////////////////////////////////////////
......@@ -54,25 +54,26 @@ RbtString GetCurrentDirectory();
// 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 = "");
std::string GetRbtDirName(const std::string &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);
std::string GetRbtFileName(const std::string &strSubdir,
const std::string &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);
std::string GetFileType(const std::string &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 = "");
RbtStringList GetDirList(const std::string &strDir,
const std::string &strFilePrefix = "",
const std::string &strFileType = "");
//
////////////////////////////////////////////////////////////////
......@@ -80,11 +81,11 @@ RbtStringList GetDirList(const RbtString &strDir,
// CONVERSION ROUTINES
//
// Converts (comma)-delimited string of segment names to segment map
RbtSegmentMap ConvertStringToSegmentMap(const RbtString &strSegments,
const RbtString &strDelimiter = ",");
RbtSegmentMap ConvertStringToSegmentMap(const std::string &strSegments,
const std::string &strDelimiter = ",");
// Converts segment map to (comma)-delimited string of segment names
RbtString ConvertSegmentMapToString(const RbtSegmentMap &segmentMap,
const RbtString &strDelimiter = ",");
std::string ConvertSegmentMapToString(const RbtSegmentMap &segmentMap,
const std::string &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
......@@ -95,11 +96,12 @@ RbtSegmentMap SegmentDiffMap(const RbtSegmentMap &map1,
// 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 = ",");
RbtStringList
ConvertDelimitedStringToList(const std::string &strValues,
const std::string &strDelimiter = ",");
// Converts string list to (comma)-delimited string (inverse of above)
RbtString ConvertListToDelimitedString(const RbtStringList &listOfValues,
const RbtString &strDelimiter = ",");
std::string ConvertListToDelimitedString(const RbtStringList &listOfValues,
const std::string &strDelimiter = ",");
//
////////////////////////////////////////////////////////////////
......@@ -112,7 +114,7 @@ RbtString ConvertListToDelimitedString(const RbtStringList &listOfValues,
// Contains copyright info, library version, date, time etc
// DM 19 Feb 1999 - include executable information
std::ostream &PrintStdHeader(std::ostream &s,
const RbtString &strExecutable = "");
const std::string &strExecutable = "");
// Helper functions to read/write chars from iostreams
// Throws error if stream state is not Good() before and after the read/write
......
......@@ -22,14 +22,14 @@
class RbtAlignTransform : public RbtBaseBiMolTransform {
public:
// Static data member for class type
static RbtString _CT;
static std::string _CT;
// Parameter names
static RbtString _COM;
static RbtString _AXES;
static std::string _COM;
static std::string _AXES;
////////////////////////////////////////
// Constructors/destructors
RbtAlignTransform(const RbtString &strName = "ALIGN");
RbtAlignTransform(const std::string &strName = "ALIGN");
virtual ~RbtAlignTransform();
////////////////////////////////////////
......
......@@ -36,7 +36,7 @@ public:
RbtDouble GetDistance() const;
RbtDouble GetScore() const;
// Get the fully qualified (FQ) residue name for atom 2 (target atom)
RbtString GetFQResName() const;
std::string GetFQResName() const;
// Set
void SetAtom1Ptr(const RbtAtom *pAt1);
......@@ -45,7 +45,7 @@ public:
void SetScore(RbtDouble s);
// Render annotation into string in rDock Viewer format
RbtString Render() const;
std::string Render() const;
// Operators
// Special meaning of operator+ for accumulating annotations by residue
......
......@@ -21,7 +21,7 @@
class RbtAnnotationHandler {
public:
static RbtString _ANNOTATION_FIELD;
static std::string _ANNOTATION_FIELD;
////////////////////////////////////////
// Constructors/destructors
......@@ -34,7 +34,7 @@ public:
// Get a const ref to the annotation list (read-only)
const RbtAnnotationList &GetAnnotationList() const;
RbtInt GetNumAnnotations() const;
void RenderAnnotationList(const RbtString &strName,
void RenderAnnotationList(const std::string &strName,
RbtStringList &retVal) const;
protected:
......
......@@ -25,18 +25,18 @@ class RbtAromIdxSF : public RbtBaseInterSF,
public RbtAnnotationHandler {
public:
// Class type string
static RbtString _CT;
static std::string _CT;
// Parameter names
static RbtString _INCR;
static RbtString _R12;
static RbtString _DR12MIN;
static RbtString _DR12MAX;
static RbtString _DAMIN;
static RbtString _DAMAX;