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.

36 lines
1.1KB

  1. #pragma once
  2. #include "common.hpp"
  3. namespace rack {
  4. namespace string {
  5. /** Converts a printf format string and optional arguments into a std::string */
  6. std::string f(const char *format, ...);
  7. /** Replaces all characters to lowercase letters */
  8. std::string lowercase(std::string s);
  9. /** Replaces all characters to uppercase letters */
  10. std::string uppercase(std::string s);
  11. /** Truncates and adds "..." to a string, not exceeding `len` characters */
  12. std::string ellipsize(std::string s, size_t len);
  13. bool startsWith(std::string str, std::string prefix);
  14. bool endsWith(std::string str, std::string suffix);
  15. /** Extracts portions of a path */
  16. std::string directory(std::string path);
  17. std::string filename(std::string path);
  18. /** Extracts the portion of a path without the extension */
  19. std::string basename(std::string path);
  20. /** Extracts the extension of a path */
  21. std::string extension(std::string path);
  22. struct CaseInsensitiveCompare {
  23. bool operator()(const std::string &a, const std::string &b) const {
  24. return lowercase(a) < lowercase(b);
  25. }
  26. };
  27. } // namespace string
  28. } // namespace rack