HOPS
HOPS class reference
MHO_SelfName.hh
Go to the documentation of this file.
1 #ifndef MHO_SelfName_HH__
2 #define MHO_SelfName_HH__
3 
4 #include <atomic>
5 #include <cstdint>
6 #include <thread>
7 
8 namespace hops
9 {
10 
11 namespace selfname
12 {
13 /*!*
14  *@file MHO_SelfName.hh
15  *@brief constexpr to strip path prefix from __FILE__ macros
16  *@author J. Barrett - barrettj@mit.edu
17  */
18 
19 //needed for stripping the path prefix from __FILE__ macro contents
20 //see https://stackoverflow.com/questions/31050113
21 constexpr const char* str_end(const char* str)
22 {
23  return *str ? str_end(str + 1) : str;
24 }
25 
32 constexpr bool str_slash(const char* str)
33 {
34  return *str == '/' ? true : (*str ? str_slash(str + 1) : false);
35 }
36 
43 constexpr const char* r_slash(const char* str)
44 {
45  return *str == '/' ? (str + 1) : r_slash(str - 1);
46 }
47 
54 constexpr const char* file_basename(const char* str)
55 {
56  return str_slash(str) ? r_slash(str_end(str)) : str;
57 }
58 
59 } // namespace selfname
60 
61 } // namespace hops
62 
63 #endif
constexpr const char * str_end(const char *str)
Definition: MHO_SelfName.hh:21
constexpr const char * r_slash(const char *str)
Checks if a string starts with '/', recursively.
Definition: MHO_SelfName.hh:43
constexpr const char * file_basename(const char *str)
Returns the base name (file name without path) from a given string.
Definition: MHO_SelfName.hh:54
constexpr bool str_slash(const char *str)
Checks if a string starts with '/'. Used for stripping path prefix from FILE.
Definition: MHO_SelfName.hh:32
Definition: MHO_ChannelLabeler.hh:17