24
25 #ifndef SHARE_UTILITIES_STRINGUTILS_HPP
26 #define SHARE_UTILITIES_STRINGUTILS_HPP
27
28 #include "memory/allStatic.hpp"
29
30 class StringUtils : AllStatic {
31 public:
32 // Replace the substring <from> with another string <to>. <to> must be
33 // no longer than <from>. The input string is modified in-place.
34 //
35 // Replacement is done in a single pass left-to-right. So replace_no_expand("aaa", "aa", "a")
36 // will result in "aa", not "a".
37 //
38 // Returns the count of substrings that have been replaced.
39 static int replace_no_expand(char* string, const char* from, const char* to);
40
41 // Compute string similarity based on Dice's coefficient
42 static double similarity(const char* str1, size_t len1, const char* str2, size_t len2);
43
44 // Find needle in haystack, case insensitive.
45 // Custom implementation of strcasestr, as it is not available on windows.
46 static const char* strstr_nocase(const char* haystack, const char* needle);
47
48 // Check if str matches the star_pattern.
49 // eg. str "_abc____def__" would match pattern "abc*def".
50 // The matching is case insensitive.
51 static bool is_star_match(const char* star_pattern, const char* str);
52 };
53
54 #endif // SHARE_UTILITIES_STRINGUTILS_HPP
|
24
25 #ifndef SHARE_UTILITIES_STRINGUTILS_HPP
26 #define SHARE_UTILITIES_STRINGUTILS_HPP
27
28 #include "memory/allStatic.hpp"
29
30 class StringUtils : AllStatic {
31 public:
32 // Replace the substring <from> with another string <to>. <to> must be
33 // no longer than <from>. The input string is modified in-place.
34 //
35 // Replacement is done in a single pass left-to-right. So replace_no_expand("aaa", "aa", "a")
36 // will result in "aa", not "a".
37 //
38 // Returns the count of substrings that have been replaced.
39 static int replace_no_expand(char* string, const char* from, const char* to);
40
41 // Compute string similarity based on Dice's coefficient
42 static double similarity(const char* str1, size_t len1, const char* str2, size_t len2);
43
44 // Match a wildcarded class list to a proposed class name (in internal form).
45 // Commas separate multiple possible matches; stars are shell-style wildcards.
46 static bool class_list_match(const char* class_list, const char* class_name);
47
48 // Find needle in haystack, case insensitive.
49 // Custom implementation of strcasestr, as it is not available on windows.
50 static const char* strstr_nocase(const char* haystack, const char* needle);
51
52 // Check if str matches the star_pattern.
53 // eg. str "_abc____def__" would match pattern "abc*def".
54 // The matching is case insensitive.
55 static bool is_star_match(const char* star_pattern, const char* str);
56 };
57
58 #endif // SHARE_UTILITIES_STRINGUTILS_HPP
|