ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/utils/StringUtils.cpp
(Generate patch)

Comparing trunk/src/utils/StringUtils.cpp (file contents):
Revision 1596 by gezelter, Mon Jul 25 17:30:53 2011 UTC vs.
Revision 1790 by gezelter, Thu Aug 30 17:18:22 2012 UTC

# Line 36 | Line 36
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 <algorithm>
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;
# Line 97 | Line 110 | namespace OpenMD {
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);
# Line 217 | Line 229 | namespace OpenMD {
229    std::string getSuffix(const std::string& str) {
230      return str.substr(0, str.find('.'));
231    }
232 <
232 >  
233    bool isInteger(const std::string& str) {
234      
235      bool result = false;
# Line 233 | Line 245 | namespace OpenMD {
245      
246      return result;
247    }
236  
237 bool CaseInsensitiveEquals(const char ch1, const char ch2) {
238  return std::toupper((unsigned char)ch1) == std::toupper((unsigned char)ch2);
239 }
248  
249 < size_t CaseInsensitiveFind(const std::string& str1, const std::string& str2) {
250 <  std::string::const_iterator pos = std::search(str1.begin(), str1.end(), str2.begin(), str2.end(), CaseInsensitiveEquals);
251 <  if (pos == str1.end())
252 <    return std::string::npos;
253 <  else
254 <    return pos - str1.begin();
255 < }
256 <
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
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.
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);
# Line 277 | Line 289 | size_t CaseInsensitiveFind(const std::string& str1, co
289      }
290      return ret;
291    }
292 <
292 >  
293   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines