File: read.cc

package info (click to toggle)
icmake 13.05.01-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,132 kB
  • sloc: cpp: 11,595; fortran: 883; makefile: 853; sh: 546; pascal: 342
file content (28 lines) | stat: -rw-r--r-- 745 bytes parent folder | download | duplicates (2)
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
#define XERR
#include "support.ih"

Support::StringVect Support::read(string const &filename)
{
    StringVect ret;

    
    if (
        size_t pos = filename.find_first_not_of(" \t");     // 1st non-ws pos
        pos == string::npos                                 // not found or
        or filename[pos] == '#' or filename.find("//") == pos   // comment
    )
        return ret;

    if (not Tools::exists(filename))
        cout << "skipping non-existing `" << filename << "'\n";
    else
    {        
        ifstream in{ Exception::factory<ifstream>(filename) };
        
        string line;
        while (getline(in, line))       // store all the lines in the .ih file
            ret.push_back(line);    
    }

    return ret;
}