21 #ifndef XAPIAN_INCLUDED_STRINGUTILS_H 22 #define XAPIAN_INCLUDED_STRINGUTILS_H 33 #define STRINGIZE_(X) #X 36 #define STRINGIZE(X) STRINGIZE_(X) 43 #define CONST_STRLEN(S) (sizeof(S"") - 1) 48 return !s.empty() && s[0] == pfx;
52 startswith(
const std::string & s,
const char * pfx,
size_t len)
54 return s.size() >= len && (std::memcmp(s.data(), pfx, len) == 0);
64 startswith(
const std::string & s,
const std::string & pfx)
72 return !s.empty() && s[s.size() - 1] == sfx;
76 endswith(
const std::string & s,
const char * sfx,
size_t len)
78 return s.size() >= len && (std::memcmp(s.data() + s.size() - len, sfx, len) == 0);
82 endswith(
const std::string & s,
const char * sfx)
84 return endswith(s, sfx, std::strlen(sfx));
88 endswith(
const std::string & s,
const std::string & sfx)
90 return endswith(s, sfx.data(), sfx.size());
93 inline std::string::size_type
96 std::string::size_type minlen = std::min(a.size(), b.size());
97 std::string::size_type common;
98 for (common = 0; common < minlen; ++common) {
99 if (a[common] != b[common])
break;
123 static_assert(
'\x20' ==
' ',
"character set isn't a superset of ASCII");
131 return C_tab[
static_cast<unsigned char>(ch)];
204 #endif // XAPIAN_INCLUDED_STRINGUTILS_H The Xapian namespace contains public interfaces for the Xapian library.
bool endswith(const std::string &s, char sfx)
unsigned char C_tab_(char ch)
const unsigned char IS_DIGIT
const unsigned char IS_UPPER
const unsigned char IS_ALPHA
Mechanism for accessing a struct of constant information.
const struct constinfo * get_constinfo_()
bool C_isnotalpha(char ch)
bool startswith(const std::string &s, char pfx)
std::string::size_type common_prefix_length(const std::string &a, const std::string &b)
char hex_decode(char ch1, char ch2)
Decode a pair of ASCII hex digits.
bool C_isnotlower(char ch)
bool C_isnotdigit(char ch)
bool C_isnotxdigit(char ch)
bool C_isnotspace(char ch)
const unsigned char HEX_MASK
bool C_isnotupper(char ch)
bool C_isnotalnum(char ch)
const unsigned char IS_SPACE