-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPerson.hpp
More file actions
102 lines (88 loc) · 3.12 KB
/
Copy pathPerson.hpp
File metadata and controls
102 lines (88 loc) · 3.12 KB
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
#include <string>
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
// include headers that implement a archive in simple xml
#include <boost/archive/xml_iarchive.hpp>
#include <boost/archive/xml_oarchive.hpp>
#include <boost/serialization/map.hpp>
using namespace std;
vector<string> sexTypeList = {"female","male"};
vector<string> eyeColorsList = {"blue", "green", "brown", "black"};
vector<string> hairColorsList = {"bold", "blond", "brunet", "red", "gray"};
vector<string> animalsList = {"none", "cat","dog"};
struct Candidate{
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
ar & BOOST_SERIALIZATION_NVP(name);
ar & BOOST_SERIALIZATION_NVP(sex);
ar & BOOST_SERIALIZATION_NVP(age);
ar & BOOST_SERIALIZATION_NVP(hight);
ar & BOOST_SERIALIZATION_NVP(eyeColor);
ar & BOOST_SERIALIZATION_NVP(hair);
ar & BOOST_SERIALIZATION_NVP(favAnimal);
ar & BOOST_SERIALIZATION_NVP(email);
ar & BOOST_SERIALIZATION_NVP(phoneNumber);
}
public:
string name;
string sex;
string age;
//Aperance data
string hight; //in cm
string eyeColor;
string hair;
//Person data
string favAnimal;
//Contact data
string email;
string phoneNumber;
//vector<pair<string,string>> ideal;
Candidate(){};
void provide_data(){
cout<<"\nProvide full name: "; cin>>name;
sex = inputDataValidation(sexTypeList, "\nProvide sex (female or male): ");
cout<<"\nProvide age: "; cin>>age;
cout<<"\nProvide hight: "; cin>>hight;
eyeColor = inputDataValidation(eyeColorsList, "\nProvide eye color (blue, green, brown, black): ");
hair = inputDataValidation(hairColorsList, "\nProvide hair color (bold, blond, brunet, red, gray): ");
favAnimal = inputDataValidation(animalsList, "\nProvide favourite animal: (none, cat, dog): ");
cout<<"\nProvide e-mail: "; cin>>email;
cout<<"\nProvide phone number: ";cin>>phoneNumber;
};
void print_all(){
cout<<"\n"<<name<<
"\nSex: "<<sex<<
"\nAge: "<<age<<
"\nHight: "<<hight<<
"\nEye color: "<<eyeColor<<
"\nHair color: "<<hair<<
"\nFavourite animal: "<<favAnimal<<
"\n----------------------------------"<<
"\nPhone number: "<<phoneNumber<<
"\nE-mail:"<<email<<"\n";
};
void print_name(){
cout<<name<<"\n";
};
string inputDataValidation(vector<string>& paramTypeList, string queryText){
bool incorrectInput{1};
string inputVal;
string outputVal;
while(incorrectInput){
cout<<queryText;cin>>inputVal;
auto iterator = find(std::begin(paramTypeList), end(paramTypeList), inputVal);
if(iterator==paramTypeList.end()){
cout<<"\nInvalid data. Follow directions in brackets. Try again.";
}else{
incorrectInput = 0;
outputVal = inputVal;
};
}
return outputVal;
};
};