| 6 |  | * redistribute this software in source and binary code form, provided | 
| 7 |  | * that the following conditions are met: | 
| 8 |  | * | 
| 9 | < | * 1. Acknowledgement of the program authors must be made in any | 
| 10 | < | *    publication of scientific results based in part on use of the | 
| 11 | < | *    program.  An acceptable form of acknowledgement is citation of | 
| 12 | < | *    the article in which the program was described (Matthew | 
| 13 | < | *    A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher | 
| 14 | < | *    J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented | 
| 15 | < | *    Parallel Simulation Engine for Molecular Dynamics," | 
| 16 | < | *    J. Comput. Chem. 26, pp. 252-271 (2005)) | 
| 17 | < | * | 
| 18 | < | * 2. Redistributions of source code must retain the above copyright | 
| 9 | > | * 1. Redistributions of source code must retain the above copyright | 
| 10 |  | *    notice, this list of conditions and the following disclaimer. | 
| 11 |  | * | 
| 12 | < | * 3. Redistributions in binary form must reproduce the above copyright | 
| 12 | > | * 2. Redistributions in binary form must reproduce the above copyright | 
| 13 |  | *    notice, this list of conditions and the following disclaimer in the | 
| 14 |  | *    documentation and/or other materials provided with the | 
| 15 |  | *    distribution. | 
| 28 |  | * arising out of the use of or inability to use software, even if the | 
| 29 |  | * University of Notre Dame has been advised of the possibility of | 
| 30 |  | * such damages. | 
| 31 | + | * | 
| 32 | + | * SUPPORT OPEN SCIENCE!  If you use OpenMD or its source code in your | 
| 33 | + | * research, please cite the appropriate papers when you publish your | 
| 34 | + | * work.  Good starting points are: | 
| 35 | + | * | 
| 36 | + | * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). | 
| 37 | + | * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). | 
| 38 | + | * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). | 
| 39 | + | * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010). | 
| 40 | + | * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). | 
| 41 |  | */ | 
| 42 |  |  | 
| 43 | + | #include "config.h" | 
| 44 |  | #include <algorithm> | 
| 45 | + | #include <stdlib.h> | 
| 46 | + | #include <cctype> | 
| 47 | + | #include <cstdlib> | 
| 48 | + | #include <string> | 
| 49 |  | #include "utils/StringUtils.hpp" | 
| 50 |  |  | 
| 51 | < | namespace oopse { | 
| 51 | > | #ifdef _MSC_VER | 
| 52 | > | #define strcasecmp _stricmp | 
| 53 | > | #define strdup _strdup | 
| 54 | > | #define strtoull _strtoui64 | 
| 55 | > | #endif | 
| 56 | > |  | 
| 57 | > |  | 
| 58 | > | namespace OpenMD { | 
| 59 |  | std::string UpperCase(const std::string& S) { | 
| 60 |  | std::string uc = S; | 
| 61 |  | unsigned int n = uc.size(); | 
| 104 |  | return (str); | 
| 105 |  | } | 
| 106 |  |  | 
| 107 | < | int findBegin(std::istream &theStream, char* startText ){ | 
| 107 | > | int findBegin(std::istream &theStream, const char* startText ){ | 
| 108 |  | const int MAXLEN = 1024; | 
| 109 |  | char readLine[MAXLEN]; | 
| 110 |  | int foundText = 0; | 
| 111 |  | int lineNum; | 
| 112 |  | char* the_token; | 
| 100 | – | char* eof_test; | 
| 113 |  |  | 
| 114 |  | // rewind the stream | 
| 115 |  | theStream.seekg (0, std::ios::beg); | 
| 191 |  | return 0; | 
| 192 |  | } | 
| 193 |  |  | 
| 194 | < | std::string OOPSE_itoa(int value, unsigned int base) { | 
| 194 | > | std::string OpenMD_itoa(int value, unsigned int base) { | 
| 195 |  | const char digitMap[] = "0123456789abcdef"; | 
| 196 |  | std::string buf; | 
| 197 |  |  | 
| 229 |  | std::string getSuffix(const std::string& str) { | 
| 230 |  | return str.substr(0, str.find('.')); | 
| 231 |  | } | 
| 232 | < |  | 
| 233 | < | bool isInteger(const std::string& str) { | 
| 234 | < |  | 
| 232 | > |  | 
| 233 | > | bool isInteger(const std::string& str) { | 
| 234 | > |  | 
| 235 |  | bool result = false; | 
| 236 | < |  | 
| 236 | > |  | 
| 237 |  | std::string::const_iterator i = str.begin(); | 
| 238 |  | if (i != str.end() && (*i == '+' || *i == '-' || std::isdigit(*i) )) { | 
| 239 | < | ++i; | 
| 240 | < | while (i != str.end() && std::isdigit(*i)) | 
| 241 | < | ++i; | 
| 242 | < | if (i == str.end()) | 
| 243 | < | result = true; | 
| 239 | > | ++i; | 
| 240 | > | while (i != str.end() && std::isdigit(*i)) | 
| 241 | > | ++i; | 
| 242 | > | if (i == str.end()) | 
| 243 | > | result = true; | 
| 244 |  | } | 
| 245 |  |  | 
| 246 |  | return result; | 
| 247 | < | } | 
| 247 | > | } | 
| 248 |  |  | 
| 249 | < | bool CaseInsensitiveEquals(const char ch1, const char ch2) { | 
| 250 | < | return std::toupper((unsigned char)ch1) == std::toupper((unsigned char)ch2); | 
| 249 | > | bool CaseInsensitiveEquals(const char ch1, const char ch2) { | 
| 250 | > | return std::toupper((unsigned char)ch1) == std::toupper((unsigned char)ch2); | 
| 251 | > | } | 
| 252 | > |  | 
| 253 | > | size_t CaseInsensitiveFind(const std::string& str1, const std::string& str2) { | 
| 254 | > | std::string::const_iterator pos = std::search(str1.begin(), str1.end(), str2.begin(), str2.end(), CaseInsensitiveEquals); | 
| 255 | > | if (pos == str1.end()) | 
| 256 | > | return std::string::npos; | 
| 257 | > | else | 
| 258 | > | return pos - str1.begin(); | 
| 259 | > | } | 
| 260 | > |  | 
| 261 | > | /** | 
| 262 | > | *    memparse - parse a string with mem suffixes into a number | 
| 263 | > | *    @ptr: Where parse begins | 
| 264 | > | *    @retptr: (output) Pointer to next char after parse completes | 
| 265 | > | * | 
| 266 | > | *    Parses a string into a number.  The number stored at @ptr is | 
| 267 | > | *    potentially suffixed with %K (for kilobytes, or 1024 bytes), | 
| 268 | > | *    %M (for megabytes, or 1048576 bytes), or %G (for gigabytes, or | 
| 269 | > | *    1073741824).  If the number is suffixed with K, M, or G, then | 
| 270 | > | *    the return value is the number multiplied by one kilobyte, one | 
| 271 | > | *    megabyte, or one gigabyte, respectively. | 
| 272 | > | */ | 
| 273 | > | unsigned long long memparse (char *ptr,  char **retptr) { | 
| 274 | > | unsigned long long ret = strtoull (ptr, retptr, 0); | 
| 275 | > |  | 
| 276 | > | switch (**retptr) { | 
| 277 | > | case 'G': | 
| 278 | > | case 'g': | 
| 279 | > | ret <<= 10; | 
| 280 | > | case 'M': | 
| 281 | > | case 'm': | 
| 282 | > | ret <<= 10; | 
| 283 | > | case 'K': | 
| 284 | > | case 'k': | 
| 285 | > | ret <<= 10; | 
| 286 | > | (*retptr)++; | 
| 287 | > | default: | 
| 288 | > | break; | 
| 289 | > | } | 
| 290 | > | return ret; | 
| 291 | > | } | 
| 292 | > |  | 
| 293 |  | } | 
| 240 | – |  | 
| 241 | – | size_t CaseInsensitiveFind(const std::string& str1, const std::string& str2) { | 
| 242 | – | std::string::const_iterator pos = std::search(str1.begin(), str1.end(), str2.begin(), str2.end(), CaseInsensitiveEquals); | 
| 243 | – | if (pos == str1.end()) | 
| 244 | – | return std::string::npos; | 
| 245 | – | else | 
| 246 | – | return pos - str1.begin(); | 
| 247 | – | } | 
| 248 | – |  | 
| 249 | – | } |