8 printf(
"\nFAILURE: %s\n\n", msg);
20 idx = s.find_first_not_of(
" \t\n\r");
23 idx = s.find_last_not_of(
" \t\n\r");
27 void split_string (
char c, std::string &s, std::string &s1, std::string &s2) {
28 size_t idx = s.find(c);
29 if (idx == std::string::npos) {
30 std::cout <<
"FAILURE: cannot split string" << s <<
"on character" << c << std::endl;
33 s1 = s.substr(0, idx);
34 s2 = s.substr(idx+1, s.length());
40 std::ostringstream str;
42 std::string out = str.str();
51 ofile = fopen(fn,
"w");
53 std::cout <<
"cannot open file:" << fn << std::endl;
64 ofile = fopen(fn,
"r");
66 std::cout <<
"FAILURE: cannot open file " << fn << std::endl;
72 std::vector< std::vector< std::string > >
read_values (
const char *fn) {
74 std::vector< std::vector< std::string > > iset;
78 std::ifstream ifile(fn);
82 std::string::size_type idx;
84 std::vector< std::string > str;
85 while (ifile.getline(readline, 1000)) {
90 if ( (line.length() > 0) && (idx != 0) ) {
92 if (idx != std::string::npos) line = line.substr(0, idx);