Belle II Software development
StringManipulation.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#pragma once
9
10#include <tracking/trackFindingCDC/utilities/Algorithms.h>
11#include <algorithm>
12#include <sstream>
13#include <string>
14
15namespace Belle2 {
20 namespace TrackFindingCDC {
22 inline std::string prefixed(const std::string& prefix, const std::string& name)
23 {
24 if (prefix == "") {
25 return name;
26 } else if (name == "") {
27 return prefix;
28 } else {
29 std::string captialisedName = name;
30 captialisedName[0] = ::toupper(name.at(0));
31 return prefix + captialisedName;
32 }
33 }
34
36 inline std::string quoted(const std::string& text)
37 {
38 return "\"" + text + "\"";
39 }
40
42 inline std::string bracketed(const std::string& text)
43 {
44 return "(" + text + ")";
45 }
46
48 template <class Ts>
49 std::string join(const std::string& sep, const Ts& texts)
50 {
51 auto it = std::begin(texts);
52 auto itEnd = std::end(texts);
53 if (it == itEnd) return std::string{};
54 std::ostringstream result;
55 result << *it++;
56 for (; it != itEnd; ++it) {
57 result << sep << *it;
58 }
59 return result.str();
60 }
61
62 }
64}
Abstract base class for different kinds of events.