Mantid
Loading...
Searching...
No Matches
FittingGlobals.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2020 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#include <utility>
8
10
12
13GlobalParameter::GlobalParameter(std::string parameter) : m_parameter(std::move(parameter)) {}
14
15GlobalTie::GlobalTie(std::string parameter, std::string tie)
16 : m_parameter(std::move(parameter)), m_tie(std::move(tie)) {}
17
18std::string GlobalTie::toCompositeParameter(std ::string const &fullParameter) const {
19 auto const dotIndex = fullParameter.find(".");
20 if (dotIndex != std::string::npos) {
21 return fullParameter.substr(0, dotIndex + 1) + "f0." + fullParameter.substr(dotIndex + 1);
22 }
23 return fullParameter;
24}
25
26std::string GlobalTie::toNonCompositeParameter(std ::string const &fullParameter) const {
27 auto const firstDotIndex = fullParameter.find(".");
28 if (firstDotIndex != std::string::npos) {
29 auto const secondDotIndex = fullParameter.find(".", firstDotIndex + 1);
30 if (secondDotIndex != std::string::npos) {
31 return fullParameter.substr(0, firstDotIndex + 1) + fullParameter.substr(secondDotIndex + 1);
32 }
33 }
34 return fullParameter;
35}
36
37std::string GlobalTie::asString() const { return m_parameter + "=" + m_tie; }
38
39} // namespace MantidQt::MantidWidgets
STL namespace.
std::string toNonCompositeParameter(std ::string const &fullParameter) const
GlobalTie(std::string parameter, std::string tie)
std::string toCompositeParameter(std ::string const &fullParameter) const