Example #1
0
void XmlReader::parseSchedules() {
	std::string entries = findTag("schedules");

  if(entries.length() > 0) {
    std::vector<std::string> lines = Tools::explode(";", entries);

    for(int l=0; l<lines.size(); l++) {
      if(lines[l].length() > 0) {
        std::vector<std::string> words = Tools::explode(":", lines[l]);
        Schedule s;
        for(int w=0; w<words.size(); w++) {
          if(typeid(words.at(0))==typeid(std::string))  s.setName(words[0]);
          if(typeid(words.at(1))==typeid(std::string))  s.setSocket(words[1]);
          if(typeid(words.at(2))==typeid(std::string))  s.setGpio(words[2]);
          if(typeid(words.at(3))==typeid(std::string))  s.setHour(atoi(words[3].c_str()));
          if(typeid(words.at(4))==typeid(std::string))  s.setMinute(atoi(words[4].c_str()));
          if(typeid(words.at(5))==typeid(std::string))  s.setOnoff(atoi(words[5].c_str()));
          if(typeid(words.at(6))==typeid(std::string))  s.setStatus(atoi(words[6].c_str()));
        }
        schedules.push_back(s);
      }
    }
  }
}