Belle II Software  release-05-02-19
StringManipulation.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2014 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <tracking/trackFindingCDC/utilities/Algorithms.h>
13 #include <algorithm>
14 #include <sstream>
15 #include <string>
16 
17 namespace Belle2 {
22  namespace TrackFindingCDC {
24  inline std::string prefixed(const std::string& prefix, const std::string& name)
25  {
26  if (prefix == "") {
27  return name;
28  } else if (name == "") {
29  return prefix;
30  } else {
31  std::string captialisedName = name;
32  captialisedName[0] = ::toupper(name.at(0));
33  return prefix + captialisedName;
34  }
35  }
36 
38  inline std::string quoted(const std::string& text)
39  {
40  return "\"" + text + "\"";
41  }
42 
44  inline std::string bracketed(const std::string& text)
45  {
46  return "(" + text + ")";
47  }
48 
50  template <class Ts>
51  std::string join(const std::string& sep, const Ts& texts)
52  {
53  auto it = std::begin(texts);
54  auto itEnd = std::end(texts);
55  if (it == itEnd) return std::string{};
56  std::ostringstream result;
57  result << *it++;
58  for (; it != itEnd; ++it) {
59  result << sep << *it;
60  }
61  return result.str();
62  }
63 
64  }
66 }
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19