gnFileSource.cpp Source File

Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Compound Members File Members

# gnFileSource.cpp

Go to the documentation of this file.

    00001
    00002 // File:            gnFileSource.h
    00003 // Purpose:         Implements generic gnBaseSource methods
    00004 // Description:     Provides a general implementation for accessing DNA
    00005 //                  sequence contig data files.
    00006 // Changes:
    00007 // Version:         libGenome 0.1.0
    00008 // Author:          Aaron Darling
    00009 // Last Edited:     April 15, 2001, 11:13:00pm
    00010 // Modified by:
    00011 // Copyright:       (c) Aaron Darling
    00012 // Licenses:        Proprietary
    00014 #include "gn/gnFileSource.h"
    00015 #include <fstream>
    00016 #include "gn/gnFilter.h"
    00017
    00018 //copy constructor
    00019 gnFileSource::gnFileSource(const gnFileSource& gnfs){
    00020         m_openString = gnfs.m_openString;
    00021         m_pFilter = gnfs.m_pFilter;
    00022         m_newlineType = gnfs.m_newlineType;
    00023         m_newlineSize = gnfs.m_newlineSize;
    00024         m_ifstream.open( m_openString.c_str(), ios::in | ios::binary );
    00025         if( !m_ifstream.is_open() )
    00026                 m_ifstream.clear();
    00027 }
    00028
    00029 // Open, Close
    00030 void gnFileSource::Open( string openString )
    00031 {
    00032         m_ifstream.open(openString.c_str(), ios::in | ios::binary );
    00033         if( m_ifstream.is_open() )
    00034         {
    00035                 m_openString = openString;
    00036                 if( ParseStream(m_ifstream) )
    00037                 {
    00038                         ;
    00039                 }
    00040                 else{
    00041                         m_ifstream.clear();
    00042                         m_ifstream.close();
    00043                 }
    00044         }else{
    00045                 m_ifstream.clear();
    00046                 Throw_gnEx(FileNotOpened());
    00047         }
    00048 }
    00049 void gnFileSource::Open( )
    00050 {
    00051         m_ifstream.open( m_openString.c_str(), ios::in | ios::binary );
    00052         if( !m_ifstream.is_open() ){
    00053                 m_ifstream.clear();
    00054                 Throw_gnEx(FileNotOpened());
    00055         }
    00056 }
    00057 void gnFileSource::Close()
    00058 {
    00059         m_ifstream.close();
    00060         if( m_ifstream.is_open() )
    00061                 Throw_gnEx(IOStreamFailed());
    00062 }
    00063
    00064 boolean gnFileSource::Read( const uint64 pos, char* buf, uint32& bufLen)
    00065 {
    00066         m_ifstream.seekg(pos, ios::beg);
    00067         m_ifstream.read(buf, bufLen);
    00068         if(m_ifstream.fail()){
    00069                 m_ifstream.clear();
    00070                 return false;
    00071         }
    00072         return true;
    00073 }