diff --git a/Device/InputOutput/OutputDataReadWriteNicos.cpp b/Device/InputOutput/OutputDataReadWriteNicos.cpp index d61a3f2b2fec0bb351e7a6e0cbdc747d26f6fb47..14ffd17999442f8a93e90a89e72ed902cd68ebd7 100644 --- a/Device/InputOutput/OutputDataReadWriteNicos.cpp +++ b/Device/InputOutput/OutputDataReadWriteNicos.cpp @@ -15,6 +15,16 @@ #include "Device/InputOutput/OutputDataReadWriteNicos.h" #include "Base/Util/StringUtils.h" +namespace { + +std::string lineRelatedError(const std::string& errorText, int lineNumber) +{ + return "Line " + std::to_string(lineNumber) + ": " + errorText; +} + +} // namespace + + OutputData<double>* OutputDataReadWriteNicos::readOutputData(std::istream& input_stream) { auto result = std::make_unique<OutputData<double>>(); // as unique ptr to ensure delete on throw @@ -94,7 +104,8 @@ OutputData<double>* OutputDataReadWriteNicos::readOutputData(std::istream& input if (valuesAsString.size() != width) throw std::runtime_error( lineRelatedError("Number of found values (" + std::to_string(valuesAsString.size()) - + ") does not match DataSizeX (" + std::to_string(width) + ").")); + + ") does not match DataSizeX (" + std::to_string(width) + ").", + m_currentLineNr)); for (unsigned col = 0; col < width; ++col) { const size_t global_index = result->toGlobalIndex( @@ -103,8 +114,10 @@ OutputData<double>* OutputDataReadWriteNicos::readOutputData(std::istream& input int value = 0; if (!BaseUtils::String::to_int(valuesAsString[col], &value)) - throw std::runtime_error(lineRelatedError( - "Value '" + valuesAsString[col] + "' could not be converted to integer.")); + throw std::runtime_error( + lineRelatedError("Value '" + valuesAsString[col] + + "' could not be converted to integer.", + m_currentLineNr)); (*result)[global_index] = value; } @@ -127,20 +140,16 @@ unsigned int OutputDataReadWriteNicos::readAssignedPositiveIntValue(const std::s { const auto parts = BaseUtils::String::split(line, "="); if (parts.size() != 2) - throw std::runtime_error(lineRelatedError("Missing assigned value.")); + throw std::runtime_error(lineRelatedError("Missing assigned value.", m_currentLineNr)); int value = 0; if (!BaseUtils::String::to_int(parts[1], &value)) throw std::runtime_error( - lineRelatedError("Can't parse assigned value '" + parts[1] + "'.")); + lineRelatedError("Can't parse assigned value '" + parts[1] + "'.", m_currentLineNr)); if (value <= 0) - throw std::runtime_error(lineRelatedError("Value of '" + parts[1] + "' is nonpositive.")); + throw std::runtime_error(lineRelatedError("Value of '" + parts[1] + "' is nonpositive.", + m_currentLineNr)); return value; } - -std::string OutputDataReadWriteNicos::lineRelatedError(const std::string& errorText) const -{ - return "Line " + std::to_string(m_currentLineNr) + ": " + errorText; -} diff --git a/Device/InputOutput/OutputDataReadWriteNicos.h b/Device/InputOutput/OutputDataReadWriteNicos.h index 541c1e63b01a2472feb10a19f816e25f26aa9a52..94540f0d19e08d24d56222fe1cbcb3df5ff2982a 100644 --- a/Device/InputOutput/OutputDataReadWriteNicos.h +++ b/Device/InputOutput/OutputDataReadWriteNicos.h @@ -28,9 +28,6 @@ private: //! Throws if not successful or if value is nonpositive unsigned int readAssignedPositiveIntValue(const std::string& line) const; - //! Returns errorText with prepended line number (suitable for throwing errors) - std::string lineRelatedError(const std::string& errorText) const; - int m_currentLineNr = 0; //!< "1" means "first line" (human readable counting) }; diff --git a/auto/Wrap/doxygenDevice.i b/auto/Wrap/doxygenDevice.i index 3a8c257fd45ff2077237b89a2359366f464b9f48..ff32ced498f63dd14e14edd70a9063f7cf394b20 100644 --- a/auto/Wrap/doxygenDevice.i +++ b/auto/Wrap/doxygenDevice.i @@ -2121,7 +2121,7 @@ C++ includes: OutputDataReadWriteINT.h // File: classOutputDataReadWriteNicos.xml %feature("docstring") OutputDataReadWriteNicos " -Read/write Nicos files (*.001). +Read/write SANSDRaw files written by Nicos (*.001). C++ includes: OutputDataReadWriteNicos.h "; @@ -2778,6 +2778,9 @@ Returns default units to convert to. // File: namespace_0d55.xml +// File: namespace_0d61.xml + + // File: namespace_0d63.xml