-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTools.hh
42 lines (39 loc) · 1.07 KB
/
Tools.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef TOOLS
#define TOOLS
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
/* string embraced in quotes */
class qstring: public std::string{
public:
qstring& operator= (std::string &s){
this->resize(s.size());
for (size_t i = 0; i< s.size(); i++) (*this)[i] = s[i];
}
friend std::istream& operator>> (std::istream &is, qstring &other){
char c;
std::string s;
while ((char) is.get() != '"' && is.good());
c = is.get();
while (c != '"' && is.good()){
s += c;
c = is.get();
}
other = s;
return is;
}
};
/* locate a section in control file */
void sclocate(std::ifstream& infile, std::string str){
std::string line;
while(!infile.eof() && line.find(str, 0) == std::string::npos)
getline(infile, line);
if (infile.eof()){
std::cerr << "***** ERROR *****" << std::endl;
std::cerr << "can not find enty: " << str << std::endl;
std::cerr << "*****************" << std::endl;
assert(0);
}
};
#endif