| 4881 | } |
| 4882 | |
| 4883 | bool EpwFile::parse(std::istream& ifs, bool storeData) { |
| 4884 | // read line by line |
| 4885 | std::string line; |
| 4886 | |
| 4887 | bool result = true; |
| 4888 | |
| 4889 | // read first 8 lines |
| 4890 | for (unsigned i = 0; i < 8; ++i) { |
| 4891 | |
| 4892 | if (!std::getline(ifs, line)) { |
| 4893 | LOG(Error, "Could not read line " << i + 1 << " of EPW file '" << m_path << "'"); |
| 4894 | return false; |
| 4895 | } |
| 4896 | |
| 4897 | switch (i) { |
| 4898 | case 0: // LOCATION, |
| 4899 | result = result && parseLocation(line); |
| 4900 | break; |
| 4901 | case 1: // DESIGN CONDITIONS |
| 4902 | result = result && parseDesignConditions(line); |
| 4903 | break; |
| 4904 | case 2: // TYPICAL/EXTREME PERIODS |
| 4905 | break; |
| 4906 | case 3: // GROUND TEMPERATURES |
| 4907 | result = result && parseGroundTemperatures(line); |
| 4908 | break; |
| 4909 | case 4: // HOLIDAYS/DAYLIGHT SAVINGS |
| 4910 | result = result && parseHolidaysDaylightSavings(line); |
| 4911 | break; |
| 4912 | case 5: // COMMENTS 1 |
| 4913 | break; |
| 4914 | case 6: // COMMENTS 2 |
| 4915 | break; |
| 4916 | case 7: // DATA PERIODS |
| 4917 | result = result && parseDataPeriod(line); |
| 4918 | break; |
| 4919 | default:; |
| 4920 | } |
| 4921 | } |
| 4922 | |
| 4923 | if (!result) { |
| 4924 | LOG(Error, "Failed to parse EPW file header '" << m_path << "'"); |
| 4925 | return false; |
| 4926 | } |
| 4927 | |
| 4928 | struct EPWString |
| 4929 | { |
| 4930 | const int lineNumber; |
| 4931 | const int year; |
| 4932 | const int month; |
| 4933 | const int day; |
| 4934 | const int hour; |
| 4935 | const int currentMinute; |
| 4936 | std::vector<std::string> strings; |
| 4937 | }; |
| 4938 | |
| 4939 | // read rest of file |
| 4940 | int lineNumber = 8; |
no test coverage detected