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.

86 lines
2.5 KiB

  1. /*
  2. Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
  3. Permission to use, copy, modify, and/or distribute this software for any
  4. purpose with or without fee is hereby granted, provided that the above
  5. copyright notice and this permission notice appear in all copies.
  6. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  7. WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  8. MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  9. ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  10. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  11. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  12. OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  13. */
  14. #pragma once
  15. #include <set>
  16. #include <string>
  17. #include <vector>
  18. namespace str
  19. {
  20. void
  21. split(const char *str,
  22. const char delimiter,
  23. std::vector<std::string> *result);
  24. void
  25. split(const std::string &str,
  26. const char delimiter,
  27. std::vector<std::string> *result);
  28. void
  29. rsplit1(const std::string &str,
  30. const char delimiter,
  31. std::vector<std::string> *result);
  32. void
  33. splitkv(const std::string &str,
  34. const char delimiter,
  35. std::string *key,
  36. std::string *value);
  37. std::string
  38. join(const std::vector<std::string> &vec,
  39. const size_t substridx,
  40. const char sep);
  41. std::string
  42. join(const std::vector<std::string> &vec,
  43. const char sep);
  44. std::string
  45. join(const std::set<std::string> &s,
  46. const char sep);
  47. size_t
  48. longest_common_prefix_index(const std::vector<std::string> &vec);
  49. std::string
  50. longest_common_prefix(const std::vector<std::string> &vec);
  51. std::string
  52. remove_common_prefix_and_join(const std::vector<std::string> &vec,
  53. const char sep);
  54. void
  55. erase_fnmatches(const std::vector<std::string> &pattern,
  56. std::vector<std::string> &strs);
  57. bool
  58. isprefix(const std::string &s0,
  59. const std::string &s1);
  60. bool
  61. startswith(const std::string &str_,
  62. const std::string &prefix_);
  63. bool
  64. endswith(const std::string &str_,
  65. const std::string &suffix_);
  66. std::string
  67. trim(const std::string &str);
  68. }