55#define strcasecmp _stricmp
57#define strtoull _strtoui64
63 unsigned int n = uc.size();
64 for (
unsigned int j = 0; j < n; j++) {
66 if (sj >=
'a' && sj <=
'z') uc[j] = (char)(sj - (
'a' -
'A'));
71 int findBegin(std::istream& theStream,
const char* startText) {
72 const int MAXLEN = 1024;
73 char readLine[MAXLEN];
79 theStream.seekg(0, std::ios::beg);
82 if (!theStream.eof()) {
83 theStream.getline(readLine, MAXLEN);
86 printf(
"Error fast forwarding stream: stream is empty.\n");
91 if (theStream.eof()) {
92 printf(
"Error fast forwarding stream at line %d: "
93 "stream ended unexpectedly.\n",
98 the_token = strtok(readLine,
" ,;\t");
99 if (the_token != NULL)
100 if (!strcasecmp(
"begin", the_token)) {
101 the_token = strtok(NULL,
" ,;\t");
102 if (the_token != NULL) {
103 foundText = !strcasecmp(startText, the_token);
108 if (!theStream.eof()) {
109 theStream.getline(readLine, MAXLEN);
112 printf(
"Error fast forwarding stream at line %d: "
113 "stream ended unexpectedly.\n",
126 working_line = strdup(line);
128 foo = strtok(working_line,
" ,;\t");
131 if (!strcasecmp(foo,
"end")) {
141 std::string OpenMD_itoa(
int value,
unsigned int base) {
142 const char digitMap[] =
"0123456789abcdef";
145 if (base == 0 || base > 16) {
return buf; }
162 for (
int i = 30; _value && i; --i) {
163 buf = digitMap[_value % base] + buf;
166 return sign.append(buf);
170 return str.substr(0, str.rfind(
'.'));
173 bool isInteger(
const std::string& str) {
176 std::string::const_iterator i = str.begin();
177 if (i != str.end() && (*i ==
'+' || *i ==
'-' || std::isdigit(*i))) {
179 while (i != str.end() && std::isdigit(*i))
181 if (i == str.end()) result =
true;
187 bool CaseInsensitiveEquals(
const char ch1,
const char ch2) {
188 return std::toupper((
unsigned char)ch1) == std::toupper((
unsigned char)ch2);
191 size_t CaseInsensitiveFind(
const std::string& str1,
const std::string& str2) {
192 std::string::const_iterator pos =
193 std::search(str1.begin(), str1.end(), str2.begin(), str2.end(),
194 CaseInsensitiveEquals);
195 if (pos == str1.end())
196 return std::string::npos;
198 return pos - str1.begin();
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
std::string UpperCase(const std::string &S)
Converts a string to UPPER CASE.
int findBegin(std::istream &theStream, const char *startText)
Finds the location of the string "begin <startText>" in an input stream.
std::string getPrefix(const std::string &str)
int isEndLine(char *line)
discovers whether or not the line contains the "end" token