Common.h 1.1 KB

123456789101112131415161718192021222324252627282930
  1. // Copyright (C) 2009-2016, Panagiotis Christopoulos Charitos.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <string>
  7. /// Write to log. Don't use it directly.
  8. void log(const char* file, int line, unsigned type, const char* fmt, ...);
  9. // Log and errors
  10. #define LOGI(...) log(__FILE__, __LINE__, 1, __VA_ARGS__)
  11. #define ERROR(...) \
  12. do \
  13. { \
  14. log(__FILE__, __LINE__, 2, __VA_ARGS__); \
  15. exit(0); \
  16. } while(0)
  17. #define LOGW(...) log(__FILE__, __LINE__, 3, __VA_ARGS__)
  18. /// Replace all @a from substrings in @a str to @a to
  19. std::string replaceAllString(
  20. const std::string& str, const std::string& from, const std::string& to);
  21. /// From a path return only the filename
  22. std::string getFilename(const std::string& path);