本文整理汇总了C++中Period::set_room方法的典型用法代码示例。如果您正苦于以下问题:C++ Period::set_room方法的具体用法?C++ Period::set_room怎么用?C++ Period::set_room使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Period
的用法示例。
在下文中一共展示了Period::set_room方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load_courses_from_csv
void load_courses_from_csv(SchoolSchedule *sopti, string periods_file)
{
ifstream period_list;
string tmps;
char tmpa[500];
vector<string> fields;
// Open the file
period_list.open(periods_file.c_str());
if(period_list.fail()) {
error("error opening file %s", periods_file.c_str());
}
// Ignore header line
period_list.getline(tmpa, 500);
while(1) {
period_list.getline(tmpa, 500);
if(!period_list.good()) {
break;
}
tmps = tmpa;
if(tmps[tmps.size()-1] == '\r')
tmps.erase(tmps.size()-1, 1);
fields = split_string(tmps, ";");
if(fields.size() != 15) {
error("invalid course file format (field_num != 15)");
}
// prepare some variables in advance
bool islab;
int type;
SchoolCourse *current_course;
if(fields[COURSEFILE_FIELD_COURSELAB] == "L")
islab=true;
else if(fields[COURSEFILE_FIELD_COURSELAB] == "C")
islab=false;
else
error("unrecognized course type");
if(fields[COURSEFILE_FIELD_COURSETYPE] == "T")
type = COURSE_TYPE_THEORYONLY;
else if(fields[COURSEFILE_FIELD_COURSETYPE] == "L")
type = COURSE_TYPE_LABONLY;
else if(fields[COURSEFILE_FIELD_COURSETYPE] == "TL")
type = COURSE_TYPE_THEORYLABSAME;
else if(fields[COURSEFILE_FIELD_COURSETYPE] == "TLS")
type = COURSE_TYPE_THEORYLABIND;
// Add course if not exists
if(!sopti->course_exists(fields[COURSEFILE_FIELD_SYMBOL])) {
SchoolCourse newcourse(fields[COURSEFILE_FIELD_SYMBOL]);
newcourse.set_title(fields[COURSEFILE_FIELD_TITLE]);
newcourse.set_type(type);
sopti->course_add(newcourse);
}
current_course = sopti->course(fields[COURSEFILE_FIELD_SYMBOL]);
// Add group if not exists
if(!current_course->group_exists(fields[COURSEFILE_FIELD_GROUP], islab)) {
Group newgroup(fields[COURSEFILE_FIELD_GROUP]);
newgroup.set_lab(islab);
current_course->add_group(newgroup, islab);
}
// Add period. It should not exist.
int period_no = poly_make_period_no(fields[COURSEFILE_FIELD_DAY], fields[COURSEFILE_FIELD_TIME]);
if(current_course->group(fields[COURSEFILE_FIELD_GROUP], islab)->has_period(period_no)) {
error("two occurences of the same period in course file");
}
Period newperiod;
newperiod.set_room(fields[COURSEFILE_FIELD_ROOM]);
newperiod.set_period_no(period_no);
if(fields[COURSEFILE_FIELD_LABWEEK] == "I") {
newperiod.set_week(1);
}
else if(fields[COURSEFILE_FIELD_LABWEEK] == "P") {
newperiod.set_week(2);
}
else {
newperiod.set_week(0);
}
current_course->group(fields[COURSEFILE_FIELD_GROUP], islab)->add_period(newperiod);
}
period_list.close();
}