eabffunc.C

Go to the documentation of this file.
00001 //
00002 // The extended adaptive biasing force method has been contributed to NAMD by the following authors:
00003 //
00004 //    Haohao Fu and Christophe Chipot
00005 //    Laboratoire International Associ\'e
00006 //    Centre National de la Recherche Scientifique et University of Illinois at Urbana--Champaign
00007 //    Unit\'e Mixte de Recherche No. 7565, Universit\'e de Lorraine
00008 //    B.P. 70239, 54506 Vand\oe uvre-lès-Nancy cedex, France
00009 //
00010 // Copyright 2016, Centre National de la Recherche Scientifique
00011 //
00012 
00013 #ifndef FUNC_CPP
00014 #define FUNC_CPP
00015 
00016 #include "eabffunc.h"
00017 
00018 
00019 // the trim method of string
00020 // accept a string, remove the space in the left and right of the string
00021 // return the reference of the same string
00022 std::string& eabffunc::trim(std::string &s)
00023 {
00024         if (s.empty())
00025         {
00026                 return s;
00027         }
00028 
00029         s.erase(0, s.find_first_not_of(" "));
00030         s.erase(s.find_last_not_of(" ") + 1);
00031         return s;
00032 }
00033 
00034 
00035 // the split of string
00036 // accept a string, return a vector<string>
00037 void eabffunc::split(const std::string &s, std::vector<std::string>& ret)
00038 {
00039         std::stringstream temp(s);
00040         std::string token;
00041         while (temp >> token)
00042         {
00043                 ret.push_back(token);
00044         }
00045 }
00046 
00047 // convert string to int
00048 int eabffunc::chartoint(const std::string& c)
00049 {
00050         std::stringstream temp(c);
00051         int token;
00052         temp >> token;
00053         return token;
00054 }
00055 
00056 // convert string to double
00057 double eabffunc::chartodouble(const std::string& c)
00058 {
00059         std::stringstream temp(c);
00060         double token;
00061         temp >> token;
00062         return token;
00063 }
00064 
00065 // convert double to int
00066 int eabffunc::doubletoint(const double a)
00067 {
00068         if (a > 0)
00069                 return int(a + 0.000001);
00070         else
00071                 return int(a - 0.000001);
00072 }
00073 
00074 #endif

Generated on Thu Nov 23 01:17:12 2017 for NAMD by  doxygen 1.4.7