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
|
void FileReaderAndy::readStaff(vector<StaffAndy>& staffIn)
{
ifstream file;
string line;
file.open("staff.txt");
file.close();
//checks to see if the initiate file exists
if(file.fail())
{
staffIn.push_back(StaffAndy("admin", "0000", true));
}
else
{
file.open("staff.txt");
while(!file.eof())
{
int delim = 0;
getline(file, line);
vector<string> staffStrings;
do
{
delim = line.find("-");
string split = line.substr(0, delim);
staffStrings.push_back(split);
line.erase(0, delim);
}
while(line.size() != 0);
do
{
string account = staffStrings.back();
delim = account.find("+");
string name = account.substr(0, delim);
account.erase(0, delim);
delim = account.find("+");
string isAdmin = account.substr(0, delim);
account.erase(0, delim);
delim = account.find("+");
string password = account.substr(0, delim);
if(isAdmin.compare(ADMIN) == 0)
{
staffIn.push_back(StaffAndy(name, password, true));
}
else
{
staffIn.push_back(StaffAndy(name, password, false));
}
staffStrings.pop_back();
}
while(staffStrings.size() != 0);
}
}
}
|