17Logger logger(
"Regex");
28template <
typename T>
int StrComp(
const std::string &Text,
const boost::regex &Re, T &Aout,
const int compNum) {
29 boost::sregex_iterator m1(Text.begin(), Text.end(), Re);
30 boost::sregex_iterator empty;
32 if (m1 == empty ||
static_cast<int>((*m1).size()) < compNum)
37 return convert((*m1)[0].str(), Aout);
48template <
typename T>
int StrComp(
const char *Text,
const boost::regex &Re, T &Aout,
const int compNum) {
49 return StrComp(std::string(Text), Re, Aout, compNum);
58int StrLook(
const std::string &Text,
const boost::regex &Re) {
59 boost::sregex_iterator m1(Text.begin(), Text.end(), Re);
60 boost::sregex_iterator empty;
74std::vector<std::string>
StrParts(std::string Sdx,
const boost::regex &Re) {
75 std::vector<std::string> Aout;
76 boost::regex_split(std::back_inserter(Aout), Sdx,
93template <
typename T>
int StrFullCut(std::string &Text,
const boost::regex &Re, T &Aout,
const int compNum) {
94 boost::sregex_iterator m1(Text.begin(), Text.end(), Re);
95 boost::sregex_iterator empty;
99 if (compNum + 1 >=
static_cast<int>(m1->size()))
105 unsigned int zero = 0;
106 Text.erase(m1->position(zero), (*m1)[0].str().length());
121template <
typename T>
int StrFullCut(std::string &Text,
const boost::regex &Re, std::vector<T> &Aout) {
122 boost::sregex_iterator m1(Text.begin(), Text.end(), Re);
123 boost::sregex_iterator empty;
127 logger.information() <<
"SFC :: \n";
129 unsigned int zero = 0;
130 const size_t M0 = m1->position(zero);
132 for (; m1 != empty; m1++) {
137 Aout.emplace_back(
tmp);
139 ML = m1->position(zero) + (*m1)[0].str().length();
141 logger.information() <<
"SFC :: " << M0 <<
" " << ML <<
'\n';
160template <>
int StrFullCut(std::string &Text,
const boost::regex &Re, std::vector<std::string> &Aout) {
161 boost::sregex_iterator m1(Text.begin(), Text.end(), Re);
162 boost::sregex_iterator empty;
166 unsigned int zero = 0;
167 const auto M0 =
static_cast<int>(m1->position(zero));
169 for (; m1 != empty; m1++) {
170 ML =
static_cast<int>(m1->position(zero) + (*m1)[0].str().length());
172 Aout.emplace_back((*m1)[
index].str());
174 logger.information() <<
"SFC :: " << M0 <<
" " << ML <<
'\n';
191template <
typename T>
int StrFullSplit(
const std::string &text,
const boost::regex &Re, std::vector<T> &Aout) {
192 boost::sregex_iterator m1(text.begin(), text.end(), Re);
193 boost::sregex_iterator empty;
194 for (; m1 != empty; m1++)
198 return static_cast<int>(Aout.size());
199 Aout.emplace_back(
tmp);
201 return static_cast<int>(Aout.size());
215template <
typename T>
int StrSingleSplit(
const std::string &text,
const boost::regex &Re, std::vector<T> &Aout) {
216 boost::sregex_iterator m1(text.begin(), text.end(), Re);
217 boost::sregex_iterator empty;
222 return static_cast<int>(Aout.size());
223 Aout.emplace_back(
tmp);
226 return static_cast<int>(Aout.size());
241template <>
int StrSingleSplit(
const std::string &text,
const boost::regex &Re, std::vector<std::string> &Aout) {
242 boost::sregex_iterator m1(text.begin(), text.end(), Re);
243 boost::sregex_iterator empty;
246 Aout.emplace_back((*m1)[
index].str());
264 fh.getline(ss, 512,
'\n');
265 while (!fh.fail() && !boost::regex_search(ss, ans, Re, boost::match_default)) {
266 fh.getline(ss, 512,
'\n');
282template <
typename T>
int findComp(std::istream &fh,
const boost::regex &Re, T &Out) {
287 fh.getline(ss, 512,
'\n');
288 while (!fh.fail() && !boost::regex_search(ss, ans, Re, boost::match_default)) {
290 fh.getline(ss, 512,
'\n');
292 if (ans[0].matched) {
293 std::string xout(ans[1].first, ans[1].second);
312 fh.getline(ss, 512,
'\n');
313 while (!fh.fail() && !boost::regex_search(ss, ans, Re, boost::match_default)) {
315 fh.getline(ss, 512,
'\n');
317 if (ans[0].matched) {
318 Out = std::string(ans[1].first, ans[1].second);
326template DLLExport int StrFullCut(std::string &,
const boost::regex &, std::string &,
const int);
328template DLLExport int StrFullCut(std::string &,
const boost::regex &,
double &,
const int);
331template DLLExport int StrFullSplit(
const std::string &,
const boost::regex &, std::vector<double> &);
332template DLLExport int StrFullSplit(
const std::string &,
const boost::regex &, std::vector<std::string> &);
337template DLLExport int StrComp(
const char *,
const boost::regex &,
double &,
const int);
338template DLLExport int StrComp(
const char *,
const boost::regex &,
int &,
const int);
339template DLLExport int StrComp(
const std::string &,
const boost::regex &,
double &,
const int);
340template DLLExport int StrComp(
const std::string &,
const boost::regex &,
int &,
const int);
std::map< DeltaEMode::Type, std::string > index
#define DLLExport
Definitions of the DLLImport compiler directives for MSVC.
Holds support functions for strings.
MANTID_KERNEL_DLL int findPattern(std::istream &, const boost::regex &, std::string &)
Finds a pattern in a file.
MANTID_KERNEL_DLL int findComp(std::istream &, const boost::regex &, T &)
Find a compmonent in a Regex in a file.
MANTID_KERNEL_DLL int StrComp(const char *, const boost::regex &, T &, const int=0)
Find if a pattern matches a string.
int StrSingleSplit(const std::string &, const boost::regex &, std::vector< T > &)
Split a line searched parts.
int StrFullCut(std::string &, const boost::regex &, T &, const int=-1)
Cut out the searched section and returns component.
int StrFullSplit(const std::string &, const boost::regex &, std::vector< T > &)
Split a line searched parts.
MANTID_KERNEL_DLL int StrLook(const std::string &, const boost::regex &)
Find is a pattern matches.
MANTID_KERNEL_DLL std::vector< std::string > StrParts(std::string, const boost::regex &)
Split a line into component parts.
int convert(const std::string &A, T &out)
Convert a string into a number.