xapian-core  1.4.26
Namespaces | Macros | Functions | Variables
stringutils.h File Reference

Various handy helpers which std::string really should provide. More...

#include <xapian/constinfo.h>
#include <algorithm>
#include <string>
#include <cstring>
+ Include dependency graph for stringutils.h:

Go to the source code of this file.

Namespaces

 Xapian
 The Xapian namespace contains public interfaces for the Xapian library.
 
 Xapian::Internal
 

Macros

#define STRINGIZE_(X)   #X
 Helper macro for STRINGIZE - the nested call is required because of how

works in macros.

More...
 
#define STRINGIZE(X)   STRINGIZE_(X)
 The STRINGIZE macro converts its parameter into a string constant. More...
 
#define CONST_STRLEN(S)   (sizeof(S"") - 1)
 Returns the length of a string constant. More...
 

Functions

bool startswith (const std::string &s, char pfx)
 
bool startswith (const std::string &s, const char *pfx, size_t len)
 
bool startswith (const std::string &s, const char *pfx)
 
bool startswith (const std::string &s, const std::string &pfx)
 
bool endswith (const std::string &s, char sfx)
 
bool endswith (const std::string &s, const char *sfx, size_t len)
 
bool endswith (const std::string &s, const char *sfx)
 
bool endswith (const std::string &s, const std::string &sfx)
 
bool contains (const std::string &s, char substring)
 
bool contains (const std::string &s, const char *substring, size_t len)
 
bool contains (const std::string &s, const char *substring)
 
bool contains (const std::string &s, const std::string &substring)
 
std::string::size_type common_prefix_length (const std::string &a, const std::string &b)
 
std::string::size_type common_prefix_length (const std::string &a, const std::string &b, std::string::size_type max_prefix_len)
 
unsigned char C_tab_ (char ch)
 
bool C_isdigit (char ch)
 
bool C_isxdigit (char ch)
 
bool C_isupper (char ch)
 
bool C_islower (char ch)
 
bool C_isalpha (char ch)
 
bool C_isalnum (char ch)
 
bool C_isspace (char ch)
 
bool C_isnotdigit (char ch)
 
bool C_isnotxdigit (char ch)
 
bool C_isnotupper (char ch)
 
bool C_isnotlower (char ch)
 
bool C_isnotalpha (char ch)
 
bool C_isnotalnum (char ch)
 
bool C_isnotspace (char ch)
 
char C_tolower (char ch)
 
char C_toupper (char ch)
 
int hex_digit (char ch)
 
char hex_decode (char ch1, char ch2)
 Decode a pair of ASCII hex digits. More...
 

Variables

const unsigned char Xapian::Internal::HEX_MASK = 0x0f
 
const unsigned char Xapian::Internal::IS_UPPER = 0x10
 
const unsigned char Xapian::Internal::IS_ALPHA = 0x20
 
const unsigned char Xapian::Internal::IS_DIGIT = 0x40
 
const unsigned char Xapian::Internal::IS_SPACE = 0x80
 

Detailed Description

Various handy helpers which std::string really should provide.

Definition in file stringutils.h.

Macro Definition Documentation

◆ CONST_STRLEN

#define CONST_STRLEN (   S)    (sizeof(S"") - 1)

Returns the length of a string constant.

We rely on concatenation of string literals to produce an error if this macro is applied to something other than a string literal.

Definition at line 43 of file stringutils.h.

Referenced by ChertDatabaseReplicator::apply_changeset_from_conn(), GlassDatabaseReplicator::apply_changeset_from_conn(), FDTracker::check(), GlassChanges::check(), GlassDatabase::get_changeset_revisions(), ChertDatabase::get_changeset_revisions(), main(), GlassDatabaseReplicator::process_changeset_chunk_blocks(), test_weight_class(), and test_weight_class_no_params().

◆ STRINGIZE

#define STRINGIZE (   X)    STRINGIZE_(X)

◆ STRINGIZE_

#define STRINGIZE_ (   X)    #X

Helper macro for STRINGIZE - the nested call is required because of how

works in macros.

Definition at line 33 of file stringutils.h.

Function Documentation

◆ C_isalnum()

bool C_isalnum ( char  ch)
inline

◆ C_isalpha()

bool C_isalpha ( char  ch)
inline

Definition at line 198 of file stringutils.h.

References C_tab_(), and Xapian::Internal::IS_ALPHA.

Referenced by C_isnotalpha(), and test_chartype1().

◆ C_isdigit()

bool C_isdigit ( char  ch)
inline

Definition at line 177 of file stringutils.h.

References C_tab_(), and Xapian::Internal::IS_DIGIT.

Referenced by C_isnotdigit(), and test_chartype1().

◆ C_islower()

bool C_islower ( char  ch)
inline

Definition at line 193 of file stringutils.h.

References C_tab_(), Xapian::Internal::IS_ALPHA, and Xapian::Internal::IS_UPPER.

Referenced by C_isnotlower(), and test_chartype1().

◆ C_isnotalnum()

bool C_isnotalnum ( char  ch)
inline

Definition at line 218 of file stringutils.h.

References C_isalnum().

Referenced by test_chartype1().

