BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSDebug.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef BDSDEBUG_H
19#define BDSDEBUG_H
20
21#include <cstddef>
22#include <cstdio>
23#include <cstdlib>
24#include <string>
25
26inline std::string methodName(const std::string& prettyFunction)
27{
28 size_t end = prettyFunction.rfind("(");
29 size_t begin = prettyFunction.rfind(" ",end) + 1;
30 // if function has pointer type then begin now is *, if so advance one more
31 if (prettyFunction[begin] == '*') {begin++;}
32 size_t len = end - begin;
33 return prettyFunction.substr(begin,len) +"> ";
34}
35#define __METHOD_NAME__ methodName(__PRETTY_FUNCTION__)
36
37
38inline std::string methodEnd(const std::string& prettyFunction)
39{
40 return methodName(prettyFunction) + "- end of method.";
41}
42#define __METHOD_END__ methodEnd(__PRETTY_FUNCTION__)
43
44
45
46#endif