36 return c ==
'\\' || c ==
'/';
43constexpr const char* extract_after_last_dotdot_impl(
const char* str,
48 ? (last ? last : orig)
49 : (str[0] ==
'.' && str[1] ==
'.' && is_sep(str[2]))
50 ? extract_after_last_dotdot_impl(str + 3, str + 3, orig)
51 : extract_after_last_dotdot_impl(str + 1, last, orig);
58 return extract_after_last_dotdot_impl(str,
nullptr, str);
62constexpr const char* extract_filename_impl(
const char* str,
const char* last,
const char* orig)
65 ? (last ? last + 1 : orig)
67 ? extract_filename_impl(str + 1, str, orig)
68 : extract_filename_impl(str + 1, last, orig));
73constexpr const char*
extract_filename(
const char* str,
const char* last_sep_pos=
nullptr)
75 return extract_filename_impl(str,
nullptr, str);
80#define A_SOURCE_FILE_PATH _AST extract_after_last_dotdot(__FILE__)
81#define A_SOURCE_FILE_NAME _AST extract_filename(__FILE__)
82#define A_SOURCE_LINE __LINE__
83#define A_SOURCE_FUNC __FUNCTION__
constexpr bool is_sep(char c)
判断字符是否为路径分隔符(反斜杠或正斜杠)
定义 SourceLocation.hpp:34
constexpr const char * extract_filename(const char *str, const char *last_sep_pos=nullptr)
从路径中提取文件名,若无分隔符则返回原串
定义 SourceLocation.hpp:73
constexpr const char * extract_after_last_dotdot(const char *str)
查找最后一个 ".." 后的路径,并返回后续实际路径的起始位置,若无 .. 则返回原串
定义 SourceLocation.hpp:56