◆ C_isnotalpha()

bool C_isnotalpha ( char  ch)
inline

Definition at line 217 of file stringutils.h.

References C_isalpha().

Referenced by test_chartype1().

◆ C_isnotdigit()

bool C_isnotdigit ( char  ch)
inline

Definition at line 213 of file stringutils.h.

References C_isdigit().

Referenced by test_chartype1().

◆ C_isnotlower()

bool C_isnotlower ( char  ch)
inline

Definition at line 216 of file stringutils.h.

References C_islower().

Referenced by test_chartype1().

◆ C_isnotspace()

bool C_isnotspace ( char  ch)
inline

Definition at line 219 of file stringutils.h.

References C_isspace().

Referenced by get_paragraph(), FileIndexer::index_to(), make_tg_db(), and test_chartype1().

◆ C_isnotupper()

bool C_isnotupper ( char  ch)
inline

Definition at line 215 of file stringutils.h.

References C_isupper().

Referenced by test_chartype1().

◆ C_isnotxdigit()

bool C_isnotxdigit ( char  ch)
inline

Definition at line 214 of file stringutils.h.

References C_isxdigit().

Referenced by test_chartype1().

◆ C_isspace()

bool C_isspace ( char  ch)
inline

◆ C_isupper()

bool C_isupper ( char  ch)
inline

Definition at line 188 of file stringutils.h.

References C_tab_(), and Xapian::Internal::IS_UPPER.

Referenced by C_isnotupper(), and test_chartype1().

◆ C_isxdigit()

bool C_isxdigit ( char  ch)
inline

◆ C_tab_()

unsigned char C_tab_ ( char  ch)
inline

◆ C_tolower()

char C_tolower ( char  ch)
inline

Definition at line 221 of file stringutils.h.

References C_tab_(), and Xapian::Internal::IS_ALPHA.

Referenced by check_db_table(), munge_term(), and HostFieldProcessor::operator()().

◆ C_toupper()

char C_toupper ( char  ch)
inline

Definition at line 226 of file stringutils.h.

References C_tab_(), and Xapian::Internal::IS_ALPHA.

Referenced by Xapian::QueryParser::Internal::parse_query().

◆ common_prefix_length() [1/2]

std::string::size_type common_prefix_length ( const std::string &  a,
const std::string &  b 
)
inline

◆ common_prefix_length() [2/2]

std::string::size_type common_prefix_length ( const std::string &  a,
const std::string &  b,
std::string::size_type  max_prefix_len 
)
inline

Definition at line 134 of file stringutils.h.

◆ contains() [1/4]

bool contains ( const std::string &  s,
char  substring 
)
inline

Definition at line 99 of file stringutils.h.

Referenced by DEFINE_TESTCASE(), and Xapian::RSet::remove_document().

◆ contains() [2/4]

bool contains ( const std::string &  s,
const char *  substring,
size_t  len 
)
inline

Definition at line 105 of file stringutils.h.

◆ contains() [3/4]

bool contains ( const std::string &  s,
const char *  substring 
)
inline

Definition at line 111 of file stringutils.h.

◆ contains() [4/4]

bool contains ( const std::string &  s,
const std::string &  substring 
)
inline

Definition at line 117 of file stringutils.h.

◆ endswith() [1/4]

bool endswith ( const std::string &  s,
char  sfx 
)
inline

◆ endswith() [2/4]

bool endswith ( const std::string &  s,
const char *  sfx,
size_t  len 
)
inline

Definition at line 81 of file stringutils.h.

◆ endswith() [3/4]

bool endswith ( const std::string &  s,
const char *  sfx 
)
inline

Definition at line 87 of file stringutils.h.

References endswith().

◆ endswith() [4/4]

bool endswith ( const std::string &  s,
const std::string &  sfx 
)
inline

Definition at line 93 of file stringutils.h.

References endswith().

◆ hex_decode()

char hex_decode ( char  ch1,
char  ch2 
)
inline

Decode a pair of ASCII hex digits.

E.g. hex_decode('4', 'A') gives 'J'.

If C_isxdigit(ch1) isn't true then ch1 is treated as '0', and similarly for ch2.

Definition at line 243 of file stringutils.h.

References hex_digit().

Referenced by munge_term(), Uuid::parse(), test_chartype1(), and unescape().

◆ hex_digit()

int hex_digit ( char  ch)
inline

Definition at line 231 of file stringutils.h.

References C_tab_(), and Xapian::Internal::HEX_MASK.

Referenced by hex_decode(), and test_chartype1().

◆ startswith() [1/4]

bool startswith ( const std::string &  s,
char  pfx 
)
inline

◆ startswith() [2/4]

bool startswith ( const std::string &  s,
const char *  pfx,
size_t  len 
)
inline

Definition at line 57 of file stringutils.h.

◆ startswith() [3/4]

bool startswith ( const std::string &  s,
const char *  pfx 
)
inline

Definition at line 63 of file stringutils.h.

References startswith().

◆ startswith() [4/4]

bool startswith ( const std::string &  s,
const std::string &  pfx 
)
inline

Definition at line 69 of file stringutils.h.

References startswith().