📄 ncbistr.hpp
字号:
/// Case-sensitive equality of two strings -- string& version. /// /// @param s1 /// String to be compared -- operand 1. /// @param s2 /// String to be compared -- operand 2. /// @return /// - true, if s1 equals s2 /// - false, otherwise /// @sa /// EqualCase(), Equal() versions with same argument types. static bool EqualCase(const string& s1, const string& s2); /// Case-insensitive equality of a substring with a pattern. /// /// @param str /// String containing the substring to be compared. /// @param pos /// Start position of substring to be compared. /// @param n /// Number of characters in substring to be compared. /// @param pattern /// String pattern (char*) to be compared with substring. /// @return /// - true, if str[pos:pos+n) equals pattern (case-insensitive compare). /// - false, otherwise. /// @sa /// Other forms of overloaded EqualNocase() with differences in /// argument types: char* vs. string& static bool EqualNocase(const string& str, SIZE_TYPE pos, SIZE_TYPE n, const char* pattern); /// Case-insensitive equality of a substring with a pattern. /// /// @param str /// String containing the substring to be compared. /// @param pos /// Start position of substring to be compared. /// @param n /// Number of characters in substring to be compared. /// @param pattern /// String pattern (string&) to be compared with substring. /// @return /// - true, if str[pos:pos+n) equals pattern (case-insensitive compare). /// - false, otherwise. /// @sa /// Other forms of overloaded EqualNocase() with differences in /// argument types: char* vs. string& static bool EqualNocase(const string& str, SIZE_TYPE pos, SIZE_TYPE n, const string& pattern); /// Case-insensitive equality of two strings -- char* version. /// /// @param s1 /// String to be compared -- operand 1. /// @param s2 /// String to be compared -- operand 2. /// @return /// - true, if s1 equals s2 (case-insensitive compare). /// - false, otherwise. /// @sa /// EqualCase(), Equal() versions with same argument types. static bool EqualNocase(const char* s1, const char* s2); /// Case-insensitive equality of two strings -- string& version. /// /// @param s1 /// String to be compared -- operand 1. /// @param s2 /// String to be compared -- operand 2. /// @return /// - true, if s1 equals s2 (case-insensitive compare). /// - false, otherwise. /// @sa /// EqualCase(), Equal() versions with same argument types. static bool EqualNocase(const string& s1, const string& s2); /// Test for equality of a substring with a pattern. /// /// @param str /// String containing the substring to be compared. /// @param pos /// Start position of substring to be compared. /// @param n /// Number of characters in substring to be compared. /// @param pattern /// String pattern (char*) to be compared with substring. /// @param use_case /// Whether to do a case sensitive compare(eCase -- default), or a /// case-insensitive compare (eNocase). /// @return /// - true, if str[pos:pos+n) equals pattern. /// - false, otherwise. /// @sa /// Other forms of overloaded Equal() with differences in argument /// types: char* vs. string& static bool Equal(const string& str, SIZE_TYPE pos, SIZE_TYPE n, const char* pattern, ECase use_case = eCase); /// Test for equality of a substring with a pattern. /// /// @param str /// String containing the substring to be compared. /// @param pos /// Start position of substring to be compared. /// @param n /// Number of characters in substring to be compared. /// @param pattern /// String pattern (string&) to be compared with substring. /// @param use_case /// Whether to do a case sensitive compare(default is eCase), or a /// case-insensitive compare (eNocase). /// @return /// - 0, if str[pos:pos+n) == pattern. /// - Negative integer, if str[pos:pos+n) < pattern. /// - Positive integer, if str[pos:pos+n) > pattern. /// @sa /// Other forms of overloaded Equal() with differences in argument /// types: char* vs. string& static bool Equal(const string& str, SIZE_TYPE pos, SIZE_TYPE n, const string& pattern, ECase use_case = eCase); /// Test for equality of two strings -- char* version. /// /// @param s1 /// String to be compared -- operand 1. /// @param s2 /// String to be compared -- operand 2. /// @param use_case /// Whether to do a case sensitive compare(default is eCase), or a /// case-insensitive compare (eNocase). /// @return /// - 0, if s1 == s2. /// - Negative integer, if s1 < s2. /// - Positive integer, if s1 > s2. /// @sa /// EqualNocase(), Equal() versions with similar argument types. static bool Equal(const char* s1, const char* s2, ECase use_case = eCase); /// Test for equality of two strings -- string&, char* version. /// /// @param s1 /// String to be compared -- operand 1. /// @param s2 /// String to be compared -- operand 2. /// @param use_case /// Whether to do a case sensitive compare(default is eCase), or a /// case-insensitive compare (eNocase). /// @return /// - true, if s1 equals s2. /// - false, otherwise. /// @sa /// EqualNocase(), Equal() versions with similar argument types. static bool Equal(const string& s1, const char* s2, ECase use_case = eCase); /// Test for equality of two strings -- char*, string& version. /// /// @param s1 /// String to be compared -- operand 1. /// @param s2 /// String to be compared -- operand 2. /// @param use_case /// Whether to do a case sensitive compare(default is eCase), or a /// case-insensitive compare (eNocase). /// @return /// - true, if s1 equals s2. /// - false, otherwise. /// @sa /// EqualNocase(), Equal() versions with similar argument types. static bool Equal(const char* s1, const string& s2, ECase use_case = eCase); /// Test for equality of two strings -- string& version. /// /// @param s1 /// String to be compared -- operand 1. /// @param s2 /// String to be compared -- operand 2. /// @param use_case /// Whether to do a case sensitive compare(default is eCase), or a /// case-insensitive compare (eNocase). /// @return /// - true, if s1 equals s2. /// - false, otherwise. /// @sa /// EqualNocase(), Equal() versions with similar argument types. static bool Equal(const string& s1, const string& s2, ECase use_case = eCase); // NOTE. On some platforms, "strn[case]cmp()" can work faster than their // "Compare***()" counterparts. /// String compare. /// /// @param s1 /// String to be compared -- operand 1. /// @param s2 /// String to be compared -- operand 2. /// @return /// - 0, if s1 == s2. /// - Negative integer, if s1 < s2. /// - Positive integer, if s1 > s2. /// @sa /// strncmp(), strcasecmp(), strncasecmp() static int strcmp(const char* s1, const char* s2); /// String compare upto specified number of characters. /// /// @param s1 /// String to be compared -- operand 1. /// @param s2 /// String to be compared -- operand 2. /// @param n /// Number of characters in string /// @return /// - 0, if s1 == s2. /// - Negative integer, if s1 < s2. /// - Positive integer, if s1 > s2. /// @sa /// strcmp(), strcasecmp(), strncasecmp() static int strncmp(const char* s1, const char* s2, size_t n); /// Case-insensitive string compare. /// /// @param s1 /// String to be compared -- operand 1. /// @param s2 /// String to be compared -- operand 2. /// @return /// - 0, if s1 == s2. /// - Negative integer, if s1 < s2. /// - Positive integer, if s1 > s2. /// @sa /// strcmp(), strncmp(), strncasecmp() static int strcasecmp(const char* s1, const char* s2); /// Case-insensitive string compare upto specfied number of characters. /// /// @param s1 /// String to be compared -- operand 1. /// @param s2 /// String to be compared -- operand 2. /// @return /// - 0, if s1 == s2. /// - Negative integer, if s1 < s2. /// - Positive integer, if s1 > s2. /// @sa /// strcmp(), strcasecmp(), strcasecmp() static int strncasecmp(const char* s1, const char* s2, size_t n); /// Wrapper for the function strftime() that corrects handling %D and %T /// time formats on MS Windows. static size_t strftime (char* s, size_t maxsize, const char* format, const struct tm* timeptr); /// Match "str" against the "mask". /// /// This function do not use regular expressions. /// @param str /// String to match. /// @param mask /// Mask used to match string "str". And can contains next /// wildcard characters: /// ? - matches to any one symbol in the string. /// * - matches to any number of symbols in the string. /// @return /// Return TRUE if "str" matches "mask", and FALSE otherwise. /// @sa /// CRegexp, CRegexpUtil static bool MatchesMask(const char *str, const char *mask); // The following 4 methods change the passed string, then return it /// Convert string to lower case -- string& version. /// /// @param str /// String to be converted. /// @return /// Lower cased string. static string& ToLower(string& str); /// Convert string to lower case -- char* version. /// /// @param str /// String to be converted. /// @return /// Lower cased string. static char* ToLower(char* str); /// Convert string to upper case -- string& version. /// /// @param str /// String to be converted. /// @return /// Upper cased string. static string& ToUpper(string& str); /// Convert string to upper case -- char* version. /// /// @param str /// String to be converted. /// @return /// Upper cased string. static char* ToUpper(char* str);private: /// Privatized ToLower() with const char* parameter to prevent passing of /// constant strings. static void/*dummy*/ ToLower(const char* /*dummy*/); /// Privatized ToUpper() with const char* parameter to prevent passing of /// constant strings. static void/*dummy*/ ToUpper(const char* /*dummy*/);public: /// Check if a string starts with a specified prefix value. /// /// @param str /// String to check. /// @param start /// Prefix value to check for. /// @param use_case /// Whether to do a case sensitive compare(default is eCase), or a /// case-insensitive compare (eNocase) while checking. static bool StartsWith(const string& str, const string& start, ECase use_case = eCase); /// Check if a string ends with a specified suffix value. /// /// @param str /// String to check. /// @param end /// Suffix value to check for. /// @param use_case /// Whether to do a case sensitive compare(default is eCase), or a /// case-insensitive compare (eNocase) while checking. static bool EndsWith(const string& str, const string& end, ECase use_case = eCase); /// Whether it is the first or last occurrence. enum EOccurrence { eFirst, ///< First occurrence eLast ///< Last occurrence }; /// Find the pattern in the specfied range of a string. /// /// @param str /// String to search. /// @param pattern /// Pattern to search for in "str". /// @param start /// Position in "str" to start search from -- default of 0 means start /// the search from the beginning of the string. /// @param end /// Position in "str" to start search up to -- default of NPOS means /// to search to the end of the string. /// @param which /// When set to eFirst, this means to find the first occurrence of /// "pattern" in "str". When set to eLast, this means to find the last
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -