| 25 |
|
* @file ElementsTable.cpp |
| 26 |
|
* @author gezelter |
| 27 |
|
* @date 12/21/2007 |
| 28 |
– |
* @time 11:30am |
| 28 |
|
* @version 1.0 |
| 29 |
|
*/ |
| 30 |
|
|
| 32 |
– |
#include <iostream> |
| 31 |
|
#include "config.h" |
| 32 |
+ |
|
| 33 |
+ |
#include <iostream> |
| 34 |
|
#include <cstdlib> |
| 35 |
|
#include <string> |
| 36 |
|
#include <fstream> |
| 37 |
|
#include <cstdlib> |
| 38 |
|
#include "utils/ElementsTable.hpp" |
| 39 |
|
#include "utils/simError.h" |
| 40 |
< |
#include "io/basic_ifstrstream.hpp" |
| 40 |
> |
#include "io/ifstrstream.hpp" |
| 41 |
|
|
| 42 |
– |
#if !HAVE_STRNCASECMP |
| 43 |
– |
extern "C" int strncasecmp(const char *s1, const char *s2, size_t n); |
| 44 |
– |
#endif |
| 45 |
– |
|
| 42 |
|
#ifdef WIN32 |
| 43 |
|
#define FILE_SEP_CHAR "\\" |
| 44 |
|
#else |
| 55 |
|
|
| 56 |
|
ElementsTable::ElementsTable() { |
| 57 |
|
init_ = false; |
| 58 |
< |
STR_DEFINE(dir_, FRC_PATH ); |
| 58 |
> |
dir_ = std::string("TO_STRING(FRC_PATH)"); |
| 59 |
|
envvar_ = "FORCE_PARAM_PATH"; |
| 60 |
|
filename_ = "element.txt"; |
| 61 |
|
} |
| 62 |
|
|
| 63 |
|
ElementsTable::~ElementsTable() { |
| 64 |
|
std::vector<Element*>::iterator i; |
| 65 |
< |
for (i = elements_.begin(); i != elements_.end(); i++) |
| 65 |
> |
for (i = elements_.begin(); i != elements_.end(); ++i) |
| 66 |
|
delete *i; |
| 67 |
|
} |
| 68 |
|
|
| 69 |
|
void ElementsTable::ParseLine(const char *line) { |
| 70 |
|
int num, maxbonds; |
| 71 |
< |
char symbol[5]; |
| 71 |
> |
char symbol[6]; |
| 72 |
|
char name[256]; |
| 73 |
|
RealType Rcov,Rvdw,mass, elNeg, ionize, elAffin; |
| 74 |
|
RealType red, green, blue; |
| 263 |
|
Init(); |
| 264 |
|
|
| 265 |
|
std::vector<Element*>::iterator i; |
| 266 |
< |
for (i = elements_.begin();i != elements_.end();i++) |
| 266 |
> |
for (i = elements_.begin();i != elements_.end(); ++i) |
| 267 |
|
if (!strncasecmp(sym,(*i)->GetSymbol(),2)) |
| 268 |
|
return((*i)->GetAtomicNum()); |
| 269 |
|
|
| 320 |
|
simError(); |
| 321 |
|
} |
| 322 |
|
|
| 323 |
< |
char charBuffer[BUFF_SIZE]; |
| 323 |
> |
|
| 324 |
|
if ((*ifsP)) { |
| 325 |
+ |
char charBuffer[BUFF_SIZE]; |
| 326 |
|
while(ifsP->getline(charBuffer,BUFF_SIZE)) |
| 327 |
|
ParseLine(charBuffer); |
| 328 |
< |
|
| 328 |
> |
|
| 329 |
|
if (ifs1) |
| 330 |
|
ifs1.close(); |
| 331 |
|
if (ifs2) |