#include <iostream>
#include <fstream>
#include <string>
#include <vector>
int pos;
struct Customer
{
int customerID;
std::string salutation;
std::string dateOfBirth;
std::string state;
std::string creationDate;
};
struct Item
{
int itemID;
std::string size;
std::string color;
int manufacturerID;
double price;
};
struct Order
{
int orderItemID;
std::string orderDate;
std::string deliveryDate;
Customer *customer;
Item *item;
};
std::string SubStr(std::string str)
{
int i = pos;
std::string substr = "";
while (str[i] != ';' && str[i]!='\0' && str[i]!=EOF)
{
substr += str[i++];
pos++;
}
pos++;
return substr;
}
int main()
{
std::string str;
std::ifstream file("C:\\Users\\User\\Desktop\\инт сис\\04\\orders_class.txt", std::ios::in);
std::vector<Order*>*vec = new std::vector<Order*>();
int strstr = 0;
while (!file.eof())
{
//if (strstr == 50078)
// bool b = true;
pos = 0;
getline(file, str);
if(!strstr)
getline(file, str);
//std::cout << str << std::endl;
if (str != "")
{
vec->push_back(new Order());
(*vec)[vec->size() - 1]->item = new Item();
(*vec)[vec->size() - 1]->customer = new Customer();
(*vec)[vec->size() - 1]->orderItemID = stoi(SubStr(str));
(*vec)[vec->size() - 1]->orderDate = SubStr(str);
(*vec)[vec->size() - 1]->deliveryDate = SubStr(str);
(*vec)[vec->size() - 1]->item->itemID = stoi(SubStr(str));
(*vec)[vec->size() - 1]->item->size = SubStr(str);
(*vec)[vec->size() - 1]->item->color = SubStr(str);
(*vec)[vec->size() - 1]->item->manufacturerID = stoi(SubStr(str));
std::string::size_type sz;
(*vec)[vec->size() - 1]->item->price = std::stod(SubStr(str), &sz);
(*vec)[vec->size() - 1]->customer->customerID = stoi(SubStr(str));
(*vec)[vec->size() - 1]->customer->salutation = SubStr(str);
(*vec)[vec->size() - 1]->customer->dateOfBirth = SubStr(str);
(*vec)[vec->size() - 1]->customer->state = SubStr(str);
(*vec)[vec->size() - 1]->customer->creationDate = SubStr(str);
}
strstr++;
//std::cout << strstr << std::endl;
}
file.close();
system("pause");
return 0;
}