Code:
#include "stdafx.h"
#include "vector"
#include "list"
#include "map"
#include "fstream"
using namespace std;
void ReadFile_FillStruct_1(string _fileName, vector<string>& _vectorStorage, bool _boolArg);
void ReadFile_FillStruct_2(string _fileName, vector<int>& _vectorStorage);
void ReadFile_FillStruct_3(string _fileName, list<string>& _listStorage, bool _boolArg);
void ReadFile_FillStruct_4(string _fileName, map<int, string>& _mapStorage, bool _boolArg);
int _tmain(int argc, _TCHAR* argv[])
{
vector<string> _vector_1;
vector<int> _vector_2;
list<string> _list;
map <int,string> _map;
string _fileName = "C:\\Temp\\FileName.txt";
ReadFile_FillStruct_1(_fileName, _vector_1, false);
_fileName = "C:\\Temp\\FileName1.txt";
ReadFile_FillStruct_3(_fileName, _list, true);
_fileName = "C:\\Temp\\FileName2.txt";
ReadFile_FillStruct_2(_fileName, _vector_2);
_fileName = "C:\\Temp\\FileName3.txt";
ReadFile_FillStruct_4(_fileName, _map, false);
return 0;
}
void ReadFile_FillStruct_1(string _fileName, vector<string>& _vectorStorage, bool _boolArg)
{
ifstream infile;
infile.open (_fileName.c_str());
while(!infile.eof())
{
// parse data, check if it is meaningful(same for all func)******
// perform necessary munipulation/validation based on _boolArg
// fill the container
}
infile.close();
}
void ReadFile_FillStruct_2(string _fileName, vector<int>& _vectorStorage)
{
ifstream infile;
infile.open (_fileName.c_str());
while(!infile.eof())
{
// parse data, check if it is meaningful(same for all func)******
// fill the container
}
infile.close();
}
void ReadFile_FillStruct_3(string _fileName, list<string>& _listStorage, bool _boolArg)
{
ifstream infile;
infile.open (_fileName.c_str());
while(!infile.eof())
{
// parse data, check if it is meaningful(same for all func)******
// perform necessary munipulation based on _boolArg
// fill the container
}
infile.close();
}
void ReadFile_FillStruct_4(string _fileName, map<int, string>& _mapStorage, bool _boolArg)
{
ifstream infile;
infile.open (_fileName.c_str());
while(!infile.eof())
{
// parse data, check if it is meaningful(same for all func)******
// perform necessary munipulation based on _boolArg
// fill the container
}
infile.close();
}