Line data Source code
1 : /* Copyright (C) 2025 Robert Schiwon 2 : * 3 : * This file is part of libjdx. 4 : * 5 : * libjdx is free software: you can redistribute it and/or modify it under the 6 : * terms of the GNU Lesser General Public License as published by the Free 7 : * Software Foundation, either version 3 of the License, or (at your option) any 8 : * later version. 9 : * 10 : * libjdx is distributed in the hope that it will be useful, but WITHOUT ANY 11 : * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 : * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 13 : * details. 14 : * 15 : * You should have received a copy of the GNU Lesser General Public License 16 : * along with libjdx. If not, see <https://www.gnu.org/licenses/>. 17 : */ 18 : #include "jdx/XyData.hpp" 19 : #include "jdx/ParseException.hpp" 20 : #include "jdx/XyBase.hpp" 21 : 22 30 : libjdx::jdx::XyData::XyData(const std::string& label, 23 : const std::string& variableList, const std::vector<StringLdr>& ldrs, 24 30 : io::TextReader& reader, std::optional<std::string>& nextLine) 25 : : XyBase(label, variableList, ldrs, s_xyDataLabel, 26 63 : std::vector<std::string>{ 27 : s_xyDataVariableLists.begin(), s_xyDataVariableLists.end()}, 28 66 : reader, nextLine) 29 : { 30 27 : } 31 : 32 12 : std::vector<std::pair<double, double>> libjdx::jdx::XyData::getData() 33 : { 34 24 : auto varList = getVariableList(); 35 12 : if (varList == s_ooQuirkVarList) 36 : { 37 : // Ocean Optics quirk 38 1 : return XyBase::getXYXYData(); 39 : } 40 11 : if (std::any_of(s_xyDataVariableLists.begin(), 41 11 : s_xyDataVariableLists.end() - 1, 42 14 : [&varList](const std::string& s) { return s == varList; })) 43 : { 44 11 : return XyBase::getXppYYData(); 45 : } 46 0 : throw ParseException("Unsupported variable list for XYDATA: " + varList); 47 : }