Mantid
Loading...
Searching...
No Matches
UserStringParser.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2010 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9//----------------------------------------------------------------------
10// Includes
11//----------------------------------------------------------------------
12
13#include "MantidKernel/DllConfig.h"
14#include <string>
15#include <vector>
16
17namespace Mantid {
18namespace Kernel {
19
36class MANTID_KERNEL_DLL UserStringParser {
37public:
39 std::vector<std::vector<unsigned int>> parse(const std::string &userString);
40
41private:
43 std::vector<std::string> separateComma(const std::string &);
46 std::vector<std::vector<unsigned int>> separateColon(const std::string &input);
49 std::vector<unsigned int> separateDelimiters(const std::string &input, const std::string &delimiters);
50
52 unsigned int toUInt(const std::string &input);
54 bool Contains(const std::string &input, char ch);
55
58 void Tokenize(const std::string &input, const std::string &delimiter, unsigned int &start, unsigned int &end,
59 unsigned int &step);
60
62 void parse(const std::string &userString, std::vector<std::vector<unsigned int>> &numbers);
64 bool isValid(const std::string &input, std::vector<std::string> &tokens);
66 void convertToNumbers(const std::string &input, const std::vector<std::string> &tokens, unsigned int &start,
67 unsigned int &end, unsigned int &step);
68 // returns true if the separator before the step string is valid
69 bool isValidStepSeparator(const std::string &input, const std::vector<std::string> &tokens);
70};
71} // namespace Kernel
72} // namespace Mantid
This class parses a given string into vector of vectors of numbers.
bool isValid(const std::string &input, std::vector< std::string > &tokens)
validates the input string
Helper class which provides the Collimation Length for SANS instruments.