11#include <boost/algorithm/string.hpp>
12#include <boost/regex.hpp>
26 std::vector<std::string> lineVec;
27 boost::split(lineVec, lines, boost::is_any_of(
"\n"));
33 boost::regex valueLineRegex(
"\\s*([a-zA-Z0-9]+)\\b.*");
34 boost::regex closedSectionRegex(
"\\s*<([a-zA-Z0-9]+)>(.*)</\\1>");
35 boost::regex openSectionRegex(
"\\s*<([a-zA-Z0-9]+)( [0-9]+)?>(.*)");
37 for (
auto lineIt = lineVec.begin(); lineIt != lineVec.end(); ++lineIt) {
38 const std::string line = *lineIt;
40 if (line.length() == 0)
44 boost::smatch matches;
47 if (boost::regex_match(line, matches, valueLineRegex)) {
48 std::string name = matches[1].str();
49 m_lines[name].emplace_back(line);
53 else if (boost::regex_match(line, matches, closedSectionRegex)) {
54 std::string name = matches[1].str();
55 std::string contents = matches[2].str();
61 else if (boost::regex_match(line, matches, openSectionRegex)) {
62 std::stringstream sectionSS;
64 std::string name = matches[1].str();
65 std::string firstLine = matches[2].str();
67 if (matches.size() == 4) {
68 num = matches[2].str();
69 firstLine = matches[3].str();
75 if (firstLine.length() > 0)
76 sectionSS << firstLine <<
"\n";
78 boost::regex openRegex(
"\\s*<" + name + num +
">.*");
79 boost::regex closeRegex(
"\\s*</" + name +
">");
82 auto secIt = lineIt + 1;
86 for (
int depth = 1; depth > 0 && secIt != lineVec.end(); ++secIt) {
87 std::string secLine = *secIt;
89 if (boost::regex_match(secLine, openRegex))
91 else if (boost::regex_match(secLine, closeRegex))
95 sectionSS << secLine <<
"\n";
101 std::string sectionStr = sectionSS.str();
104 if (sectionStr.size() > 0)
105 sectionStr.resize(sectionStr.size() - 1);
107 m_sections[name + num].emplace_back(sectionStr);
113 g_log.
warning() <<
"Unable to identify line in TSVSerialiser::parseLines(): '" << line <<
"'\n";
124 std::vector<std::string> ret;
127 boost::split(ret, line, boost::is_any_of(
"\t"));
134 return std::vector<std::string>();
184 std::stringstream valSS(valStr);
197 std::stringstream valSS(valStr);
210 std::stringstream valSS(valStr);
223 std::stringstream valSS(valStr);
236 std::stringstream valSS(valStr);
253 QPoint point0(x0, y0);
254 QPoint point1(x1, y1);
255 QRect rect(point0, point1);
270 QColor color(r, g, b, a);
400 m_output <<
"\t" << std::string(val);
405 const std::string str = val.toUtf8().constData();
431 auto point0 = val.topLeft();
432 auto point1 = val.bottomRight();
433 m_output <<
"\t" << point0.x() <<
"\t" << point0.y() <<
"\t" << point1.x() <<
"\t" << point1.y();
439 m_output <<
"\t" << val.red() <<
"\t" << val.green() <<
"\t" << val.blue() <<
"\t" << val.alpha();
445 m_output <<
"\t" << val.x() <<
"\t" << val.y();
451 m_output <<
"\t" << val.x() <<
"\t" << val.y();
464 m_midLine = (raw.length() > 0 && raw[raw.length() - 1] !=
'\n');
479 if (body.length() > 0 && body[body.length() - 1] !=
'\n')
500 std::string output =
m_output.str();
std::string outputLines() const
void writeInlineSection(const std::string &name, const std::string &body)
TSVSerialiser & operator<<(const std::string &val)
std::vector< std::string > sections(const std::string &name) const
void writeSection(const std::string &name, const std::string &body)
bool hasSection(const std::string &name) const
bool asBool(const size_t i) const
Mantid::Kernel::CaseInsensitiveMap< std::vector< std::string > > m_sections
QString lineAsQString(const std::string &name, const size_t i=0) const
bool selectLine(const std::string &name, const size_t i=0)
QColor asQColor(const size_t i)
std::vector< std::string > values(const std::string &name, const size_t i=0) const
bool selectSection(const std::string &name, const size_t i=0)
double asDouble(const size_t i) const
size_t asSize_t(const size_t i) const
bool hasLine(const std::string &name) const
QPointF asQPointF(const size_t i)
std::vector< std::string > m_curValues
void storeDouble(const double val)
void storeInt(const int val)
TSVSerialiser & operator>>(std::vector< T > &val)
Mantid::Kernel::CaseInsensitiveMap< std::vector< std::string > > m_lines
void writeRaw(const std::string &raw)
void storeBool(const bool val)
TSVSerialiser & writeLine(const std::string &name)
QString asQString(const size_t i) const
void storeString(const std::string &val)
std::string lineAsString(const std::string &name, const size_t i=0) const
QRect asQRect(const size_t i)
int asInt(const size_t i) const
float asFloat(const size_t i) const
std::stringstream m_output
QPoint asQPoint(const size_t i)
std::string asString(const size_t i) const
void parseLines(const std::string &lines)
The Logger class is in charge of the publishing messages from the framework through various channels.
void warning(const std::string &msg)
Logs at warning level.
Kernel::Logger g_log("ExperimentInfo")
static logger object