Belle II Software  release-08-01-10
MakeROOTCompatible Class Reference

Helper class for converting strings into a ROOT-friendly format (e.g. More...

#include <MakeROOTCompatible.h>

Static Public Member Functions

static std::string makeROOTCompatible (std::string str)
 Remove special characters that ROOT dislikes in branch names, e.g. More...
 
static std::string invertMakeROOTCompatible (std::string str)
 Invert makeROOTCompatible operation.
 
static std::map< std::string, std::string > getSubstitutionMap ()
 Substituation map for makeROOTCompatible.
 

Detailed Description

Helper class for converting strings into a ROOT-friendly format (e.g.

: removing special characters in branch names, etc.)

Definition at line 24 of file MakeROOTCompatible.h.

Member Function Documentation

◆ makeROOTCompatible()

std::string makeROOTCompatible ( std::string  str)
static

Remove special characters that ROOT dislikes in branch names, e.g.

(, ), :, etc

Definition at line 60 of file MakeROOTCompatible.cc.

61 {
62  if (str.find("__") != std::string::npos) {
63  B2WARNING("String passed to makeROOTCompatible contains double-underscore __, which is used internally for escaping special characters. "
64  "It is recommended to avoid this. However escaping a string twice with makeROOTCompatible is safe, but will print this warning. "
65  "Passed string: " + str);
66  }
67  auto replace = getSubstitutionMap();
68  for (auto& pair : replace) {
69  boost::replace_all(str, pair.first, pair.second);
70  }
71  const static std::regex blackList("[^a-zA-Z0-9_]");
72  return std::regex_replace(str, blackList, "");
73 }
static std::map< std::string, std::string > getSubstitutionMap()
Substituation map for makeROOTCompatible.

The documentation for this class was generated from the following files: