| 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]  Vardeman & Gezelter, in progress (2009). | 
| 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 | + | #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; | 
| 230 |  | std::string getSuffix(const std::string& str) { | 
| 231 |  | return str.substr(0, str.find('.')); | 
| 232 |  | } | 
| 233 | < |  | 
| 234 | < | bool isInteger(const std::string& str) { | 
| 235 | < |  | 
| 233 | > |  | 
| 234 | > | bool isInteger(const std::string& str) { | 
| 235 | > |  | 
| 236 |  | bool result = false; | 
| 237 | < |  | 
| 237 | > |  | 
| 238 |  | std::string::const_iterator i = str.begin(); | 
| 239 |  | if (i != str.end() && (*i == '+' || *i == '-' || std::isdigit(*i) )) { | 
| 240 | < | ++i; | 
| 241 | < | while (i != str.end() && std::isdigit(*i)) | 
| 242 | < | ++i; | 
| 243 | < | if (i == str.end()) | 
| 244 | < | result = true; | 
| 240 | > | ++i; | 
| 241 | > | while (i != str.end() && std::isdigit(*i)) | 
| 242 | > | ++i; | 
| 243 | > | if (i == str.end()) | 
| 244 | > | result = true; | 
| 245 |  | } | 
| 246 |  |  | 
| 247 |  | return result; | 
| 248 | < | } | 
| 236 | < |  | 
| 237 | < | bool CaseInsensitiveEquals(const char ch1, const char ch2) { | 
| 238 | < | return std::toupper((unsigned char)ch1) == std::toupper((unsigned char)ch2); | 
| 239 | < | } | 
| 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 |  |  | 
| 250 | + | bool CaseInsensitiveEquals(const char ch1, const char ch2) { | 
| 251 | + | return std::toupper((unsigned char)ch1) == std::toupper((unsigned char)ch2); | 
| 252 | + | } | 
| 253 | + |  | 
| 254 | + | size_t CaseInsensitiveFind(const std::string& str1, const std::string& str2) { | 
| 255 | + | std::string::const_iterator pos = std::search(str1.begin(), str1.end(), str2.begin(), str2.end(), CaseInsensitiveEquals); | 
| 256 | + | if (pos == str1.end()) | 
| 257 | + | return std::string::npos; | 
| 258 | + | else | 
| 259 | + | return pos - str1.begin(); | 
| 260 | + | } | 
| 261 | + |  | 
| 262 | + | /** | 
| 263 | + | *    memparse - parse a string with mem suffixes into a number | 
| 264 | + | *    @ptr: Where parse begins | 
| 265 | + | *    @retptr: (output) Pointer to next char after parse completes | 
| 266 | + | * | 
| 267 | + | *    Parses a string into a number.  The number stored at @ptr is | 
| 268 | + | *    potentially suffixed with %K (for kilobytes, or 1024 bytes), | 
| 269 | + | *    %M (for megabytes, or 1048576 bytes), or %G (for gigabytes, or | 
| 270 | + | *    1073741824).  If the number is suffixed with K, M, or G, then | 
| 271 | + | *    the return value is the number multiplied by one kilobyte, one | 
| 272 | + | *    megabyte, or one gigabyte, respectively. | 
| 273 | + | */ | 
| 274 | + | unsigned long long memparse (char *ptr,  char **retptr) { | 
| 275 | + | unsigned long long ret = strtoull (ptr, retptr, 0); | 
| 276 | + |  | 
| 277 | + | switch (**retptr) { | 
| 278 | + | case 'G': | 
| 279 | + | case 'g': | 
| 280 | + | ret <<= 10; | 
| 281 | + | case 'M': | 
| 282 | + | case 'm': | 
| 283 | + | ret <<= 10; | 
| 284 | + | case 'K': | 
| 285 | + | case 'k': | 
| 286 | + | ret <<= 10; | 
| 287 | + | (*retptr)++; | 
| 288 | + | default: | 
| 289 | + | break; | 
| 290 | + | } | 
| 291 | + | return ret; | 
| 292 | + | } | 
| 293 | + |  | 
| 294 |  | } |