Open Source Tomb Raider Engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

strings.h 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*!
  2. * \file include/utils/strings.h
  3. * \brief String handling utilities
  4. *
  5. * \author xythobuz
  6. * \author Mongoose
  7. */
  8. #ifndef _UTILS_STRINGS_H_
  9. #define _UTILS_STRINGS_H_
  10. #include <cstdarg>
  11. char *stringRemoveQuotes(const char *s);
  12. char *stringReplace(const char *s, const char *search, const char *replace);
  13. int readBool(const char *value, bool *var);
  14. /*!
  15. * \brief Check if a string ends with another string.
  16. * \param str string to check
  17. * \param suffix suffix for which to check
  18. * \returns true if str ends with suffix
  19. */
  20. bool stringEndsWith(const char *str, const char *suffix);
  21. /*!
  22. * \brief Generates a buffered string for the printf call
  23. * \param string format string like for printf
  24. * \param args arguments matching format string
  25. * \returns string in a buffer
  26. */
  27. char *bufferString(const char *string, va_list args) __attribute__((format(printf, 1, 0)));
  28. /*!
  29. * \brief Generates a buffered string for the printf call
  30. * \param string format string like for printf
  31. * \returns string in a buffer
  32. */
  33. char *bufferString(const char *string, ...) __attribute__((format(printf, 1, 2)));
  34. /*!
  35. * \brief Expansion of unix home enviroment char.
  36. * Also makes sure string ends in "end" char.
  37. * \param path path string
  38. * \param end end character. 0 appends no additional char
  39. * \returns allocated string of path with expansions
  40. */
  41. char *fullPath(const char *path, char end);
  42. #endif