osrm-backend/include/util/exception_utils.hpp

15 lines
635 B
C++

#ifndef SOURCE_MACROS_HPP
#define SOURCE_MACROS_HPP
#include <cstring>
// Helper macros, don't use these ones
// STRIP the OSRM_PROJECT_DIR from the front of a filename. Expected to come
// from CMake's CURRENT_SOURCE_DIR, which doesn't have a trailing /, hence the +1
#define _PROJECT_RELATIVE_PATH(x) std::string(x).substr(strlen(OSRM_PROJECT_DIR) + 1)
// Return the path of a file, relative to the OSRM_PROJECT_DIR
#define _OSRM_SOURCE_FILE _PROJECT_RELATIVE_PATH(__FILE__)
// This is the macro to use
#define SOURCE_REF std::string(" (at ") + _OSRM_SOURCE_FILE + ":" + std::to_string(__LINE__) + ")"
#endif // SOURCE_MACROS_HPP