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

Comparing trunk/src/utils/ElementsTable.cpp (file contents):
Revision 1293 by chuckv, Sun Sep 14 01:32:26 2008 UTC vs.
Revision 1782 by gezelter, Wed Aug 22 02:28:28 2012 UTC

# Line 1 | Line 1 | This basic Periodic Table class was originally taken f
1   /**********************************************************************
2  
3   This basic Periodic Table class was originally taken from the data.cpp
4 < file in OpenBabel. The code has been modified to match the OOPSE coding style.
4 > file in OpenBabel. The code has been modified to match the OpenMD coding style.
5  
6   We have retained the OpenBabel copyright and GPL license on this class:  
7  
# Line 29 | Line 29 | GNU General Public License for more details.
29   * @version 1.0
30   */
31  
32 #include <iostream>
32   #include "config.h"
33 +
34 + #include <iostream>
35   #include <cstdlib>
36   #include <string>
37   #include <fstream>
38   #include <cstdlib>
39   #include "utils/ElementsTable.hpp"
40   #include "utils/simError.h"
41 < #include "io/basic_ifstrstream.hpp"
41 > #include "io/ifstrstream.hpp"
42  
43 < #if !HAVE_STRNCASECMP
44 < extern "C" int strncasecmp(const char *s1, const char *s2, size_t n);
43 > #ifdef _MSC_VER
44 > #define strncasecmp _strnicmp
45 > #define strcasecmp _stricmp
46   #endif
47  
48 +
49   #ifdef WIN32
50   #define FILE_SEP_CHAR "\\"
51   #else
# Line 53 | Line 56 | extern "C" int strncasecmp(const char *s1, const char
56   #define BUFF_SIZE 32768
57   #endif
58  
59 < namespace oopse {
59 > namespace OpenMD {
60  
61    ElementsTable etab;
62  
63    ElementsTable::ElementsTable() {
64      init_ = false;
65 <    STR_DEFINE(dir_, FRC_PATH );
65 >    dir_ = std::string("TO_STRING(FRC_PATH)");
66      envvar_ = "FORCE_PARAM_PATH";
67      filename_ = "element.txt";
68    }
# Line 78 | Line 81 | namespace oopse {
81      RealType red, green, blue;
82  
83      // skip comment line (at the top)
81    
84      if (line[0] != '#')  {
85        sscanf(line,"%d %5s %lf %*f %lf %d %lf %lf %lf %lf %lf %lf %lf %255s",
86               &num,
# Line 110 | Line 112 | namespace oopse {
112      return elements_.size();
113    }
114  
115 <  char *ElementsTable::GetSymbol(int atomicnum) {
115 >  const char *ElementsTable::GetSymbol(int atomicnum) {
116      if (!init_)
117        Init();
118      
# Line 295 | Line 297 | namespace oopse {
297        buffer = getenv(envvar_.c_str());
298        buffer += FILE_SEP_CHAR;
299        
300 +
301 +
302 +
303        if (!subdir_.empty()) {
304          subbuffer = buffer;
305          subbuffer += subdir_;
306          subbuffer += FILE_SEP_CHAR;
307        }
308        
309 +
310 +      
311        buffer += filename_;
312        subbuffer += filename_;
313 +
314        
315        ifs1.open(subbuffer.c_str());
316        ifsP= &ifs1;
317 <      if (!(*ifsP)) {
317 >      if (!(ifsP->is_open())) {
318          ifs2.open(buffer.c_str());
319          ifsP = &ifs2;
320        }
321 +      
322      } else {
323        sprintf( painCave.errMsg,
324                 "ElementsTable error.\n"
# Line 322 | Line 331 | namespace oopse {
331      if ((*ifsP)) {
332        while(ifsP->getline(charBuffer,BUFF_SIZE))
333          ParseLine(charBuffer);
334 <      
334 >
335        if (ifs1)
336          ifs1.close();
337        if (ifs2)

Comparing trunk/src/utils/ElementsTable.cpp (property svn:keywords):
Revision 1293 by chuckv, Sun Sep 14 01:32:26 2008 UTC vs.
Revision 1782 by gezelter, Wed Aug 22 02:28:28 2012 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines