Open Source Tomb Raider Engine
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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. /*!
  11. * \brief Check if a string ends with another string.
  12. * \param str string to check
  13. * \param suffix suffix for which to check
  14. * \returns true if str ends with suffix
  15. */
  16. bool stringEndsWith(const char *str, const char *suffix);
  17. /*!
  18. * \brief Generates a buffered string for the printf call
  19. * \param string Format string like for printf
  20. * \returns string in a buffer
  21. */
  22. char *bufferString(const char *string, ...) __attribute__((format(printf, 1, 2)));
  23. /*!
  24. * \brief Expansion of unix home enviroment char.
  25. * Also makes sure string ends in "end" char.
  26. * \param path path string
  27. * \param end end character. 0 appends no additional char
  28. * \returns allocated string of path with expansions
  29. */
  30. char *fullPath(const char *path, char end);
  31. /*!
  32. * \brief Checks if Command matches Symbol.
  33. * Returns the rest of the argument list back in command buffer, if any
  34. * \param symbol command string
  35. * \param command with arguments
  36. * \returns true if command matches symbol
  37. */
  38. bool rc_command(const char *symbol, char *command);
  39. /*!
  40. * \brief Interpret a string as a bool
  41. * \param buffer "true" or "false"
  42. * \param val is set to boolean interpretation of buffer
  43. * \returns -1 for null string, -2 if string is not "true" or "false"
  44. */
  45. int rc_get_bool(const char *buffer, bool *val);
  46. #endif