LineRepository.h


Dosyayı İndir
#ifndef LINEREPOSITORY_H
#define STREAMREPOSITORY_H

#include <string>
#include <vector>
#include <fstream>
#include <stdexcept>

#include "RepositoryUtilities.h"

using namespace std;


class LineRepository
{
public:
    LineRepository(){
    }
    LineRepository(string &filePath) : _filePath(filePath){
    }
    ~LineRepository(){
        delete &_lineVector;
    }
    string &getFilePath(){
        return _filePath;
    }
    void setFilePath(string &filePath){
        _filePath=filePath;
    }
    void add(string line);
    void remove(unsigned int index);
    void load();
    void store();
    void print();

private:
    string _filePath;
    vector<string> _lineVector;
};

void LineRepository::load(){
    ifstream ifs(_filePath.c_str());
    read_vector(ifs,_lineVector);
}

void LineRepository::store(){
    ofstream ofs(_filePath.c_str());
    write_vector(ofs,_lineVector);
    ofs.close();
}

void LineRepository::print(){
    write_vector(cout,_lineVector);
}


void LineRepository::add(string line){
    _lineVector.push_back(line);
}

void LineRepository::remove(unsigned int index){
    if(index>=0 && index<_lineVector.size()){
        _lineVector.erase(_lineVector.begin()+index);
    }else{
        throw out_of_range("Bu s�rada bir ��e yok!" );
    }
}
#endif

				
Dosyayı İndir

Bu Sayfayı Paylaş:




Bu Sayfayı Paylaş:

İletişim Bilgileri

Takip Et

Her Hakkı Saklıdır. Bu sitede yayınlanan tüm bilgi ve fikirlerin kullanımından fibiler.com sorumlu değildir. Bu sitede üretilmiş , derlenmiş içerikleri, fibiler.com'u kaynak göstermek koşuluyla kendi sitenizde kullanılabilirsiniz. Ancak telif hakkı olan içeriklerin hakları sahiplerine aittir