diff --git a/Code/Mantid/Framework/Geometry/CMakeLists.txt b/Code/Mantid/Framework/Geometry/CMakeLists.txt index 8a4ba1af77e10a745db4dae0f38577704ace8e95..f683402815442a9d8130cc43b4678cefd45fe74c 100644 --- a/Code/Mantid/Framework/Geometry/CMakeLists.txt +++ b/Code/Mantid/Framework/Geometry/CMakeLists.txt @@ -28,9 +28,7 @@ set ( SRC_FILES src/IDetector.cpp src/Math/PolyFunction.cpp src/Math/PolyVar.cpp src/Math/PolyVarOne.cpp - src/Math/RegexSupport.cpp src/Math/RotCounter.cpp - src/Math/SupportGeometry.cpp src/Math/Triple.cpp src/MDGeometry/IMDDimension.cpp src/MDGeometry/MDBasisDimension.cpp @@ -106,7 +104,6 @@ set ( INC_FILES inc/MantidGeometry/DllExport.h inc/MantidGeometry/Math/PolyBase.h inc/MantidGeometry/Math/PolyFunction.h inc/MantidGeometry/Math/PolyVar.h - inc/MantidGeometry/Math/RegexSupport.h inc/MantidGeometry/Math/RotCounter.h inc/MantidGeometry/Math/Triple.h inc/MantidGeometry/MDGeometry/IMDDimension.h @@ -182,7 +179,6 @@ set ( TEST_FILES test/AcompTest.h test/PolyTest.h test/QuatTest.h test/RectangularDetectorTest.h - test/RegexSupportTest.h test/RotCounterTest.h test/RulesBoolValueTest.h test/RulesIntersectionTest.h diff --git a/Code/Mantid/Framework/Geometry/src/Math/Acomp.cpp b/Code/Mantid/Framework/Geometry/src/Math/Acomp.cpp index 46f11fc1982a4bd1ae2db78bcfa2b316c7d8eea3..3932f8bab68774ce7114577eb2fbdf2fd5574786 100644 --- a/Code/Mantid/Framework/Geometry/src/Math/Acomp.cpp +++ b/Code/Mantid/Framework/Geometry/src/Math/Acomp.cpp @@ -1,6 +1,6 @@ #include "MantidGeometry/Math/Acomp.h" #include "MantidKernel/Logger.h" -#include "MantidKernel/Support.h" +#include "MantidKernel/Strings.h" #include "MantidKernel/Exception.h" #include "MantidGeometry/Math/Matrix.h" #include "MantidGeometry/Math/RotCounter.h" @@ -478,7 +478,7 @@ namespace Mantid if (Ln[iu]=='%') { iu++; - const int Nmove=StrFunc::convPartNum(Ln.substr(iu),numItem); + const int Nmove=Mantid::Kernel::Strings::convPartNum(Ln.substr(iu),numItem); if (!Nmove) throw std::invalid_argument("Acomp::procIntersection error in line Ln\"" + Ln + "\""); numItem+=52; diff --git a/Code/Mantid/Framework/Geometry/src/Math/Algebra.cpp b/Code/Mantid/Framework/Geometry/src/Math/Algebra.cpp index 88c2392e087ed6a8c0c0ef7c924f99672ae5cdbe..ee0282520d4f28dfa74a79b3d2043f8d9984d65e 100644 --- a/Code/Mantid/Framework/Geometry/src/Math/Algebra.cpp +++ b/Code/Mantid/Framework/Geometry/src/Math/Algebra.cpp @@ -13,7 +13,7 @@ #include <iterator> #include "MantidKernel/Exception.h" -#include "MantidKernel/Support.h" +#include "MantidKernel/Strings.h" #include "MantidGeometry/Math/MapSupport.h" #include "MantidGeometry/Math/Algebra.h" @@ -279,7 +279,7 @@ Algebra::setFunctionObjStr(const std::string& A) { int N; int neg(0); - int nCount=StrFunc::convPartNum(A.substr(ipt,std::string::npos),N); + int nCount=Mantid::Kernel::Strings::convPartNum(A.substr(ipt,std::string::npos),N); if (nCount) { if (N<0) diff --git a/Code/Mantid/Framework/Geometry/src/Math/PolyFunction.cpp b/Code/Mantid/Framework/Geometry/src/Math/PolyFunction.cpp index d9745970253e564d3ff058f9e724f90913fa0afc..a0ae4213818996177295ba24391e45ddafba0736 100644 --- a/Code/Mantid/Framework/Geometry/src/Math/PolyFunction.cpp +++ b/Code/Mantid/Framework/Geometry/src/Math/PolyFunction.cpp @@ -7,7 +7,7 @@ #include <functional> #include <gsl/gsl_poly.h> -#include "MantidKernel/Support.h" +#include "MantidKernel/Strings.h" #include "MantidGeometry/Math/PolyFunction.h" namespace Mantid @@ -101,7 +101,7 @@ PolyFunction::getMaxSize(const std::string& CLine,const char V) if (pos!=L && CLine[pos+1]=='^') { int pV; - if (StrFunc::convPartNum(CLine.substr(pos+2),pV) && pV>maxPower) + if (Mantid::Kernel::Strings::convPartNum(CLine.substr(pos+2),pV) && pV>maxPower) maxPower=pV; } else if (!maxPower) // case of +y+... etc diff --git a/Code/Mantid/Framework/Geometry/src/Math/PolyVar.cpp b/Code/Mantid/Framework/Geometry/src/Math/PolyVar.cpp index 27c8119371bcbc6f86152e06c78a28652e3e8dd0..82fa72e93337d74b0b7d078ec7347ccdff32ce94 100644 --- a/Code/Mantid/Framework/Geometry/src/Math/PolyVar.cpp +++ b/Code/Mantid/Framework/Geometry/src/Math/PolyVar.cpp @@ -9,7 +9,7 @@ #include "MantidKernel/Exception.h" -#include "MantidKernel/Support.h" +#include "MantidKernel/Strings.h" #include "MantidGeometry/Math/MatrixBase.h" #include "MantidGeometry/Math/PolyVar.h" @@ -743,7 +743,7 @@ namespace Mantid int PolyVar<VCount>::read(const std::string& Line) { const char Variable("xyzabc"[VCount-1]); - std::string CLine=StrFunc::removeSpace(Line); + std::string CLine=Mantid::Kernel::Strings::removeSpace(Line); setDegree(PolyFunction::getMaxSize(CLine,Variable)); zeroPoly(); @@ -796,7 +796,7 @@ namespace Mantid if (!CLine.empty() && CLine[0]=='^') { CLine.erase(0,1); - if (!StrFunc::sectPartNum(CLine,pV) || pV<0) + if (!Mantid::Kernel::Strings::sectPartNum(CLine,pV) || pV<0) return -1; } if (Comp.empty()) diff --git a/Code/Mantid/Framework/Geometry/src/Math/PolyVarOne.cpp b/Code/Mantid/Framework/Geometry/src/Math/PolyVarOne.cpp index 78a1a2dff37be49abc9adaa752e0224ee2a8a47f..81c4fef4280fa71c4323be7e054eb70e9dcfee7d 100644 --- a/Code/Mantid/Framework/Geometry/src/Math/PolyVarOne.cpp +++ b/Code/Mantid/Framework/Geometry/src/Math/PolyVarOne.cpp @@ -8,7 +8,7 @@ #include <gsl/gsl_poly.h> #include "MantidKernel/Exception.h" -#include "MantidKernel/Support.h" +#include "MantidKernel/Strings.h" #include "MantidGeometry/Math/PolyVar.h" #ifndef M_PI @@ -883,7 +883,7 @@ namespace Mantid */ { const char Variable('x'); - std::string CLine=StrFunc::removeSpace(Line); + std::string CLine=Mantid::Kernel::Strings::removeSpace(Line); setDegree(PolyFunction::getMaxSize(CLine,Variable)); std::string::size_type pos=CLine.find(Variable); @@ -917,10 +917,10 @@ namespace Mantid if (!CLine.empty() && CLine[0]=='^') { CLine.erase(0,1); - StrFunc::sectPartNum(CLine,pV); + Mantid::Kernel::Strings::sectPartNum(CLine,pV); } - if (pV<0 || (!Comp.empty() && !StrFunc::convert(Comp,cV))) + if (pV<0 || (!Comp.empty() && !Mantid::Kernel::Strings::convert(Comp,cV))) throw std::invalid_argument("Invalid line in PolVarOne::read : " + Line); if (Comp.empty()) @@ -931,7 +931,7 @@ namespace Mantid } // Process variable at end: - if (!CLine.empty() && StrFunc::section(CLine,cV)) + if (!CLine.empty() && Mantid::Kernel::Strings::section(CLine,cV)) PCoeff[0]=cV; return 0; diff --git a/Code/Mantid/Framework/Geometry/src/Math/SupportGeometry.cpp b/Code/Mantid/Framework/Geometry/src/Math/SupportGeometry.cpp deleted file mode 100644 index be0dc6fe02fbfd0f21c6a9f256b1481e6f5c455a..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/Geometry/src/Math/SupportGeometry.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include <iostream> -#include <iomanip> -#include <fstream> -#include <sstream> -#include <cmath> -#include <vector> - -#include "MantidGeometry/Math/Matrix.h" -#include "MantidGeometry/V3D.h" -#include "MantidKernel/Support.h" -#include "MantidKernel/SupportTempCode.h" - -namespace Mantid -{ -namespace StrFunc -{ - -/// \cond TEMPLATE - -template DLLExport int section(std::string&,Geometry::V3D&); - -template DLLExport int convert(const std::string&,Geometry::V3D&); - -/// \endcond TEMPLATE - -} // NAMESPACE StrFunc - -} // NAMESPACE Mantid diff --git a/Code/Mantid/Framework/Geometry/src/Objects/Object.cpp b/Code/Mantid/Framework/Geometry/src/Objects/Object.cpp index 5b8daf008b4ce447c30aad7d39cceb724b877d89..ab162f1ad3b739cb6e96b4c13c1e3d3b5d5721bc 100644 --- a/Code/Mantid/Framework/Geometry/src/Objects/Object.cpp +++ b/Code/Mantid/Framework/Geometry/src/Objects/Object.cpp @@ -1,6 +1,6 @@ #include "MantidGeometry/Objects/Object.h" #include "MantidKernel/Logger.h" -#include "MantidKernel/Support.h" +#include "MantidKernel/Strings.h" #include "MantidKernel/Exception.h" #include "MantidGeometry/Objects/Rules.h" #include "MantidGeometry/Objects/Track.h" @@ -15,7 +15,7 @@ #include "MantidGeometry/Rendering/CacheGeometryHandler.h" #include "MantidGeometry/Rendering/vtkGeometryCacheReader.h" #include "MantidGeometry/Rendering/vtkGeometryCacheWriter.h" -#include "MantidGeometry/Math/RegexSupport.h" +#include "MantidKernel/RegexStrings.h" #include "MantidGeometry/Tolerance.h" #include <deque> #include <stack> @@ -126,7 +126,7 @@ namespace Mantid // Split line std::string part; const boost::regex letters("[a-zA-Z]"); // Does the string now contain junk... - if (StrFunc::StrLook(Ln, letters)) + if (Mantid::Kernel::Strings::StrLook(Ln, letters)) return 0; if (procString(Ln)) // this currently does not fail: @@ -169,7 +169,7 @@ namespace Mantid pos++; cx << TopStr.substr(0, pos); // Everything including the # int cN(0); - const int nLen = StrFunc::convPartNum(TopStr.substr(pos), cN); + const int nLen = Mantid::Kernel::Strings::convPartNum(TopStr.substr(pos), cN); if (nLen > 0) { cx << "("; @@ -329,7 +329,7 @@ namespace Mantid int type = 0; //intersection //plus 1 to skip 'R' - if (Rstart == Ln.size() || !StrFunc::convert(Ln.c_str() + Rstart + 1, Ra) || Rlist.find(Ra) + if (Rstart == Ln.size() || !Mantid::Kernel::Strings::convert(Ln.c_str() + Rstart + 1, Ra) || Rlist.find(Ra) == Rlist.end()) return 0; @@ -338,7 +338,7 @@ namespace Mantid if (Ln[Rend] == ':') type = 1; //make union } - if (Rend == Ln.size() || !StrFunc::convert(Ln.c_str() + Rend + 1, Rb) || Rlist.find(Rb) == Rlist.end()) + if (Rend == Ln.size() || !Mantid::Kernel::Strings::convert(Ln.c_str() + Rend + 1, Rb) || Rlist.find(Rb) == Rlist.end()) return 0; // Get end of number (digital) @@ -678,7 +678,7 @@ namespace Mantid std::ostringstream cx; cx.precision(10); cx << str(); - StrFunc::writeMCNPX(cx.str(), OX); + Mantid::Kernel::Strings::writeMCNPX(cx.str(), OX); return; } @@ -708,7 +708,7 @@ namespace Mantid if (isdigit(Ln[i]) || Ln[i] == '-') { int SN; - int nLen = StrFunc::convPartNum(Ln.substr(i), SN); + int nLen = Mantid::Kernel::Strings::convPartNum(Ln.substr(i), SN); if (!nLen) throw std::invalid_argument("Invalid surface string in Object::ProcString : " + Line); // Process #Number diff --git a/Code/Mantid/Framework/Geometry/src/Surfaces/Cone.cpp b/Code/Mantid/Framework/Geometry/src/Surfaces/Cone.cpp index 5450147450248e2c2a8778ea1ca070a3c1e220a7..0412acfbea01df2bcb95eed32c406e27bb72f853 100644 --- a/Code/Mantid/Framework/Geometry/src/Surfaces/Cone.cpp +++ b/Code/Mantid/Framework/Geometry/src/Surfaces/Cone.cpp @@ -13,7 +13,7 @@ #include "MantidKernel/Logger.h" -#include "MantidKernel/Support.h" +#include "MantidKernel/Strings.h" #include "MantidGeometry/Tolerance.h" #include "MantidGeometry/Math/Matrix.h" #include "MantidGeometry/V3D.h" @@ -110,7 +110,7 @@ namespace Mantid { std::string Line=Pstr; std::string item; - if (!StrFunc::section(Line,item) || + if (!Mantid::Kernel::Strings::section(Line,item) || tolower(item[0])!='k' || item.length()<2 || item.length()>3) return -1; @@ -126,19 +126,19 @@ namespace Mantid if (itemPt==1) // kx type cone { - if (!StrFunc::section(Line,cent[ptype])) + if (!Mantid::Kernel::Strings::section(Line,cent[ptype])) return -3; } else { int index; - for(index=0;index<3 && StrFunc::section(Line,cent[index]);index++); + for(index=0;index<3 && Mantid::Kernel::Strings::section(Line,cent[index]);index++); if (index!=3) return -4; } // The user must enter t^2 which is tan^2(angle) for MCNPX double tanAng; - if (!StrFunc::section(Line,tanAng)) + if (!Mantid::Kernel::Strings::section(Line,tanAng)) return -5; Centre=Geometry::V3D(cent); @@ -380,7 +380,7 @@ namespace Mantid } const double TA=tan((M_PI*alpha)/180.0); // tan^2(angle) cx<<TA*TA; - StrFunc::writeMCNPX(cx.str(),OX); + Mantid::Kernel::Strings::writeMCNPX(cx.str(),OX); return; } diff --git a/Code/Mantid/Framework/Geometry/src/Surfaces/Cylinder.cpp b/Code/Mantid/Framework/Geometry/src/Surfaces/Cylinder.cpp index 8a0b1747e6b2726682737eb796215fc4203af439..43c93d7d44b8291967b9dbdce8abbe890f5358f9 100644 --- a/Code/Mantid/Framework/Geometry/src/Surfaces/Cylinder.cpp +++ b/Code/Mantid/Framework/Geometry/src/Surfaces/Cylinder.cpp @@ -1,6 +1,6 @@ #include "MantidGeometry/Surfaces/Cylinder.h" #include "MantidKernel/Logger.h" -#include "MantidKernel/Support.h" +#include "MantidKernel/Strings.h" #include "MantidGeometry/Tolerance.h" #include "MantidGeometry/Math/Matrix.h" #include <cfloat> @@ -91,7 +91,7 @@ Cylinder::setSurface(const std::string& Pstr) std::string Line=Pstr; std::string item; - if (!StrFunc::section(Line,item) || + if (!Mantid::Kernel::Strings::section(Line,item) || tolower(item[0])!='c' || item.length()<2 || item.length()>3) return errDesc; @@ -109,7 +109,7 @@ Cylinder::setSurface(const std::string& Pstr) { // get the other two coordinates int index((!ptype) ? 1 : 0); - while(index<3 && StrFunc::section(Line,cent[index])) + while(index<3 && Mantid::Kernel::Strings::section(Line,cent[index])) { index++; if (index==ptype) @@ -120,7 +120,7 @@ Cylinder::setSurface(const std::string& Pstr) } // Now get radius double R; - if (!StrFunc::section(Line,R) || R<=0.0) + if (!Mantid::Kernel::Strings::section(Line,R) || R<=0.0) return errRadius; Centre=Geometry::V3D(cent); @@ -350,7 +350,7 @@ Cylinder::write(std::ostream& OX) const cx<< Radius; } - StrFunc::writeMCNPX(cx.str(),OX); + Mantid::Kernel::Strings::writeMCNPX(cx.str(),OX); return; } diff --git a/Code/Mantid/Framework/Geometry/src/Surfaces/General.cpp b/Code/Mantid/Framework/Geometry/src/Surfaces/General.cpp index f69f1217a8412bd0aeb2492e15ae9464f5da69fd..cae5a4d5cb5c4f5c6442845279d88f4846d66a4a 100644 --- a/Code/Mantid/Framework/Geometry/src/Surfaces/General.cpp +++ b/Code/Mantid/Framework/Geometry/src/Surfaces/General.cpp @@ -1,6 +1,6 @@ #include "MantidGeometry/Surfaces/General.h" #include "MantidKernel/Logger.h" -#include "MantidKernel/Support.h" +#include "MantidKernel/Strings.h" #include "MantidGeometry/Math/Matrix.h" namespace Mantid @@ -76,7 +76,7 @@ General::setSurface(const std::string& Pstr) { std::string Line=Pstr; std::string item; - if (!StrFunc::section(Line,item) || item.length()!=2 || + if (!Mantid::Kernel::Strings::section(Line,item) || item.length()!=2 || (tolower(item[0])!='g' && tolower(item[0]!='s')) || tolower(item[1])!='q') return -1; @@ -84,7 +84,7 @@ General::setSurface(const std::string& Pstr) double num[10]; int index; for(index=0;index<10 && - StrFunc::section(Line,num[index]);index++); + Mantid::Kernel::Strings::section(Line,num[index]);index++); if (index!=10) return -2; diff --git a/Code/Mantid/Framework/Geometry/src/Surfaces/Line.cpp b/Code/Mantid/Framework/Geometry/src/Surfaces/Line.cpp index 9dd88f242a9a697b1385196d53e5faa5ed5b56ac..098c81066c21ab1c4e13740a78ea1d36af76d86c 100644 --- a/Code/Mantid/Framework/Geometry/src/Surfaces/Line.cpp +++ b/Code/Mantid/Framework/Geometry/src/Surfaces/Line.cpp @@ -1,6 +1,6 @@ #include "MantidGeometry/Surfaces/Line.h" #include "MantidKernel/Logger.h" -#include "MantidKernel/Support.h" +#include "MantidKernel/Strings.h" #include "MantidGeometry/Math/mathSupport.h" #include "MantidGeometry/Math/Matrix.h" #include "MantidGeometry/Surfaces/Quadratic.h" diff --git a/Code/Mantid/Framework/Geometry/src/Surfaces/LineIntersectVisit.cpp b/Code/Mantid/Framework/Geometry/src/Surfaces/LineIntersectVisit.cpp index f539ab6348a9d44b7de106112d84ce4098c319bd..1768ff627a21398fcce1b1de03029b3b5fd15424 100644 --- a/Code/Mantid/Framework/Geometry/src/Surfaces/LineIntersectVisit.cpp +++ b/Code/Mantid/Framework/Geometry/src/Surfaces/LineIntersectVisit.cpp @@ -1,6 +1,6 @@ #include "MantidGeometry/Surfaces/LineIntersectVisit.h" #include "MantidKernel/Logger.h" -#include "MantidKernel/Support.h" +#include "MantidKernel/Strings.h" #include "MantidKernel/Exception.h" #include "MantidGeometry/Surfaces/Surface.h" #include "MantidGeometry/Surfaces/Quadratic.h" diff --git a/Code/Mantid/Framework/Geometry/src/Surfaces/Plane.cpp b/Code/Mantid/Framework/Geometry/src/Surfaces/Plane.cpp index 613868b5b07164acad83a3baac4b6a523f3c1f89..0018830e8f5cea190d570e4f74b5bb83cd942160 100644 --- a/Code/Mantid/Framework/Geometry/src/Surfaces/Plane.cpp +++ b/Code/Mantid/Framework/Geometry/src/Surfaces/Plane.cpp @@ -1,6 +1,6 @@ #include "MantidGeometry/Surfaces/Plane.h" #include "MantidKernel/Logger.h" -#include "MantidKernel/Support.h" +#include "MantidKernel/Strings.h" #include "MantidGeometry/Tolerance.h" #include <cfloat> @@ -81,7 +81,7 @@ Plane::setSurface(const std::string& Pstr) std::string Line=Pstr; std::string item; - if (!StrFunc::section(Line,item) || tolower(item[0])!='p') + if (!Mantid::Kernel::Strings::section(Line,item) || tolower(item[0])!='p') return -1; // Only 3 need to be declared double surf[9]={0.0,0,0,0,0}; @@ -89,7 +89,7 @@ Plane::setSurface(const std::string& Pstr) if (item.size()==1) // PROCESS BASIC PLANE: { int cnt; - for(cnt=0;cnt<9 && StrFunc::section(Line,surf[cnt]);cnt++); + for(cnt=0;cnt<9 && Mantid::Kernel::Strings::section(Line,surf[cnt]);cnt++); if (cnt!=4 && cnt!=9) return -3; @@ -119,7 +119,7 @@ Plane::setSurface(const std::string& Pstr) if (ptype<0 || ptype>2) // Not x,y,z return -5; surf[ptype]=1.0; - if (!StrFunc::convert(Line,Dist)) + if (!Mantid::Kernel::Strings::convert(Line,Dist)) return -6; //Too short or no number NormV=Geometry::V3D(surf[0],surf[1],surf[2]); } @@ -305,7 +305,7 @@ void Plane::write(std::ostream& OX) const else cx<<"p"<<"xyz"[ptype-1]<<" "<<Dist; - StrFunc::writeMCNPX(cx.str(),OX); + Mantid::Kernel::Strings::writeMCNPX(cx.str(),OX); return; } diff --git a/Code/Mantid/Framework/Geometry/src/Surfaces/Quadratic.cpp b/Code/Mantid/Framework/Geometry/src/Surfaces/Quadratic.cpp index bb95de990662d61c06cdb9f4507695fb50d0af79..568e5dfcfd9df69a04f8539790dc4ed2af79ed25 100644 --- a/Code/Mantid/Framework/Geometry/src/Surfaces/Quadratic.cpp +++ b/Code/Mantid/Framework/Geometry/src/Surfaces/Quadratic.cpp @@ -24,7 +24,7 @@ #include "MantidGeometry/Surfaces/Quadratic.h" #include "MantidKernel/Logger.h" -#include "MantidKernel/Support.h" +#include "MantidKernel/Strings.h" namespace Mantid { @@ -387,7 +387,7 @@ Quadratic::write(std::ostream& OX) const cx<<" "<<BaseEqn[4]<<" "; for(int i=6;i<10;i++) cx<<" "<<BaseEqn[i]<<" "; - StrFunc::writeMCNPX(cx.str(),OX); + Mantid::Kernel::Strings::writeMCNPX(cx.str(),OX); return; } diff --git a/Code/Mantid/Framework/Geometry/src/Surfaces/Sphere.cpp b/Code/Mantid/Framework/Geometry/src/Surfaces/Sphere.cpp index 04f1559d0e1296db083dc1a9580b03e42ed7fafe..b6dcc3ec3d8b18c740d6d0bef75dde8b9a971797 100644 --- a/Code/Mantid/Framework/Geometry/src/Surfaces/Sphere.cpp +++ b/Code/Mantid/Framework/Geometry/src/Surfaces/Sphere.cpp @@ -1,6 +1,6 @@ #include "MantidGeometry/Surfaces/Sphere.h" #include "MantidKernel/Logger.h" -#include "MantidKernel/Support.h" +#include "MantidKernel/Strings.h" #include "MantidGeometry/Tolerance.h" namespace Mantid @@ -82,7 +82,7 @@ namespace Mantid { std::string Line=Pstr; std::string item; - if (!StrFunc::section(Line,item) || + if (!Mantid::Kernel::Strings::section(Line,item) || tolower(item[0])!='s' || item.length()>2) return -1; @@ -95,21 +95,21 @@ namespace Mantid const int pType=static_cast<int>(tolower(item[1])-'x'); if (pType<0 || pType>2) return -3; - if (!StrFunc::section(Line,cent[pType])) + if (!Mantid::Kernel::Strings::section(Line,cent[pType])) return -4; } } else if (item.length()==1) { int index; - for(index=0;index<3 && StrFunc::section(Line,cent[index]); + for(index=0;index<3 && Mantid::Kernel::Strings::section(Line,cent[index]); index++); if (index!=3) return -5; } else return -6; - if (!StrFunc::section(Line,R)) + if (!Mantid::Kernel::Strings::section(Line,R)) return -7; Centre=Geometry::V3D(cent); @@ -256,7 +256,7 @@ namespace Mantid { cx<<"s "<<Centre<<" "<<Radius; } - StrFunc::writeMCNPX(cx.str(),OX); + Mantid::Kernel::Strings::writeMCNPX(cx.str(),OX); return; } /** diff --git a/Code/Mantid/Framework/Geometry/src/Surfaces/Surface.cpp b/Code/Mantid/Framework/Geometry/src/Surfaces/Surface.cpp index c22f3b01155dbc823727f7c2ef74285b26f3c381..22dc23edc6b8834cae5e6afa7427880b995b7e69 100644 --- a/Code/Mantid/Framework/Geometry/src/Surfaces/Surface.cpp +++ b/Code/Mantid/Framework/Geometry/src/Surfaces/Surface.cpp @@ -14,7 +14,7 @@ #include "MantidKernel/Exception.h" #include "MantidKernel/Logger.h" -#include "MantidKernel/Support.h" +#include "MantidKernel/Strings.h" #include "MantidGeometry/Math/mathSupport.h" #include "MantidGeometry/Math/Matrix.h" #include "MantidGeometry/V3D.h" diff --git a/Code/Mantid/Framework/Geometry/src/Surfaces/SurfaceFactory.cpp b/Code/Mantid/Framework/Geometry/src/Surfaces/SurfaceFactory.cpp index 71965c522d3779e10d31c947c020f991f2215e41..d6e94027777d62142132a57b479fc76422e1e761 100644 --- a/Code/Mantid/Framework/Geometry/src/Surfaces/SurfaceFactory.cpp +++ b/Code/Mantid/Framework/Geometry/src/Surfaces/SurfaceFactory.cpp @@ -15,7 +15,7 @@ #include "MantidGeometry/Math/Matrix.h" #include "MantidGeometry/V3D.h" -#include "MantidKernel/Support.h" +#include "MantidKernel/Strings.h" #include "MantidGeometry/Surfaces/BaseVisit.h" #include "MantidGeometry/Surfaces/Surface.h" #include "MantidGeometry/Surfaces/Quadratic.h" @@ -160,7 +160,7 @@ SurfaceFactory::processLine(const std::string& Line) const */ { std::string key; - if (!StrFunc::convert(Line,key)) + if (!Mantid::Kernel::Strings::convert(Line,key)) throw Kernel::Exception::NotFoundError("SurfaceFactory::processLine",Line); Surface *X = createSurfaceID(key); diff --git a/Code/Mantid/Framework/Geometry/src/Surfaces/Torus.cpp b/Code/Mantid/Framework/Geometry/src/Surfaces/Torus.cpp index 95836d985762decfed92af7c9cfe6866b16b2044..cc69115a2eab668173c73ecdb3e85172024e7027 100644 --- a/Code/Mantid/Framework/Geometry/src/Surfaces/Torus.cpp +++ b/Code/Mantid/Framework/Geometry/src/Surfaces/Torus.cpp @@ -11,7 +11,7 @@ #include <algorithm> #include "MantidKernel/Logger.h" -#include "MantidKernel/Support.h" +#include "MantidKernel/Strings.h" #include "MantidKernel/Exception.h" #include "MantidGeometry/Tolerance.h" #include "MantidGeometry/Math/Matrix.h" @@ -112,6 +112,35 @@ Torus::operator==(const Torus& A) const return 1; } + +/* + takes a character string and evaluates + the first <T> object. The string is then filled with + spaces upto the end of the <T> object + @param out :: place for output + @param A :: string for input and output. + @return 1 on success 0 on failure +*/ +int sectionV3D(std::string& A,Mantid::Geometry::V3D& out) +{ + if (A.empty()) return 0; + std::istringstream cx; + Mantid::Geometry::V3D retval; + cx.str(A); + cx.clear(); + cx>>retval; + if (cx.fail()) + return 0; + const std::streamoff xpt = cx.tellg(); + const char xc=cx.get(); + if (!cx.fail() && !isspace(xc)) + return 0; + A.erase(0, static_cast<unsigned int>(xpt)); + out=retval; + return 1; +} + + int Torus::setSurface(const std::string& Pstr) /** @@ -129,7 +158,7 @@ Torus::setSurface(const std::string& Pstr) std::string Line=Pstr; std::string item; - if (!StrFunc::section(Line,item) || + if (!Mantid::Kernel::Strings::section(Line,item) || tolower(item[0])!='t' || item.length()!=3) return errDesc; @@ -145,9 +174,9 @@ Torus::setSurface(const std::string& Pstr) // Torus on X/Y/Z axis Norm[ptype]=1.0; - if (!StrFunc::section(Line,Centre)) + if (!sectionV3D(Line,Centre)) return errCent; - if (!StrFunc::section(Line,PtVec)) + if (!sectionV3D(Line,PtVec)) return errNormal; Iradius=PtVec[1]; @@ -294,7 +323,7 @@ Torus::write(std::ostream& OX) const // Name and transform cx<<Centre<<" "<<Displacement<<" "<<Iradius<<" "<<Dradius; - StrFunc::writeMCNPX(cx.str(),OX); + Mantid::Kernel::Strings::writeMCNPX(cx.str(),OX); return; } diff --git a/Code/Mantid/Framework/Kernel/CMakeLists.txt b/Code/Mantid/Framework/Kernel/CMakeLists.txt index 08b912d28e2bb0f9ce5d2ec438f9193865988a99..ff7acb6219818cde05e9ecdcf20f745bc90374fd 100644 --- a/Code/Mantid/Framework/Kernel/CMakeLists.txt +++ b/Code/Mantid/Framework/Kernel/CMakeLists.txt @@ -34,11 +34,11 @@ set ( SRC_FILES src/ArrayBoundedValidator.cpp src/PropertyManagerOwner.cpp src/PropertyWithValue.cpp src/RebinParamsValidator.cpp + src/RegexStrings.cpp src/SignalChannel.cpp src/SingletonHolder.cpp src/Statistics.cpp - src/SupportBasic.cpp - src/SupportKernel.cpp + src/Strings.cpp src/System.cpp src/TestChannel.cpp src/ThreadSafeLogStream.cpp @@ -127,11 +127,11 @@ set ( INC_FILES inc/MantidKernel/ArrayBoundedValidator.h inc/MantidKernel/PropertyWithValue.h inc/MantidKernel/RandomNumberGenerator.h inc/MantidKernel/RebinParamsValidator.h + inc/MantidKernel/RegexStrings.h inc/MantidKernel/SignalChannel.h inc/MantidKernel/SingletonHolder.h inc/MantidKernel/Statistics.h - inc/MantidKernel/Support.h - inc/MantidKernel/SupportTempCode.h + inc/MantidKernel/Strings.h inc/MantidKernel/System.h inc/MantidKernel/TestChannel.h inc/MantidKernel/ThreadScheduler.h @@ -182,9 +182,10 @@ set ( TEST_FILES test/ArrayBoundedValidatorTest.h test/RandomNumberGeneratorTest.h test/RebinHistogramTest.h test/RebinParamsValidatorTest.h + test/RegexStringsTest.h test/SignalChannelTest.h test/StatisticsTest.h - test/SupportTest.h + test/StringsTest.h test/ThreadPoolTest.h test/TimerTest.h test/TimeSeriesPropertyTest.h diff --git a/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Math/RegexSupport.h b/Code/Mantid/Framework/Kernel/inc/MantidKernel/RegexStrings.h similarity index 94% rename from Code/Mantid/Framework/Geometry/inc/MantidGeometry/Math/RegexSupport.h rename to Code/Mantid/Framework/Kernel/inc/MantidKernel/RegexStrings.h index 59455df9fe6845c82b94b0f8e5414fb4fb21728c..102c8692548b8bbe11cad669a8e79f1084da1588 100644 --- a/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Math/RegexSupport.h +++ b/Code/Mantid/Framework/Kernel/inc/MantidKernel/RegexStrings.h @@ -1,13 +1,14 @@ #ifndef REGEXSUPPORT_H #define REGEXSUPPORT_H -#include "MantidKernel/Support.h" +#include "MantidKernel/Strings.h" #include <boost/regex.hpp> namespace Mantid { - -namespace StrFunc +namespace Kernel +{ +namespace Strings { /// Find if a pattern matches a string template<typename T> DLLExport int StrComp(const char*,const boost::regex&,T&,const int=0); @@ -47,8 +48,10 @@ template<typename T> DLLExport int findComp(std::istream&,const boost::regex&,T& /// Finds a pattern in a file DLLExport int findPattern(std::istream&,const boost::regex&,std::string&); -} +} //NAMESPACE Strings + +} //NAMESPACE Kernel } //NAMESPACE Mantid #endif diff --git a/Code/Mantid/Framework/Kernel/inc/MantidKernel/Support.h b/Code/Mantid/Framework/Kernel/inc/MantidKernel/Strings.h similarity index 95% rename from Code/Mantid/Framework/Kernel/inc/MantidKernel/Support.h rename to Code/Mantid/Framework/Kernel/inc/MantidKernel/Strings.h index a16a7e7c8e00d70ab9f856b539d82ee68e0fe633..2df50b85a8b6430af1984bebf39a457428b09036 100644 --- a/Code/Mantid/Framework/Kernel/inc/MantidKernel/Support.h +++ b/Code/Mantid/Framework/Kernel/inc/MantidKernel/Strings.h @@ -1,5 +1,5 @@ -#ifndef MANTID_STRFUNC_SUPPORT_H_ -#define MANTID_STRFUNC_SUPPORT_H_ +#ifndef MANTID_KERNEL_STRINGS_H +#define MANTID_KERNEL_STRINGS_H //---------------------------------------------------------------------- // Includes @@ -11,6 +11,9 @@ namespace Mantid { +namespace Kernel +{ + /** Holds support functions for strings. @author S. Ansell @@ -35,8 +38,9 @@ namespace Mantid File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>. Code Documentation is available at: <http://doxygen.mantidproject.org> -v*/ -namespace StrFunc +*/ + +namespace Strings { /// determine if a character group exists in a string DLLExport int confirmStr(const std::string& S,const std::string& fullPhrase); @@ -92,13 +96,14 @@ int writeFile(const std::string& Fname,const V<T,A>& X,const V<T,A>& Y); template<template<typename T,typename A> class V,typename T,typename A> int writeFile(const std::string& Fname,const V<T,A>& X,const V<T,A>& Y,const V<T,A>& Err); - /// Convert a VAX number to x86 little eindien float getVAXnum(const float A); -} // NAMESPACE StrFunc +} // NAMESPACE Strings + +} // NAMESPACE Kernel } // NAMESPACE Mantid -#endif //MANTID_STRFUNC_SUPPORT_H_ +#endif //MANTID_KERNEL_STRINGS_H diff --git a/Code/Mantid/Framework/Kernel/inc/MantidKernel/SupportTempCode.h b/Code/Mantid/Framework/Kernel/inc/MantidKernel/SupportTempCode.h deleted file mode 100644 index 53d797f95254f776a48c0e4f5320fa2aa25631fb..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/Kernel/inc/MantidKernel/SupportTempCode.h +++ /dev/null @@ -1,348 +0,0 @@ -#ifndef StrFunc_SupportTempCode_h -#define StrFunc_SupportTempCode_h - -#include <string.h> - -namespace Mantid -{ -namespace StrFunc -{ - -/** - Takes a character string and evaluates - the first [typename T] object. The string is then - erase upt to the end of number. - The diffierence between this and section is that - it allows trailing characters after the number. - @param out :: place for output - @param A :: string to process - @return 1 on success 0 on failure - */ -template<typename T> -int sectPartNum(std::string& A,T& out) -{ - if (A.empty()) - return 0; - - std::istringstream cx; - T retval; - cx.str(A); - cx.clear(); - cx>>retval; - const std::streamoff xpt = cx.tellg(); - if (xpt < 0) - return 0; - A.erase(0,static_cast<unsigned int>(xpt)); - out=retval; - return 1; -} - -/** - Takes a character string and evaluates - the first [typename T] object. The string is then filled with - spaces upto the end of the [typename T] object - @param out :: place for output - @param cA :: char array for input and output. - @return 1 on success 0 on failure - */ -template<typename T> -int section(char* cA,T& out) -{ - if (!cA) return 0; - std::string sA(cA); - const int item(section(sA,out)); - if (item) - { - strcpy(cA,sA.c_str()); - return 1; - } - return 0; -} - -/* - takes a character string and evaluates - the first <T> object. The string is then filled with - spaces upto the end of the <T> object - @param out :: place for output - @param A :: string for input and output. - @return 1 on success 0 on failure -*/ -template<typename T> -int section(std::string& A,T& out) -{ - if (A.empty()) return 0; - std::istringstream cx; - T retval; - cx.str(A); - cx.clear(); - cx>>retval; - if (cx.fail()) - return 0; - const std::streamoff xpt = cx.tellg(); - const char xc=cx.get(); - if (!cx.fail() && !isspace(xc)) - return 0; - A.erase(0, static_cast<unsigned int>(xpt)); - out=retval; - return 1; -} - -/* - Takes a character string and evaluates - the first [T] object. The string is then filled with - spaces upto the end of the [T] object. - This version deals with MCNPX numbers. Those - are numbers that are crushed together like - - 5.4938e+04-3.32923e-6 - @param out :: place for output - @param A :: string for input and output. - @return 1 on success 0 on failure -*/ -template<typename T> -int sectionMCNPX(std::string& A,T& out) -{ - if (A.empty()) return 0; - std::istringstream cx; - T retval; - cx.str(A); - cx.clear(); - cx>>retval; - if (!cx.fail()) - { - const std::streamoff xpt = cx.tellg(); - if( xpt < 0 ) - { - return 0; - } - const char xc=cx.get(); - if (!cx.fail() && !isspace(xc) && (xc!='-' || xpt<5)) - { - return 0; - } - A.erase(0, static_cast<unsigned int>(xpt)); - out=retval; - return 1; - } - return 0; -} - -/** - Takes a character string and evaluates - the first [typename T] object. The string is then - erase upto the end of number. - The diffierence between this and convert is that - it allows trailing characters after the number. - @param out :: place for output - @param A :: string to process - @retval number of char read on success - @retval 0 on failure - */ -template<typename T> -int convPartNum(const std::string& A,T& out) -{ - if (A.empty()) return 0; - std::istringstream cx; - T retval; - cx.str(A); - cx.clear(); - cx>>retval; - const std::streamoff xpt = cx.tellg(); - if (xpt<0) - return 0; - out=retval; - return static_cast<int>(xpt); -} - -/** - Convert a string into a value - @param A :: string to pass - @param out :: value if found - @return 0 on failure 1 on success -*/ -template<typename T> -int convert(const std::string& A,T& out) -{ - if (A.empty()) return 0; - std::istringstream cx; - T retval; - cx.str(A); - cx.clear(); - cx>>retval; - if (cx.fail()) - return 0; - const char clast=cx.get(); - if (!cx.fail() && !isspace(clast)) - return 0; - out=retval; - return 1; -} - -/** - Convert a string into a value - @param A :: string to pass - @param out :: value if found - @return 0 on failure 1 on success -*/ -template<typename T> -int convert(const char* A,T& out) -{ - // No string, no conversion - if (!A) return 0; - std::string Cx=A; - return convert(Cx,out); -} - -/** - Write out the three vectors into a file of type dc 9 - @param step :: parameter to control x-step (starts from zero) - @param Y :: Y column - @param Fname :: Name of the file - @return 0 on success and -ve on failure -*/ -template<template<typename T,typename A> class V,typename T,typename A> -int writeFile(const std::string& Fname,const T step, const V<T,A>& Y) -{ - V<T,A> Ex; // Empty vector - V<T,A> X; // Empty vector - for(unsigned int i=0;i<Y.size();i++) - X.push_back(i*step); - - return writeFile(Fname,X,Y,Ex); -} - -/** - Write out the three vectors into a file of type dc 9 - @param X :: X column - @param Y :: Y column - @param Fname :: Name of the file - @return 0 on success and -ve on failure -*/ -template<template<typename T,typename A> class V,typename T,typename A> -int writeFile(const std::string& Fname,const V<T,A>& X,const V<T,A>& Y) -{ - V<T,A> Ex; // Empty vector/list - return writeFile(Fname,X,Y,Ex); // don't need to specific ?? -} - -/** - Write out the three container into a file with - column free-formated data in the form : - - X Y Err - If Err does not exist (or is short) 0.0 is substituted. - @param X :: X column - @param Y :: Y column - @param Err :: Err column - @param Fname :: Name of the file - @return 0 on success and -ve on failure -*/ -template<template<typename T,typename A> class V,typename T,typename A> -int writeFile(const std::string& Fname,const V<T,A>& X,const V<T,A>& Y,const V<T,A>& Err) -{ - const int Npts(X.size()>Y.size() ? Y.size() : X.size()); - const int Epts(Npts>static_cast<int>(Err.size()) ? Err.size() : Npts); - - std::ofstream FX; - - FX.open(Fname.c_str()); - if (!FX.good()) - return -1; - - FX<<"# "<<Npts<<" "<<Epts<<std::endl; - FX.precision(10); - FX.setf(std::ios::scientific,std::ios::floatfield); - typename V<T,A>::const_iterator xPt=X.begin(); - typename V<T,A>::const_iterator yPt=Y.begin(); - typename V<T,A>::const_iterator ePt=(Epts ? Err.begin() : Y.begin()); - - // Double loop to include/exclude a short error stack - int eCount=0; - for(;eCount<Epts;eCount++) - { - FX<<(*xPt)<<" "<<(*yPt)<<" "<<(*ePt)<<std::endl; - xPt++; - yPt++; - ePt++; - } - for(;eCount<Npts;eCount++) - { - FX<<(*xPt)<<" "<<(*yPt)<<" 0.0"<<std::endl; - xPt++; - yPt++; - } - FX.close(); - return 0; -} - -/** - Call to read in various values in position x1,x2,x3 from the - line. Note to avoid the dependency on crossSort this needs - to be call IN ORDER - @param Line :: string to read - @param Index :: Indexes to read - @param Out :: OutValues [unchanged if not read] - @retval 0 :: success - @retval -ve on failure. -*/ -template<typename T> -int setValues(const std::string& Line,const std::vector<int>& Index,std::vector<T>& Out) -{ - if (Index.empty()) - return 0; - - if(Out.size()!=Index.size()) - return -1; -// throw ColErr::MisMatch<int>(Index.size(),Out.size(), -// "StrFunc::setValues"); - - std::string modLine=Line; - std::vector<int> sIndex(Index); // Copy for sorting - std::vector<int> OPt(Index.size()); - for(unsigned int i=0;i<Index.size();i++) - OPt[i]=i; - - - // mathFunc::crossSort(sIndex,OPt); - - typedef std::vector<int>::const_iterator iVecIter; - std::vector<int>::const_iterator sc=sIndex.begin(); - std::vector<int>::const_iterator oc=OPt.begin(); - int cnt(0); - T value; - std::string dump; - while(sc!=sIndex.end() && *sc<0) - { - sc++; - oc++; - } - - while(sc!=sIndex.end()) - { - if (*sc==cnt) - { - if (!section(modLine,value)) - return -1-distance(static_cast<iVecIter>(sIndex.begin()),sc); - // this loop handles repeat units - do - { - Out[*oc]=value; - sc++; - oc++; - } while (sc!=sIndex.end() && *sc==cnt); - } - else - { - if (!section(modLine,dump)) - return -1-distance(static_cast<iVecIter>(sIndex.begin()),sc); - } - cnt++; // Add only to cnt [sc/oc in while loop] - } - // Success since loop only gets here if sc is exhaused. - return 0; -} - -} // NAMESPACE StrFunc - -} // NAMESPACE Mantid - - -#endif diff --git a/Code/Mantid/Framework/Kernel/src/ConfigService.cpp b/Code/Mantid/Framework/Kernel/src/ConfigService.cpp index 9e2cb0a6b009e51ef666ce2cc70aef70618e0c83..ad026eae7be2fc837ec2da6887ad63130b2a4f02 100644 --- a/Code/Mantid/Framework/Kernel/src/ConfigService.cpp +++ b/Code/Mantid/Framework/Kernel/src/ConfigService.cpp @@ -3,7 +3,7 @@ //---------------------------------------------------------------------- #include "MantidKernel/ConfigService.h" #include "MantidKernel/MantidVersion.h" -#include "MantidKernel/Support.h" +#include "MantidKernel/Strings.h" #include "MantidKernel/Logger.h" #include "MantidKernel/FilterChannel.h" #include "MantidKernel/SignalChannel.h" @@ -780,7 +780,7 @@ template<typename T> int ConfigServiceImpl::getValue(const std::string& keyName, T& out) { std::string strValue = getString(keyName); - int result = StrFunc::convert(strValue, out); + int result = Mantid::Kernel::Strings::convert(strValue, out); return result; } diff --git a/Code/Mantid/Framework/Kernel/src/DllOpen.cpp b/Code/Mantid/Framework/Kernel/src/DllOpen.cpp index 97e9ef7fa7b12a2a2832fb4afe1a5497be78c9b9..5ed53a68b9929f5e1a7c94a99709eb8a5cf77fe1 100644 --- a/Code/Mantid/Framework/Kernel/src/DllOpen.cpp +++ b/Code/Mantid/Framework/Kernel/src/DllOpen.cpp @@ -17,7 +17,7 @@ #include <dlfcn.h> #endif /* _WIN32 */ -#include "MantidKernel/Support.h" +#include "MantidKernel/Strings.h" #include "MantidKernel/DllOpen.h" #include "MantidKernel/Logger.h" diff --git a/Code/Mantid/Framework/Kernel/src/FacilityInfo.cpp b/Code/Mantid/Framework/Kernel/src/FacilityInfo.cpp index 7b97b27af797281dfe0589969e579b9593540f86..395ab2eace387f9cbeae9503b1265eec1db311d1 100644 --- a/Code/Mantid/Framework/Kernel/src/FacilityInfo.cpp +++ b/Code/Mantid/Framework/Kernel/src/FacilityInfo.cpp @@ -2,7 +2,7 @@ // Includes //---------------------------------------------------------------------- #include "MantidKernel/FacilityInfo.h" -#include "MantidKernel/Support.h" +#include "MantidKernel/Strings.h" #include "MantidKernel/Exception.h" #include "MantidKernel/ConfigService.h" @@ -34,7 +34,7 @@ FacilityInfo::FacilityInfo(const Poco::XML::Element* elem) : throw std::runtime_error("Facility name is not defined"); } std::string paddingStr = elem->getAttribute("zeropadding"); - if ( paddingStr.empty() || !StrFunc::convert(paddingStr,m_zeroPadding) ) + if ( paddingStr.empty() || !Mantid::Kernel::Strings::convert(paddingStr,m_zeroPadding) ) { m_zeroPadding = 0; } diff --git a/Code/Mantid/Framework/Kernel/src/InstrumentInfo.cpp b/Code/Mantid/Framework/Kernel/src/InstrumentInfo.cpp index f9bdaeaa34a8ea26ee3f46f8ae8f3a9ac9d15177..31e0780cc89dd39097238ceaef7ea05535eef383 100644 --- a/Code/Mantid/Framework/Kernel/src/InstrumentInfo.cpp +++ b/Code/Mantid/Framework/Kernel/src/InstrumentInfo.cpp @@ -4,7 +4,7 @@ #include "MantidKernel/InstrumentInfo.h" #include "MantidKernel/FacilityInfo.h" #include "MantidKernel/Exception.h" -#include "MantidKernel/Support.h" +#include "MantidKernel/Strings.h" #include <Poco/DOM/Element.h> #include <Poco/DOM/NodeList.h> @@ -28,7 +28,7 @@ namespace Mantid :m_facility(f) { std::string paddingStr = elem->getAttribute("zeropadding"); - if ( paddingStr.empty() || !StrFunc::convert(paddingStr,m_zeroPadding) ) + if ( paddingStr.empty() || !Mantid::Kernel::Strings::convert(paddingStr,m_zeroPadding) ) { m_zeroPadding = f->zeroPadding(); } diff --git a/Code/Mantid/Framework/Geometry/src/Math/RegexSupport.cpp b/Code/Mantid/Framework/Kernel/src/RegexStrings.cpp similarity index 50% rename from Code/Mantid/Framework/Geometry/src/Math/RegexSupport.cpp rename to Code/Mantid/Framework/Kernel/src/RegexStrings.cpp index 492a9c0b6025d78a60fee1aa3b72b8d2f60600ed..b777eb3b0dc1b8429ccc37d4a4edfa3b998c9eae 100644 --- a/Code/Mantid/Framework/Geometry/src/Math/RegexSupport.cpp +++ b/Code/Mantid/Framework/Kernel/src/RegexStrings.cpp @@ -8,26 +8,26 @@ #include <algorithm> #include <functional> -#include "MantidGeometry/Math/RegexSupport.h" +#include "MantidKernel/RegexStrings.h" namespace Mantid { - -namespace StrFunc +namespace Kernel +{ +namespace Strings { +/** + Find the match in regular expression and places number in Aout + @param Text :: string to search + @param Re :: regular expression to use + @param Aout :: Place to put Unit found + @param compNum :: item to extract [0:N-1] + @return 0 on failure and 1 on success +*/ template<typename T> -int -StrComp(const std::string& Text,const boost::regex& Re,T& Aout, +int StrComp(const std::string& Text,const boost::regex& Re,T& Aout, const int compNum) - /** - Find the match in regular expression and places number in Aout - @param Text :: string to search - @param Re :: regular expression to use - @param Aout :: Place to put Unit found - @param compNum :: item to extract [0:N-1] - @return 0 on failure and 1 on success - */ { boost::sregex_iterator m1(Text.begin(),Text.end(),Re); boost::sregex_iterator empty; @@ -42,31 +42,29 @@ StrComp(const std::string& Text,const boost::regex& Re,T& Aout, } +/** + Find the match in regular expression and places number in Aout + @param Text :: string to search + @param Re :: regular expression to use + @param Aout :: Place to put Unit found + @param compNum :: item to extract [0:N-1] + @return 0 on failure and 1 on success +*/ template<typename T> -int -StrComp(const char* Text,const boost::regex& Re, +int StrComp(const char* Text,const boost::regex& Re, T& Aout,const int compNum) - /** - Find the match in regular expression and places number in Aout - @param Text :: string to search - @param Re :: regular expression to use - @param Aout :: Place to put Unit found - @param compNum :: item to extract [0:N-1] - @return 0 on failure and 1 on success - */ { return StrComp(std::string(Text),Re,Aout,compNum); } -int -StrLook(const char* Sx,const boost::regex& Re) - /** - Find the match in regular expression and return 1 if good match - @param Sx :: string to match - @param Re :: regular expression to use - @return 0 on failure and 1 on success - */ +/** + Find the match in regular expression and return 1 if good match + @param Sx :: string to match + @param Re :: regular expression to use + @return 0 on failure and 1 on success +*/ +int StrLook(const char* Sx,const boost::regex& Re) { boost::cmatch ans; if (boost::regex_search(Sx,ans,Re,boost::match_default)) @@ -74,14 +72,13 @@ StrLook(const char* Sx,const boost::regex& Re) return 0; } -int -StrLook(const std::string& Text,const boost::regex& Re) - /** - Find the match in regular expression and return 1 if good match - @param Text :: string to match - @param Re :: regular expression to use - @return 0 on failure and 1 on success - */ +/** + Find the match in regular expression and return 1 if good match + @param Text :: string to match + @param Re :: regular expression to use + @return 0 on failure and 1 on success +*/ +int StrLook(const std::string& Text,const boost::regex& Re) { boost::sregex_iterator m1(Text.begin(),Text.end(),Re); boost::sregex_iterator empty; @@ -91,37 +88,35 @@ StrLook(const std::string& Text,const boost::regex& Re) return 1; } -std::vector<std::string> -StrParts(std::string Sdx,const boost::regex& Re) - /** - Find the match, return the disected items. - Note it is complementary to support.h StrParts(Sdx) - @param Sdx :: Input string (note implicit copy since altered) - @param Re :: Regular expression for separator component - @return vector of string components - */ +/** + Find the match, return the disected items. + Note it is complementary to support.h StrParts(Sdx) + @param Sdx :: Input string (note implicit copy since altered) + @param Re :: Regular expression for separator component + @return vector of string components +*/ +std::vector<std::string> StrParts(std::string Sdx,const boost::regex& Re) { std::vector<std::string> Aout; boost::regex_split(std::back_inserter(Aout), Sdx, Re); // Destroys string in process return Aout; } +/** + Find the match, return the disected items: + Then remove the whole of the match + The regexpression must have one ( ) around the area to extract + @param Text :: string to split, is returned with the string after + the find (if successful). + @param Re :: regular expression to use. + @param Aout :: Value to extract + @param compNum :: Index of matches [0->N-1] (-1 :: whole match) + @retval 0 :: failed to match the string or there were no parts to match. + @retval 1 :: success + */ template<typename T> -int -StrFullCut(std::string& Text,const boost::regex& Re,T& Aout, +int StrFullCut(std::string& Text,const boost::regex& Re,T& Aout, const int compNum) - /** - Find the match, return the disected items: - Then remove the whole of the match - The regexpression must have one ( ) around the area to extract - @param Text :: string to split, is returned with the string after - the find (if successful). - @param Re :: regular expression to use. - @param Aout :: Value to extract - @param compNum :: Index of matches [0->N-1] (-1 :: whole match) - @retval 0 :: failed to match the string or there were no parts to match. - @retval 1 :: success - */ { boost::sregex_iterator m1(Text.begin(),Text.end(),Re); boost::sregex_iterator empty; @@ -130,8 +125,8 @@ StrFullCut(std::string& Text,const boost::regex& Re,T& Aout, if (compNum+1>=static_cast<int>(m1->size())) return 0; - // StrFunc::Convert to required output form - if (!StrFunc::convert((*m1)[compNum+1].str(),Aout)) + // Mantid::Kernel::Strings::Convert to required output form + if (!Mantid::Kernel::Strings::convert((*m1)[compNum+1].str(),Aout)) return 0; // Found object unsigned int zero = 0; // Needed for boost 1.40 (can't just put 0 in next line) @@ -139,20 +134,19 @@ StrFullCut(std::string& Text,const boost::regex& Re,T& Aout, return 1; } +/** + Find the match, return the disected items: + Then remove the whole of the match + The regexpression must have one ( ) around the area to extract + @param Text :: string to split, is returned with the string after + the find (if successful). + @param Re :: regular expression to use. + @param Aout :: Values to extract + @retval 0 :: failed to match the string or there were no parts to match. + @retval 1 :: success + */ template<typename T> -int -StrFullCut(std::string& Text,const boost::regex& Re,std::vector<T>& Aout) - /** - Find the match, return the disected items: - Then remove the whole of the match - The regexpression must have one ( ) around the area to extract - @param Text :: string to split, is returned with the string after - the find (if successful). - @param Re :: regular expression to use. - @param Aout :: Values to extract - @retval 0 :: failed to match the string or there were no parts to match. - @retval 1 :: success - */ +int StrFullCut(std::string& Text,const boost::regex& Re,std::vector<T>& Aout) { boost::sregex_iterator m1(Text.begin(),Text.end(),Re); boost::sregex_iterator empty; @@ -169,7 +163,7 @@ StrFullCut(std::string& Text,const boost::regex& Re,std::vector<T>& Aout) for(unsigned int index=1;index<m1->size();index++) { T tmp; - if (!StrFunc::convert((*m1)[index].str(),tmp)) + if (!Mantid::Kernel::Strings::convert((*m1)[index].str(),tmp)) return 0; Aout.push_back(tmp); } @@ -181,23 +175,22 @@ StrFullCut(std::string& Text,const boost::regex& Re,std::vector<T>& Aout) return 1; } +/** + Find the match, return the disected items: + Then remove the whole of the match + The regexpression must have one ( ) around the area to extract + This is specialised for string and thus does not need + a convert. + @param Text :: string to split, is returned with the string after + the find (if successful). + @param Re :: regular expression to use. + @param Aout :: Values to extract + @retval 0 :: failed to match the string or there were no parts to match. + @retval 1 :: success + */ template<> -int -StrFullCut(std::string& Text,const boost::regex& Re, +int StrFullCut(std::string& Text,const boost::regex& Re, std::vector<std::string>& Aout) - /** - Find the match, return the disected items: - Then remove the whole of the match - The regexpression must have one ( ) around the area to extract - This is specialised for string and thus does not need - a convert. - @param Text :: string to split, is returned with the string after - the find (if successful). - @param Re :: regular expression to use. - @param Aout :: Values to extract - @retval 0 :: failed to match the string or there were no parts to match. - @retval 1 :: success - */ { boost::sregex_iterator m1(Text.begin(),Text.end(),Re); boost::sregex_iterator empty; @@ -219,8 +212,6 @@ StrFullCut(std::string& Text,const boost::regex& Re, return 1; } -int -StrRemove(std::string& Sdx,std::string& Extract,const boost::regex& Re) /** Find the match, return the string - the bit @param Sdx :: string to split, is returned with the string after @@ -230,6 +221,7 @@ StrRemove(std::string& Sdx,std::string& Extract,const boost::regex& Re) @retval 0 :: failed to match the string or there were no parts to match. @retval 1 :: succes */ +int StrRemove(std::string& Sdx,std::string& Extract,const boost::regex& Re) { boost::sregex_token_iterator empty; @@ -247,21 +239,20 @@ StrRemove(std::string& Sdx,std::string& Extract,const boost::regex& Re) return 0; } +/** + Find the match, return the disected items + The rege xpression must have ( ) around the area to extract. + The function appends the results onto Aout. + @param text :: string to split, is returned with the string after + the find (if successful). + @param Re :: regular expression to use. + @param Aout :: vector to add components to. + @retval 0 :: failed to match the string or there were no parts to match. + @retval Number :: number of components added to Aout. + */ template<typename T> -int -StrFullSplit(const std::string& text, +int StrFullSplit(const std::string& text, const boost::regex& Re,std::vector<T>& Aout) - /** - Find the match, return the disected items - The rege xpression must have ( ) around the area to extract. - The function appends the results onto Aout. - @param text :: string to split, is returned with the string after - the find (if successful). - @param Re :: regular expression to use. - @param Aout :: vector to add components to. - @retval 0 :: failed to match the string or there were no parts to match. - @retval Number :: number of components added to Aout. - */ { boost::sregex_iterator m1(text.begin(),text.end(),Re); boost::sregex_iterator empty; @@ -269,28 +260,27 @@ StrFullSplit(const std::string& text, for(unsigned int index=1;index<m1->size();index++) { T tmp; - if (!StrFunc::convert((*m1)[index].str(),tmp)) + if (!Mantid::Kernel::Strings::convert((*m1)[index].str(),tmp)) return static_cast<int>(Aout.size()); Aout.push_back(tmp); } return static_cast<int>(Aout.size()); } +/** + Find the match, return the disected items + The regexpression must have ( ) around the area to extract. + The function appends the results onto Aout. + @param text :: string to split, is returned with the string after + the find (if successful). + @param Re :: regular expression to use. + @param Aout :: vector to add components to. + @retval 0 :: failed to match the string or there were no parts to match. + @retval Number :: number of components added to Aout. + */ template<typename T> -int -StrSingleSplit(const std::string& text, +int StrSingleSplit(const std::string& text, const boost::regex& Re,std::vector<T>& Aout) - /** - Find the match, return the disected items - The regexpression must have ( ) around the area to extract. - The function appends the results onto Aout. - @param text :: string to split, is returned with the string after - the find (if successful). - @param Re :: regular expression to use. - @param Aout :: vector to add components to. - @retval 0 :: failed to match the string or there were no parts to match. - @retval Number :: number of components added to Aout. - */ { boost::sregex_iterator m1(text.begin(),text.end(),Re); boost::sregex_iterator empty; @@ -298,7 +288,7 @@ StrSingleSplit(const std::string& text, for(unsigned int index=1;index<m1->size();index++) { T tmp; - if (!StrFunc::convert((*m1)[index].str(),tmp)) + if (!Mantid::Kernel::Strings::convert((*m1)[index].str(),tmp)) return static_cast<int>(Aout.size()); Aout.push_back(tmp); } @@ -306,22 +296,21 @@ StrSingleSplit(const std::string& text, return static_cast<int>(Aout.size()); } +/** + Find the match, return the disected items + The regexpression must have ( ) around the area to extract. + The function appends the results onto Aout. + - Specialised to avoid convert for std::string + @param text :: string to split, is returned with the string after + the find (if successful). + @param Re :: regular expression to use. + @param Aout :: vector to add components to. + @retval 0 :: failed to match the string or there were no parts to match. + @retval Number :: number of components added to Aout. + */ template<> -int -StrSingleSplit(const std::string& text, +int StrSingleSplit(const std::string& text, const boost::regex& Re,std::vector<std::string>& Aout) - /** - Find the match, return the disected items - The regexpression must have ( ) around the area to extract. - The function appends the results onto Aout. - - Specialised to avoid convert for std::string - @param text :: string to split, is returned with the string after - the find (if successful). - @param Re :: regular expression to use. - @param Aout :: vector to add components to. - @retval 0 :: failed to match the string or there were no parts to match. - @retval Number :: number of components added to Aout. - */ { boost::sregex_iterator m1(text.begin(),text.end(),Re); boost::sregex_iterator empty; @@ -334,15 +323,15 @@ StrSingleSplit(const std::string& text, return 0; } +/** + Finds the start of the tally + @param fh :: open file stream + @param Re :: regular expression to match + @param Out :: string to place match + @return count of line that matched (or zero on failure) +*/ DLLExport int findPattern(std::istream& fh,const boost::regex& Re,std::string& Out) - /** - Finds the start of the tally - @param fh :: open file stream - @param Re :: regular expression to match - @param Out :: string to place match - @return count of line that matched (or zero on failure) - */ { char ss[512]; // max of 512 boost::cmatch ans; @@ -360,16 +349,15 @@ findPattern(std::istream& fh,const boost::regex& Re,std::string& Out) return cnt; } +/** + Finds the start of the tally + @param fh :: open file stream + @param Re :: regular expression to match + @param Out :: component in ( ) expression must be first. + @return count of line that matched (or zero on failure) +*/ template<typename T> -int -findComp(std::istream& fh,const boost::regex& Re,T& Out) - /** - Finds the start of the tally - @param fh :: open file stream - @param Re :: regular expression to match - @param Out :: component in ( ) expression must be first. - @return count of line that matched (or zero on failure) - */ +int findComp(std::istream& fh,const boost::regex& Re,T& Out) { char ss[512]; // max of 512 boost::cmatch ans; @@ -384,22 +372,21 @@ findComp(std::istream& fh,const boost::regex& Re,T& Out) if (ans[0].matched) { std::string xout(ans[1].first,ans[1].second); - if (StrFunc::convert(xout,Out)) + if (Mantid::Kernel::Strings::convert(xout,Out)) return cnt; } return 0; } +/** + Finds the start of the tally + @param fh :: open file stream + @param Re :: regular expression to match + @param Out :: component in ( ) expression must be first. + @return count of line that matched (or zero on failure) +*/ template<> -DLLExport int -findComp(std::istream& fh,const boost::regex& Re,std::string& Out) - /** - Finds the start of the tally - @param fh :: open file stream - @param Re :: regular expression to match - @param Out :: component in ( ) expression must be first. - @return count of line that matched (or zero on failure) - */ +DLLExport int findComp(std::istream& fh,const boost::regex& Re,std::string& Out) { char ss[512]; // max of 512 boost::cmatch ans; @@ -419,6 +406,9 @@ findComp(std::istream& fh,const boost::regex& Re,std::string& Out) return 0; } + + + /// \cond TEMPLATE template DLLExport int StrFullCut(std::string&,const boost::regex&, @@ -426,29 +416,31 @@ template DLLExport int StrFullCut(std::string&,const boost::regex&, template DLLExport int StrFullCut(std::string&,const boost::regex&,int&,const int); template DLLExport int StrFullCut(std::string&,const boost::regex&,double&,const int); - -// -------------------------------------------------------- template DLLExport int StrFullSplit(const std::string&,const boost::regex&, std::vector<int>&); template DLLExport int StrFullSplit(const std::string&,const boost::regex&, std::vector<double>&); template DLLExport int StrFullSplit(const std::string&,const boost::regex&, std::vector<std::string>&); -// -------------------------------------------------------- + template DLLExport int StrSingleSplit(const std::string&,const boost::regex&, std::vector<int>&); template DLLExport int StrSingleSplit(const std::string&,const boost::regex&, std::vector<double>&); -// -------------------------------------------------------- + template DLLExport int StrComp(const char*,const boost::regex&,double&,const int); template DLLExport int StrComp(const char*,const boost::regex&,int&,const int); template DLLExport int StrComp(const std::string&,const boost::regex&,double&,const int); template DLLExport int StrComp(const std::string&,const boost::regex&,int&,const int); -// ------------------------------------------------------------------ + template DLLExport int findComp(std::istream&,const boost::regex&,int&); /// \endcond TEMPLATE -} // NAMESPACE StrFunc -} // NAMESPACE MAntid + +} //NAMESPACE Strings + +} //NAMESPACE Kernel + +} //NAMESPACE Mantid diff --git a/Code/Mantid/Framework/Kernel/src/Strings.cpp b/Code/Mantid/Framework/Kernel/src/Strings.cpp new file mode 100644 index 0000000000000000000000000000000000000000..544d4832f2e061750457d0102ccab4107bf5bce8 --- /dev/null +++ b/Code/Mantid/Framework/Kernel/src/Strings.cpp @@ -0,0 +1,724 @@ +#include <iostream> +#include <iomanip> +#include <fstream> +#include <sstream> +#include <cmath> +#include <vector> +#include <string.h> + +#include "MantidKernel/Strings.h" + +using std::size_t; + +namespace Mantid +{ + +namespace Geometry +{ + class V3D; //Forward declaration +} + + +namespace Kernel +{ +namespace Strings +{ + +/** + Function to convert a number into hex + output (and leave the stream un-changed) + @param OFS :: Output stream + @param n :: Integer to convert + \todo Change this to a stream operator +*/ +void printHex(std::ostream& OFS,const int n) +{ + std::ios_base::fmtflags PrevFlags=OFS.flags(); + OFS<<"Ox"; + OFS.width(8); + OFS.fill('0'); + hex(OFS); + OFS << n; + OFS.flags(PrevFlags); + return; +} + +/** + Removes the multiple spaces in the line + @param Line :: Line to process + @return String with single space components +*/ +std::string stripMultSpc(const std::string& Line) +{ + std::string Out; + int spc(1); + int lastReal(-1); + for(unsigned int i=0;i<Line.length();i++) + { + if (Line[i]!=' ' && Line[i]!='\t' && + Line[i]!='\r' && Line[i]!='\n') + { + lastReal=i; + spc=0; + Out+=Line[i]; + } + else if (!spc) + { + spc=1; + Out+=' '; + } + } + lastReal++; + if (lastReal<static_cast<int>(Out.length())) + Out.erase(lastReal); + return Out; +} + +/** + Checks that as least cnt letters of + works is part of the string. It is currently + case sensative. It removes the Word if found + @param Line :: Line to process + @param Word :: Word to use + @param cnt :: Length of Word for significants [default =4] + @retval 1 on success (and changed Line) + @retval 0 on failure +*/ +int extractWord(std::string& Line,const std::string& Word,const int cnt) +{ + if (Word.empty()) + return 0; + + unsigned int minSize(cnt>static_cast<int>(Word.size()) ? Word.size() : cnt); + std::string::size_type pos=Line.find(Word.substr(0,minSize)); + if (pos==std::string::npos) + return 0; + // Pos == Start of find + unsigned int LinePt=minSize+pos; + for(;minSize<Word.size() && LinePt<Line.size() + && Word[minSize]==Line[LinePt];LinePt++,minSize++) + { + } + + Line.erase(pos,LinePt-(pos-1)); + return 1; +} + +/** + Check to see if S is the same as the + first part of a phrase. (case insensitive) + @param S :: string to check + @param fullPhrase :: complete phrase + @return 1 on success +*/ +int confirmStr(const std::string& S,const std::string& fullPhrase) +{ + const size_t nS(S.length()); + const size_t nC(fullPhrase.length()); + if (nS>nC || nS<=0) + return 0; + for(size_t i=0;i<nS;i++) + if (S[i]!=fullPhrase[i]) + return 0; + return 1; +} + +/** + Gets a line and determine if there is addition component to add + in the case of a very long line. + @param fh :: input stream to get line + @param Out :: string up to last 'tab' or ' ' + @param Excess :: string after 'tab or ' ' + @param spc :: number of char to try to read + @retval 1 :: more line to be found + @retval -1 :: Error with file + @retval 0 :: line finished. +*/ +int getPartLine(std::istream& fh,std::string& Out,std::string& Excess,const int spc) +{ + std::string Line; + if (fh.good()) + { + char* ss=new char[spc+1]; + const int clen=spc-Out.length(); + fh.getline(ss,clen,'\n'); + ss[clen+1]=0; // incase line failed to read completely + Out+=static_cast<std::string>(ss); + delete [] ss; + // remove trailing comments + std::string::size_type pos = Out.find_first_of("#!"); + if (pos!=std::string::npos) + { + Out.erase(pos); + return 0; + } + if (fh.gcount()==clen-1) // cont line + { + pos=Out.find_last_of("\t "); + if (pos!=std::string::npos) + { + Excess=Out.substr(pos,std::string::npos); + Out.erase(pos); + } + else + Excess.erase(0,std::string::npos); + fh.clear(); + return 1; + } + return 0; + } + return -1; +} + +/** + Removes all spaces from a string + except those with in the form '\ ' + @param CLine :: Line to strip + @return String without space +*/ +std::string removeSpace(const std::string& CLine) +{ + std::string Out; + char prev='x'; + for(unsigned int i=0;i<CLine.length();i++) + { + if (!isspace(CLine[i]) || prev=='\\') + { + Out+=CLine[i]; + prev=CLine[i]; + } + } + return Out; +} + +/** + Reads a line from the stream of max length spc. + Trailing comments are removed. (with # or ! character) + @param fh :: already open file handle + @param spc :: max number of characters to read + @return String read. +*/ +std::string getLine(std::istream& fh,const int spc) +{ + char* ss=new char[spc+1]; + std::string Line; + if (fh.good()) + { + fh.getline(ss,spc,'\n'); + ss[spc]=0; // incase line failed to read completely + Line=ss; + // remove trailing comments + std::string::size_type pos = Line.find_first_of("#!"); + if (pos!=std::string::npos) + Line.erase(pos); + } + delete [] ss; + return Line; +} + +/** + Determines if a string is only spaces + @param A :: string to check + @return 1 on an empty string , 0 on failure +*/ +int isEmpty(const std::string& A) +{ + std::string::size_type pos= + A.find_first_not_of(" \t"); + return (pos!=std::string::npos) ? 0 : 1; +} + +/** + removes the string after the comment type of + '$ ' or '!' or '# ' + @param A :: String to process +*/ +void stripComment(std::string& A) +{ + std::string::size_type posA=A.find("$ "); + std::string::size_type posB=A.find("# "); + std::string::size_type posC=A.find("!"); + if (posA>posB) + posA=posB; + if (posA>posC) + posA=posC; + if (posA!=std::string::npos) + A.erase(posA,std::string::npos); + return; +} + +/** + Returns the string from the first non-space to the + last non-space + @param A :: string to process + @return shortened string +*/ +std::string fullBlock(const std::string& A) +{ + std::string::size_type posA=A.find_first_not_of(" "); + std::string::size_type posB=A.find_last_not_of(" "); + if (posA==std::string::npos) + return ""; + return A.substr(posA,1+posB-posA); +} + + +/** + Write out the line in the limited form for MCNPX + ie initial line from 0->72 after that 8 to 72 + (split on a space or comma) + @param Line :: full MCNPX line + @param OX :: ostream to write to +*/ +void writeMCNPX(const std::string& Line,std::ostream& OX) +{ + const int MaxLine(72); + std::string::size_type pos(0); + std::string X=Line.substr(0,MaxLine); + std::string::size_type posB=X.find_last_of(" ,"); + int spc(0); + while (posB!=std::string::npos && + static_cast<int>(X.length())>=MaxLine-spc) + { + pos+=posB+1; + if (!isspace(X[posB])) + posB++; + const std::string Out=X.substr(0,posB); + if (!isEmpty(Out)) + { + if (spc) + OX<<std::string(spc,' '); + OX<<X.substr(0,posB)<<std::endl; + } + spc=8; + X=Line.substr(pos,MaxLine-spc); + posB=X.find_last_of(" ,"); + } + if (!isEmpty(X)) + { + if (spc) + OX<<std::string(spc,' '); + OX<<X<<std::endl; + } + return; +} + +/** + Splits the sting into parts that are space delminated. + @param Ln :: line component to strip + @return vector of components +*/ +std::vector<std::string> StrParts(std::string Ln) +{ + std::vector<std::string> Out; + std::string Part; + while(section(Ln,Part)) + Out.push_back(Part); + return Out; +} + +/** + Converts a vax number into a standard unix number + @param A :: float number as read from a VAX file + @return float A in IEEE little eindian format +*/ +float getVAXnum(const float A) +{ + union + { + char a[4]; + float f; + int ival; + } Bd; + + int sign,expt,fmask; + float frac; + double onum; + + Bd.f=A; + sign = (Bd.ival & 0x8000) ? -1 : 1; + expt = ((Bd.ival & 0x7f80) >> 7); //reveresed ? + if (!expt) + return 0.0; + + fmask = ((Bd.ival & 0x7f) << 16) | ((Bd.ival & 0xffff0000) >> 16); + expt-=128; + fmask |= 0x800000; + frac = (float) fmask / 0x1000000; + onum= frac * sign * + pow(2.0,expt); + return (float) onum; +} + + +/** + Takes a character string and evaluates + the first [typename T] object. The string is then + erase upt to the end of number. + The diffierence between this and section is that + it allows trailing characters after the number. + @param out :: place for output + @param A :: string to process + @return 1 on success 0 on failure + */ +template<typename T> +int sectPartNum(std::string& A,T& out) +{ + if (A.empty()) + return 0; + + std::istringstream cx; + T retval; + cx.str(A); + cx.clear(); + cx>>retval; + const std::streamoff xpt = cx.tellg(); + if (xpt < 0) + return 0; + A.erase(0,static_cast<unsigned int>(xpt)); + out=retval; + return 1; +} + +/** + Takes a character string and evaluates + the first [typename T] object. The string is then filled with + spaces upto the end of the [typename T] object + @param out :: place for output + @param cA :: char array for input and output. + @return 1 on success 0 on failure + */ +template<typename T> +int section(char* cA,T& out) +{ + if (!cA) return 0; + std::string sA(cA); + const int item(section(sA,out)); + if (item) + { + strcpy(cA,sA.c_str()); + return 1; + } + return 0; +} + +/* + takes a character string and evaluates + the first <T> object. The string is then filled with + spaces upto the end of the <T> object + @param out :: place for output + @param A :: string for input and output. + @return 1 on success 0 on failure +*/ +template<typename T> +int section(std::string& A,T& out) +{ + if (A.empty()) return 0; + std::istringstream cx; + T retval; + cx.str(A); + cx.clear(); + cx>>retval; + if (cx.fail()) + return 0; + const std::streamoff xpt = cx.tellg(); + const char xc=cx.get(); + if (!cx.fail() && !isspace(xc)) + return 0; + A.erase(0, static_cast<unsigned int>(xpt)); + out=retval; + return 1; +} + +/* + Takes a character string and evaluates + the first [T] object. The string is then filled with + spaces upto the end of the [T] object. + This version deals with MCNPX numbers. Those + are numbers that are crushed together like + - 5.4938e+04-3.32923e-6 + @param out :: place for output + @param A :: string for input and output. + @return 1 on success 0 on failure +*/ +template<typename T> +int sectionMCNPX(std::string& A,T& out) +{ + if (A.empty()) return 0; + std::istringstream cx; + T retval; + cx.str(A); + cx.clear(); + cx>>retval; + if (!cx.fail()) + { + const std::streamoff xpt = cx.tellg(); + if( xpt < 0 ) + { + return 0; + } + const char xc=cx.get(); + if (!cx.fail() && !isspace(xc) && (xc!='-' || xpt<5)) + { + return 0; + } + A.erase(0, static_cast<unsigned int>(xpt)); + out=retval; + return 1; + } + return 0; +} + +/** + Takes a character string and evaluates + the first [typename T] object. The string is then + erase upto the end of number. + The diffierence between this and convert is that + it allows trailing characters after the number. + @param out :: place for output + @param A :: string to process + @retval number of char read on success + @retval 0 on failure + */ +template<typename T> +int convPartNum(const std::string& A,T& out) +{ + if (A.empty()) return 0; + std::istringstream cx; + T retval; + cx.str(A); + cx.clear(); + cx>>retval; + const std::streamoff xpt = cx.tellg(); + if (xpt<0) + return 0; + out=retval; + return static_cast<int>(xpt); +} + +/** + Convert a string into a value + @param A :: string to pass + @param out :: value if found + @return 0 on failure 1 on success +*/ +template<typename T> +int convert(const std::string& A,T& out) +{ + if (A.empty()) return 0; + std::istringstream cx; + T retval; + cx.str(A); + cx.clear(); + cx>>retval; + if (cx.fail()) + return 0; + const char clast=cx.get(); + if (!cx.fail() && !isspace(clast)) + return 0; + out=retval; + return 1; +} + +/** + Convert a string into a value + @param A :: string to pass + @param out :: value if found + @return 0 on failure 1 on success +*/ +template<typename T> +int convert(const char* A,T& out) +{ + // No string, no conversion + if (!A) return 0; + std::string Cx=A; + return convert(Cx,out); +} + +/** + Write out the three vectors into a file of type dc 9 + @param step :: parameter to control x-step (starts from zero) + @param Y :: Y column + @param Fname :: Name of the file + @return 0 on success and -ve on failure +*/ +template<template<typename T,typename A> class V,typename T,typename A> +int writeFile(const std::string& Fname,const T step, const V<T,A>& Y) +{ + V<T,A> Ex; // Empty vector + V<T,A> X; // Empty vector + for(unsigned int i=0;i<Y.size();i++) + X.push_back(i*step); + + return writeFile(Fname,X,Y,Ex); +} + +/** + Write out the three vectors into a file of type dc 9 + @param X :: X column + @param Y :: Y column + @param Fname :: Name of the file + @return 0 on success and -ve on failure +*/ +template<template<typename T,typename A> class V,typename T,typename A> +int writeFile(const std::string& Fname,const V<T,A>& X,const V<T,A>& Y) +{ + V<T,A> Ex; // Empty vector/list + return writeFile(Fname,X,Y,Ex); // don't need to specific ?? +} + +/** + Write out the three container into a file with + column free-formated data in the form : + - X Y Err + If Err does not exist (or is short) 0.0 is substituted. + @param X :: X column + @param Y :: Y column + @param Err :: Err column + @param Fname :: Name of the file + @return 0 on success and -ve on failure +*/ +template<template<typename T,typename A> class V,typename T,typename A> +int writeFile(const std::string& Fname,const V<T,A>& X,const V<T,A>& Y,const V<T,A>& Err) +{ + const int Npts(X.size()>Y.size() ? Y.size() : X.size()); + const int Epts(Npts>static_cast<int>(Err.size()) ? Err.size() : Npts); + + std::ofstream FX; + + FX.open(Fname.c_str()); + if (!FX.good()) + return -1; + + FX<<"# "<<Npts<<" "<<Epts<<std::endl; + FX.precision(10); + FX.setf(std::ios::scientific,std::ios::floatfield); + typename V<T,A>::const_iterator xPt=X.begin(); + typename V<T,A>::const_iterator yPt=Y.begin(); + typename V<T,A>::const_iterator ePt=(Epts ? Err.begin() : Y.begin()); + + // Double loop to include/exclude a short error stack + int eCount=0; + for(;eCount<Epts;eCount++) + { + FX<<(*xPt)<<" "<<(*yPt)<<" "<<(*ePt)<<std::endl; + xPt++; + yPt++; + ePt++; + } + for(;eCount<Npts;eCount++) + { + FX<<(*xPt)<<" "<<(*yPt)<<" 0.0"<<std::endl; + xPt++; + yPt++; + } + FX.close(); + return 0; +} + +/** + Call to read in various values in position x1,x2,x3 from the + line. Note to avoid the dependency on crossSort this needs + to be call IN ORDER + @param Line :: string to read + @param Index :: Indexes to read + @param Out :: OutValues [unchanged if not read] + @retval 0 :: success + @retval -ve on failure. +*/ +template<typename T> +int setValues(const std::string& Line,const std::vector<int>& Index,std::vector<T>& Out) +{ + if (Index.empty()) + return 0; + + if(Out.size()!=Index.size()) + return -1; +// throw ColErr::MisMatch<int>(Index.size(),Out.size(), +// "Mantid::Kernel::Strings::setValues"); + + std::string modLine=Line; + std::vector<int> sIndex(Index); // Copy for sorting + std::vector<int> OPt(Index.size()); + for(unsigned int i=0;i<Index.size();i++) + OPt[i]=i; + + + // mathFunc::crossSort(sIndex,OPt); + + typedef std::vector<int>::const_iterator iVecIter; + std::vector<int>::const_iterator sc=sIndex.begin(); + std::vector<int>::const_iterator oc=OPt.begin(); + int cnt(0); + T value; + std::string dump; + while(sc!=sIndex.end() && *sc<0) + { + sc++; + oc++; + } + + while(sc!=sIndex.end()) + { + if (*sc==cnt) + { + if (!section(modLine,value)) + return -1-distance(static_cast<iVecIter>(sIndex.begin()),sc); + // this loop handles repeat units + do + { + Out[*oc]=value; + sc++; + oc++; + } while (sc!=sIndex.end() && *sc==cnt); + } + else + { + if (!section(modLine,dump)) + return -1-distance(static_cast<iVecIter>(sIndex.begin()),sc); + } + cnt++; // Add only to cnt [sc/oc in while loop] + } + // Success since loop only gets here if sc is exhaused. + return 0; +} + + + +/// \cond TEMPLATE + +template DLLExport int section(std::string&,double&); +template DLLExport int section(std::string&,float&); +template DLLExport int section(std::string&,int&); +template DLLExport int section(std::string&,std::string&); +//template DLLExport int section(std::string&, Mantid::Geometry::V3D&); + +template DLLExport int sectPartNum(std::string&,double&); +template DLLExport int sectPartNum(std::string&,int&); +template DLLExport int sectionMCNPX(std::string&,double&); + +template DLLExport int convert(const std::string&,double&); +template DLLExport int convert(const std::string&,std::string&); +template DLLExport int convert(const std::string&,int&); +template DLLExport int convert(const char*,std::string&); +template DLLExport int convert(const char*,double&); +template DLLExport int convert(const char*,int&); + +template DLLExport int convPartNum(const std::string&,double&); +template DLLExport int convPartNum(const std::string&,int&); + +template DLLExport int setValues(const std::string&,const std::vector<int>&,std::vector<double>&); + +template DLLExport int writeFile(const std::string&,const double,const std::vector<double>&); +template DLLExport int writeFile(const std::string&,const std::vector<double>&,const std::vector<double>&,const std::vector<double>&); +template DLLExport int writeFile(const std::string&,const std::vector<double>&,const std::vector<double>&); +template DLLExport int writeFile(const std::string&,const std::vector<float>&,const std::vector<float>&); +template DLLExport int writeFile(const std::string&,const std::vector<float>&,const std::vector<float>&,const std::vector<float>&); + +/// \endcond TEMPLATE + +} // NAMESPACE Strings + +} // Namespace Kernel + +} // NAMESPACE Mantid diff --git a/Code/Mantid/Framework/Kernel/src/SupportBasic.cpp b/Code/Mantid/Framework/Kernel/src/SupportBasic.cpp deleted file mode 100644 index 93c91d920464f8ab24eba71addcd7211bfc11bba..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/Kernel/src/SupportBasic.cpp +++ /dev/null @@ -1,346 +0,0 @@ -#include <iostream> -#include <iomanip> -#include <fstream> -#include <sstream> -#include <cmath> -#include <vector> - -#include "MantidKernel/Support.h" - -using std::size_t; - -namespace Mantid -{ - -namespace StrFunc -{ - -/** - Function to convert a number into hex - output (and leave the stream un-changed) - @param OFS :: Output stream - @param n :: Integer to convert - \todo Change this to a stream operator -*/ -void printHex(std::ostream& OFS,const int n) -{ - std::ios_base::fmtflags PrevFlags=OFS.flags(); - OFS<<"Ox"; - OFS.width(8); - OFS.fill('0'); - hex(OFS); - OFS << n; - OFS.flags(PrevFlags); - return; -} - -/** - Removes the multiple spaces in the line - @param Line :: Line to process - @return String with single space components -*/ -std::string stripMultSpc(const std::string& Line) -{ - std::string Out; - int spc(1); - int lastReal(-1); - for(unsigned int i=0;i<Line.length();i++) - { - if (Line[i]!=' ' && Line[i]!='\t' && - Line[i]!='\r' && Line[i]!='\n') - { - lastReal=i; - spc=0; - Out+=Line[i]; - } - else if (!spc) - { - spc=1; - Out+=' '; - } - } - lastReal++; - if (lastReal<static_cast<int>(Out.length())) - Out.erase(lastReal); - return Out; -} - -/** - Checks that as least cnt letters of - works is part of the string. It is currently - case sensative. It removes the Word if found - @param Line :: Line to process - @param Word :: Word to use - @param cnt :: Length of Word for significants [default =4] - @retval 1 on success (and changed Line) - @retval 0 on failure -*/ -int extractWord(std::string& Line,const std::string& Word,const int cnt) -{ - if (Word.empty()) - return 0; - - unsigned int minSize(cnt>static_cast<int>(Word.size()) ? Word.size() : cnt); - std::string::size_type pos=Line.find(Word.substr(0,minSize)); - if (pos==std::string::npos) - return 0; - // Pos == Start of find - unsigned int LinePt=minSize+pos; - for(;minSize<Word.size() && LinePt<Line.size() - && Word[minSize]==Line[LinePt];LinePt++,minSize++) - { - } - - Line.erase(pos,LinePt-(pos-1)); - return 1; -} - -/** - Check to see if S is the same as the - first part of a phrase. (case insensitive) - @param S :: string to check - @param fullPhrase :: complete phrase - @return 1 on success -*/ -int confirmStr(const std::string& S,const std::string& fullPhrase) -{ - const size_t nS(S.length()); - const size_t nC(fullPhrase.length()); - if (nS>nC || nS<=0) - return 0; - for(size_t i=0;i<nS;i++) - if (S[i]!=fullPhrase[i]) - return 0; - return 1; -} - -/** - Gets a line and determine if there is addition component to add - in the case of a very long line. - @param fh :: input stream to get line - @param Out :: string up to last 'tab' or ' ' - @param Excess :: string after 'tab or ' ' - @param spc :: number of char to try to read - @retval 1 :: more line to be found - @retval -1 :: Error with file - @retval 0 :: line finished. -*/ -int getPartLine(std::istream& fh,std::string& Out,std::string& Excess,const int spc) -{ - std::string Line; - if (fh.good()) - { - char* ss=new char[spc+1]; - const int clen=spc-Out.length(); - fh.getline(ss,clen,'\n'); - ss[clen+1]=0; // incase line failed to read completely - Out+=static_cast<std::string>(ss); - delete [] ss; - // remove trailing comments - std::string::size_type pos = Out.find_first_of("#!"); - if (pos!=std::string::npos) - { - Out.erase(pos); - return 0; - } - if (fh.gcount()==clen-1) // cont line - { - pos=Out.find_last_of("\t "); - if (pos!=std::string::npos) - { - Excess=Out.substr(pos,std::string::npos); - Out.erase(pos); - } - else - Excess.erase(0,std::string::npos); - fh.clear(); - return 1; - } - return 0; - } - return -1; -} - -/** - Removes all spaces from a string - except those with in the form '\ ' - @param CLine :: Line to strip - @return String without space -*/ -std::string removeSpace(const std::string& CLine) -{ - std::string Out; - char prev='x'; - for(unsigned int i=0;i<CLine.length();i++) - { - if (!isspace(CLine[i]) || prev=='\\') - { - Out+=CLine[i]; - prev=CLine[i]; - } - } - return Out; -} - -/** - Reads a line from the stream of max length spc. - Trailing comments are removed. (with # or ! character) - @param fh :: already open file handle - @param spc :: max number of characters to read - @return String read. -*/ -std::string getLine(std::istream& fh,const int spc) -{ - char* ss=new char[spc+1]; - std::string Line; - if (fh.good()) - { - fh.getline(ss,spc,'\n'); - ss[spc]=0; // incase line failed to read completely - Line=ss; - // remove trailing comments - std::string::size_type pos = Line.find_first_of("#!"); - if (pos!=std::string::npos) - Line.erase(pos); - } - delete [] ss; - return Line; -} - -/** - Determines if a string is only spaces - @param A :: string to check - @return 1 on an empty string , 0 on failure -*/ -int isEmpty(const std::string& A) -{ - std::string::size_type pos= - A.find_first_not_of(" \t"); - return (pos!=std::string::npos) ? 0 : 1; -} - -/** - removes the string after the comment type of - '$ ' or '!' or '# ' - @param A :: String to process -*/ -void stripComment(std::string& A) -{ - std::string::size_type posA=A.find("$ "); - std::string::size_type posB=A.find("# "); - std::string::size_type posC=A.find("!"); - if (posA>posB) - posA=posB; - if (posA>posC) - posA=posC; - if (posA!=std::string::npos) - A.erase(posA,std::string::npos); - return; -} - -/** - Returns the string from the first non-space to the - last non-space - @param A :: string to process - @return shortened string -*/ -std::string fullBlock(const std::string& A) -{ - std::string::size_type posA=A.find_first_not_of(" "); - std::string::size_type posB=A.find_last_not_of(" "); - if (posA==std::string::npos) - return ""; - return A.substr(posA,1+posB-posA); -} - - -/** - Write out the line in the limited form for MCNPX - ie initial line from 0->72 after that 8 to 72 - (split on a space or comma) - @param Line :: full MCNPX line - @param OX :: ostream to write to -*/ -void writeMCNPX(const std::string& Line,std::ostream& OX) -{ - const int MaxLine(72); - std::string::size_type pos(0); - std::string X=Line.substr(0,MaxLine); - std::string::size_type posB=X.find_last_of(" ,"); - int spc(0); - while (posB!=std::string::npos && - static_cast<int>(X.length())>=MaxLine-spc) - { - pos+=posB+1; - if (!isspace(X[posB])) - posB++; - const std::string Out=X.substr(0,posB); - if (!isEmpty(Out)) - { - if (spc) - OX<<std::string(spc,' '); - OX<<X.substr(0,posB)<<std::endl; - } - spc=8; - X=Line.substr(pos,MaxLine-spc); - posB=X.find_last_of(" ,"); - } - if (!isEmpty(X)) - { - if (spc) - OX<<std::string(spc,' '); - OX<<X<<std::endl; - } - return; -} - -/** - Splits the sting into parts that are space delminated. - @param Ln :: line component to strip - @return vector of components -*/ -std::vector<std::string> StrParts(std::string Ln) -{ - std::vector<std::string> Out; - std::string Part; - while(section(Ln,Part)) - Out.push_back(Part); - return Out; -} - -/** - Converts a vax number into a standard unix number - @param A :: float number as read from a VAX file - @return float A in IEEE little eindian format -*/ -float getVAXnum(const float A) -{ - union - { - char a[4]; - float f; - int ival; - } Bd; - - int sign,expt,fmask; - float frac; - double onum; - - Bd.f=A; - sign = (Bd.ival & 0x8000) ? -1 : 1; - expt = ((Bd.ival & 0x7f80) >> 7); //reveresed ? - if (!expt) - return 0.0; - - fmask = ((Bd.ival & 0x7f) << 16) | ((Bd.ival & 0xffff0000) >> 16); - expt-=128; - fmask |= 0x800000; - frac = (float) fmask / 0x1000000; - onum= frac * sign * - pow(2.0,expt); - return (float) onum; -} - -} // NAMESPACE StrFunc - -} // NAMESPACE Mantid diff --git a/Code/Mantid/Framework/Kernel/src/SupportKernel.cpp b/Code/Mantid/Framework/Kernel/src/SupportKernel.cpp deleted file mode 100644 index 54d50b0b291eb5ae5cc534f7654fb6a2a2d4f538..0000000000000000000000000000000000000000 --- a/Code/Mantid/Framework/Kernel/src/SupportKernel.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include <iostream> -#include <iomanip> -#include <fstream> -#include <sstream> -#include <cmath> -#include <vector> - -#include "MantidKernel/Support.h" -#include "MantidKernel/SupportTempCode.h" - -namespace Mantid -{ -namespace StrFunc -{ - -/// \cond TEMPLATE - -template DLLExport int section(std::string&,double&); -template DLLExport int section(std::string&,float&); -template DLLExport int section(std::string&,int&); -template DLLExport int section(std::string&,std::string&); - -template DLLExport int sectPartNum(std::string&,double&); -template DLLExport int sectPartNum(std::string&,int&); -template DLLExport int sectionMCNPX(std::string&,double&); - -template DLLExport int convert(const std::string&,double&); -template DLLExport int convert(const std::string&,std::string&); -template DLLExport int convert(const std::string&,int&); -template DLLExport int convert(const char*,std::string&); -template DLLExport int convert(const char*,double&); -template DLLExport int convert(const char*,int&); - -template DLLExport int convPartNum(const std::string&,double&); -template DLLExport int convPartNum(const std::string&,int&); - -template DLLExport int setValues(const std::string&,const std::vector<int>&,std::vector<double>&); - -template DLLExport int writeFile(const std::string&,const double,const std::vector<double>&); -template DLLExport int writeFile(const std::string&,const std::vector<double>&,const std::vector<double>&,const std::vector<double>&); -template DLLExport int writeFile(const std::string&,const std::vector<double>&,const std::vector<double>&); -template DLLExport int writeFile(const std::string&,const std::vector<float>&,const std::vector<float>&); -template DLLExport int writeFile(const std::string&,const std::vector<float>&,const std::vector<float>&,const std::vector<float>&); - -/// \endcond TEMPLATE - -} // NAMESPACE StrFunc - -} // NAMESPACE Mantid diff --git a/Code/Mantid/Framework/Geometry/test/RegexSupportTest.h b/Code/Mantid/Framework/Kernel/test/RegexStringsTest.h similarity index 96% rename from Code/Mantid/Framework/Geometry/test/RegexSupportTest.h rename to Code/Mantid/Framework/Kernel/test/RegexStringsTest.h index 987f13c47100da5eaa7ef43fb73eddb861a3db9e..05106e0ea56a110aa4b31c06d51c892240fd256e 100644 --- a/Code/Mantid/Framework/Geometry/test/RegexSupportTest.h +++ b/Code/Mantid/Framework/Kernel/test/RegexStringsTest.h @@ -10,21 +10,20 @@ #include "MantidKernel/Logger.h" #include "MantidKernel/System.h" -#include "MantidGeometry/V3D.h" #include <boost/regex.hpp> -#include "MantidGeometry/Math/RegexSupport.h" +#include "MantidKernel/RegexStrings.h" using namespace Mantid; -using namespace StrFunc; +using namespace Mantid::Kernel::Strings; -class RegexSupportTest: public CxxTest::TestSuite +class RegexStringsTest: public CxxTest::TestSuite { private: std::stringstream testStream; public: - RegexSupportTest() + RegexStringsTest() { testStream << "2007-11-16T13:25:48 END\n" << "2007-11-16T13:29:36 CHANGE RUNTABLE\n" diff --git a/Code/Mantid/Framework/Kernel/test/SupportTest.h b/Code/Mantid/Framework/Kernel/test/StringsTest.h similarity index 88% rename from Code/Mantid/Framework/Kernel/test/SupportTest.h rename to Code/Mantid/Framework/Kernel/test/StringsTest.h index c765d2a1318f35a0547b140715268c4143849ba7..92adb5ea5cfbe47eee66a26a38130dca86206d18 100644 --- a/Code/Mantid/Framework/Kernel/test/SupportTest.h +++ b/Code/Mantid/Framework/Kernel/test/StringsTest.h @@ -1,25 +1,23 @@ - #ifndef MANTID_SUPPORTTEST_H_ #define MANTID_SUPPORTTEST_H_ #include <cxxtest/TestSuite.h> -#include "MantidKernel/Support.h" +#include "MantidKernel/Strings.h" #include <string> -using namespace Mantid::StrFunc; +using namespace Mantid::Kernel::Strings; /** - \class testSupport - \brief test of Support components - \version 1.0 + \class StringsTest + \brief test of Strings components \date September 2005 \author S.Ansell - Checks the basic string operations in - support.cxx + Checks the basic string operations in Strings */ -class SupportTest : public CxxTest::TestSuite + +class StringsTest : public CxxTest::TestSuite { public: diff --git a/Code/Mantid/Framework/TestHelpers/CMakeLists.txt b/Code/Mantid/Framework/TestHelpers/CMakeLists.txt index 540c654dbf1e35c49ed70608a3f4c8fb62349c60..397c4ffe0b995d2a3323fe7ab6274ca71c38fbf7 100644 --- a/Code/Mantid/Framework/TestHelpers/CMakeLists.txt +++ b/Code/Mantid/Framework/TestHelpers/CMakeLists.txt @@ -33,4 +33,4 @@ set ( TMP_MANTIDLIBS ) #add_executable(WikiMaker EXCLUDE_FROM_ALL ${CMAKE_CURRENT_SOURCE_DIR}/src/WikiMaker.cpp ) add_executable(WikiMaker ${CMAKE_CURRENT_SOURCE_DIR}/src/WikiMaker.cpp ) -target_link_libraries ( WikiMaker ${MANTIDLIBS} Algorithms DataHandling DataObjects ) +target_link_libraries ( WikiMaker ${MANTIDLIBS} Algorithms DataHandling DataObjects Geometry ) diff --git a/Code/Mantid/MantidPlot/CMakeLists.txt b/Code/Mantid/MantidPlot/CMakeLists.txt index a8b0ebbd33afd1cba9e9d36f7f565cc8c1aeda6e..0b98378340a3914893edf6c07bf668dd9cd35bc7 100644 --- a/Code/Mantid/MantidPlot/CMakeLists.txt +++ b/Code/Mantid/MantidPlot/CMakeLists.txt @@ -697,7 +697,7 @@ target_link_libraries ( MantidPlot ${QWT_LIBRARIES} ${QWTPLOT3D_LIBRARIES} ${QSCINTILLA_LIBRARIES} ${PYTHON_LIBRARIES} - ${ZLIB_LIBRARIES} + ${ZLIB_LIBRARIES} ) ###########################################################################