indii/ml/data/Reader.cpp

00001 #include "Reader.hpp"
00002 
00003 #include <fstream>
00004 
00005 using namespace indii::ml::data;
00006 
00007 Reader::Reader(std::istream* in) : in(in), ownStream(false) {
00008   //
00009 }
00010 
00011 Reader::Reader(const std::string& file) : ownStream(true) {
00012   in = new std::ifstream(file.c_str());
00013 }
00014 
00015 Reader::Reader(std::istream* in, unsigned int col) : in(in),
00016     ownStream(false) {
00017   cols.push_back(col);
00018 }
00019 
00020 Reader::Reader(const std::string& file, unsigned int col) : ownStream(true) {
00021   in = new std::ifstream(file.c_str());
00022   cols.push_back(col);
00023 }
00024 
00025 Reader::Reader(std::istream* in, const std::vector<unsigned int>& cols) :
00026     in(in), cols(cols), ownStream(false) {
00027   //
00028 }
00029 
00030 Reader::Reader(const std::string& file, const std::vector<unsigned int>& cols)
00031     : cols(cols), ownStream(true) {
00032   in = new std::ifstream(file.c_str());
00033 }
00034 
00035 Reader::~Reader() {
00036   if (ownStream) {
00037     static_cast<std::ifstream*>(in)->close();
00038     delete in;
00039   }
00040 }
00041 

Generated on Wed Dec 17 15:11:57 2008 for dysii Dynamical Systems Library by  doxygen 1.5.3