collection of C++ header library
- include/mie/string.hpp ; fast strstr, findStr and other functions with SSE4.2
Note: These codes requires Xbyak(https://github.com/herumi/xbyak) and "-fno-operator-names" option is required on gcc to avoid analyzing "and", "or", etc. as operators.
All funcionts are declared within a namespace mie. All functions may access max 16 bytes beyond end of text.
/*
fast strstr
*/
const char *strstr(const char *str, const char *key);
/*
strstr(case insensitive version)
@note key must not have capital characters [A-Z]
*/
const char *strcasestr(const char *str, const char *key);
/*
find key[0] or key[1], ... in str
@note strlen(key) <= 16, key[i] != 0
@note almost same as strbpk excluding restriction with key size
*/
const char *strchr_any(const char *str, const char *key);
/*
find c such that key[0] <= c && c <= key[1], key[2] <= c && c <= key[3], ... in str
@note strlen(key) <= 16, key[i] != 0
@note strchr_range(str, "az09") means to find string with a regular expression [a-z0-9] in str
*/
const char *strchr_range(const char *str, const char *key);
/*
find c in [begin, end)
if c is not found then return end
*/
const char *findChar(const char *begin, const char *end, char c);
/*
find any of key[0..keySize - 1] in [begin, end)
if char is not found then return end
@note keySize <= 16
*/
const char *findChar_any(const char *begin, const char *end, const char *key, size_t keySize);
/*
find character in range [key[0]..key[1]], [key[2]..key[3]], ... in [begin, end)
if char is not found then return end
@note keySize <= 16
*/
const char *findChar_range(const char *begin, const char *end, const char *key, size_t keySize);
/*
find [key, key + keySize) in [begin, end)
*/
const char *findStr(const char*begin, const char *end, const char *key, size_t keySize);
/*
case insensitive find [key, key + keySize) in [begin, end)
@note key must not have capital characters [A-Z]
*/
const char *findCaseStr(const char*begin, const char *end, const char *key, size_t keySize);
modified new BSD License (http://opensource.org/licenses/BSD-3-Clause)
MITSUNARI Shigeo
- mail:[email protected]
- twitter:@herumi
- facebook:https://www.facebook.com/mitsunari.shigeo