Codegen/FileManager.cpp
// TODO: implement this in a fancy way using seek(), tell() and caches
implement this in a fancy way using seek(), tell() and caches
implement this in a fancy way using seek () tell () and caches
std::string FileManager::read(const LocusRange& where) {
    if(where.lhv.filename != where.rhv.filename) {
        return "";
    }
    std::ifstream file(where.lhv.filename.c_str());
    if(!file) return "";
    for(auto i = 0U; i < where.lhv.loc.line-1; ++i) {
        file.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
    }
    file.ignore(where.lhv.loc.col-1);
    std::ostringstream out;
    for(auto i = where.lhv.loc.line; i < where.rhv.loc.line; ++i) {
        std::string line;
        std::getline(file, line);
        out << line << '\n';
    }
    {
        std::vector<char> data(where.rhv.loc.col+1);
        file.get(data.data(), where.rhv.loc.col);
        out << data.data(); 
    }
    return out.str();
}
std :: string FileManager :: read ( const LocusRange & where ) { if ( where . lhv . filename != where . rhv . filename ) { return " " ; } std :: ifstream file ( where . lhv . filename . c_str ( ) ) ; if ( ! file ) return " " ; for ( auto i = 0U ; i < where . lhv . loc . line - 1 ; ++ i ) { file . ignore ( std :: numeric_limits < std :: streamsize > :: max ( ) , ' \n ' ) ; } file . ignore ( where . lhv . loc . col - 1 ) ; std :: ostringstream out ; for ( auto i = where . lhv . loc . line ; i < where . rhv . loc . line ; ++ i ) { std :: string line ; std :: getline ( file , line ) ; out << line << ' \n ' ; } { std :: vector < char > data ( where . rhv . loc . col + 1 ) ; file . get ( data . data ( ) , where . rhv . loc . col ) ; out << data . data ( ) ; } return out . str ( ) ; }
TODO: implement this in a fancy way using seek(), tell() and caches
TODO : implement this in a fancy way using seek () tell () and caches
// std::vector<char> is guaranteed to be null-terminated