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 1781 by gezelter, Mon Jul 25 17:30:53 2011 UTC vs.
Revision 1782 by gezelter, Wed Aug 22 02:28:28 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 217 | Line 230 | namespace OpenMD {
230    std::string getSuffix(const std::string& str) {
231      return str.substr(0, str.find('.'));
232    }
233 <
233 >  
234    bool isInteger(const std::string& str) {
235      
236      bool result = false;
# Line 233 | Line 246 | namespace OpenMD {
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 }
249  
250 < size_t CaseInsensitiveFind(const std::string& str1, const std::string& str2) {
251 <  std::string::const_iterator pos = std::search(str1.begin(), str1.end(), str2.begin(), str2.end(), CaseInsensitiveEquals);
252 <  if (pos == str1.end())
253 <    return std::string::npos;
254 <  else
255 <    return pos - str1.begin();
256 < }
257 <
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
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.
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);
# Line 277 | Line 290 | size_t CaseInsensitiveFind(const std::string& str1, co
290      }
291      return ret;
292    }
293 <
293 >  
294   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines