-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstudent.cpp
94 lines (90 loc) · 2.37 KB
/
student.cpp
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
#include "student.h"
CStudent::CStudent()
{
name_first = "Maxi";
name_last = "Musterfrau";
}
CStudent::~CStudent()
{
}
/**************************************************************************
STD read function
04/2009 OK Implementation
**************************************************************************/
ios::pos_type CStudent::Read(ifstream& input_file)
{
//----------------------------------------------------------------------
string input_line;
char buffer[256]; // MAX_LINE
ios::pos_type position;
//----------------------------------------------------------------------
while(true)
{
position = input_file.tellg(); //OK
input_file.getline(buffer,256);
input_line = buffer;
cout << input_line << endl;
//return position;
if(input_line.size()<1) // empty line
continue;
// Dealing with keywords
if(input_line.find('#')!=string::npos) // keyword found
return position;
// Dealing with subkeywords
if(input_line.find("$NAME_FIRST")!=string::npos) // lesen bis ans Ende des strings
{
input_file.getline(buffer,256);
input_line = buffer;
name_first = input_line;
cout << input_line << endl;
return position;
}
if(input_line.find("$NAME_LAST")!=string::npos)
{
input_file >> name_last;
}
if(input_line.find("$COURSE")!=string::npos)
{
input_file >> course;
}
if(input_line.find("$YEAR")!=string::npos)
{
input_file >> year;
}
if(input_line.find("$BANK_ACCOUNT")!=string::npos)
{
input_file >> bank_account;
}
if(input_line.find("$BIRTHDAY")!=string::npos)
{
input_file >> birthday;
}
if(input_line.find("$NATION")!=string::npos)
{
input_file >> nation;
}
if(input_line.find("$GENDER")!=string::npos)
{
input_file >> gender;
}
if(input_line.find("$ID")!=string::npos)
{
input_file >> id;
}
if(input_line.find("$EMAIL")!=string::npos)
{
input_file >> email;
}
if(input_line.find("$ADDRESS")!=string::npos)
{
input_file >> city;
input_file >> street;
}
if(input_line.find("$FOTO_ID")!=string::npos)
{
input_file >> bmp_id;
}
}
//----------------------------------------------------------------------
return position;
}