1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
#include "stdafx.h"
#include "tchar.h"
#include <fstream>
#include <string>
#include <vector>
#include <iostream>
#include <cstdlib>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string BronBestand;
string TemplateBestand;
string regel;
vector<string>Template;
vector<string>Bron;
cout << "Geef het adres van het bronbestand" << endl;
cin >> BronBestand;
cout << "Geef het adres van de template" << endl;
cin >> TemplateBestand;
system("CLS");
cin.ignore(1000,'\n');
//////////////////////////////////////////////
// read template
//////////////////////////////////////////////
ifstream bestand(TemplateBestand.c_str());
if(!bestand)
{
cout << "Het bestand " << TemplateBestand << " kan niet geopend worden." << endl;
cin.get();
return 0;
}
else
{
while (!bestand.eof())
{
getline(bestand, regel);
Template.push_back(regel);
}
bestand.close();
cout << "template bestand ingelezen" << endl;
}
//////////////////////////////////////////////
// read source
//////////////////////////////////////////////
ifstream brbestand(BronBestand.c_str());
if(!brbestand)
{
cout << "Het bestand " << BronBestand << " kan niet geopend worden." << endl;
cin.get();
return 0;
}
else
{
while (!brbestand.eof())
{
getline(brbestand, regel);
Bron.push_back(regel);
}
brbestand.close();
cout << "bron bestand ingelezen" << endl;
}
//////////////////////////////////////////////
// write file
//////////////////////////////////////////////
ofstream bipFile;
bipFile.open("c:\text.txt");
bipFile << "ok";
if (!bipFile.is_open())
{
cout << "Fout bij het aanmaken van het bestand." << endl;
cin.get();
return 0;
}
else
{
vector<string>::iterator bronPos;
vector<string>::iterator temPos;
for (bronPos = Bron.begin(); bronPos != Bron.end(); ++bronPos)
{
string::size_type beginIndex, eindIndex;
string deel = (string)*bronPos;
beginIndex = deel.find_first_not_of(";");
//while(beginIndex != string::npos)
//{
eindIndex = deel.find_first_of(";", beginIndex);
string naam = deel.substr(beginIndex, eindIndex);
cout << naam << endl;
beginIndex = deel.find_first_not_of(";", eindIndex);
eindIndex = deel.find_first_of(";", beginIndex);
string rgb = deel.substr(beginIndex, eindIndex);
cout << rgb << endl;
for (temPos = Template.begin(); temPos != Template.end(); ++ temPos)
{
string temp = (string) *temPos;
if (temp.find("NAME"))
{
//temp.replace("NAME",naam);
}
}
//}
}
}
cin.ignore(1000,'\n');
return 0;
}
|