24 #ifndef STATICLIB_CONFIG_TRACEMSG_HPP
25 #define STATICLIB_CONFIG_TRACEMSG_HPP
33 #ifdef STATICLIB_ANDROID
35 #endif // STATICLIB_ANDROID
37 #define TRACEMSG(message) staticlib::config::tracemsg(std::string() + message, __FILE__, STATICLIB_CURRENT_FUNCTION, __LINE__)
52 inline std::string
tracemsg(
const std::string& message,
const std::string& file,
const std::string& func,
int line) {
54 auto paren_ind = func.find(
"(");
55 auto fun_end_pos = std::string::npos != paren_ind ? paren_ind : message.length();
56 auto space_ind = func.find_last_of(
" ", fun_end_pos);
57 auto fun_start_pos = (std::string::npos != space_ind && fun_end_pos > space_ind) ? space_ind + 1 : 0;
59 std::string::size_type filename_start_pos = 0;
60 auto slash_ind = file.find_last_of(
"/");
61 if (std::string::npos != slash_ind && file.length() > slash_ind) {
62 filename_start_pos = slash_ind + 1;
64 auto backslash_ind = file.find_last_of(
"\\");
65 if (std::string::npos != backslash_ind && file.length() > backslash_ind) {
66 filename_start_pos = backslash_ind + 1;
70 #ifdef STATICLIB_ANDROID
71 std::stringstream linestream;
73 std::string linest = linestream.str();
75 std::string linest = std::to_string(line);
76 #endif // STATICLIB_ANDROID
81 .append(func, fun_start_pos, fun_end_pos - fun_start_pos)
83 .append(file, filename_start_pos, file.length() - filename_start_pos)