16#include <boost/algorithm/string.hpp>
17#include <boost/algorithm/string/finder.hpp>
18#include <boost/algorithm/string/iter_find.hpp>
19#include <boost/algorithm/string/predicate.hpp>
20#include <boost/algorithm/string/trim.hpp>
39 std::initializer_list<std::string> exts = {
".prm",
".iparm"};
42 declareProperty(std::make_unique<FileProperty>(
"InputFilename",
"",
FileProperty::Load, exts),
43 "Name of the GSAS instrument parameter file to get fixed for format. ");
46 declareProperty(std::make_unique<FileProperty>(
"OutputFilename",
"",
FileProperty::Save, exts),
47 "Name of the output GSAS instrument parameter file to have format "
59 vector<string> vec_line;
61 infile.open(infilename.c_str(), ios::in);
62 if (!infile.is_open()) {
64 errss <<
"File " << infilename <<
" cannot be opened for reading. "
67 throw runtime_error(errss.str());
71 while (getline(infile, line)) {
73 vector<string> fields;
74 boost::algorithm::split(fields, line, boost::algorithm::is_any_of(
"\n"));
76 throw runtime_error(
"Impossible to have an empty line. ");
77 vec_line.emplace_back(fields[0]);
85 ofile.open(outfilename.c_str(), ios::out);
86 if (!ofile.is_open()) {
88 errss <<
"File " << outfilename <<
" cannot be opened for writing. "
91 throw runtime_error(errss.str());
94 for (
const auto &line : vec_line) {
96 for (
size_t j = line.size(); j <
LINESIZE; ++j)
#define DECLARE_ALGORITHM(classname)
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
@ Save
to specify a file to write to, the file may or may not exist
@ Load
allowed here which will be passed to the algorithm
FixGSASInstrumentFile : TODO: DESCRIPTION.
void exec() override
Implement abstract Algorithm methods.
void error(const std::string &msg)
Logs at error level.
Helper class which provides the Collimation Length for SANS instruments.