24#ifndef ROUTER_SRC_ROUTING_GUIDELINES_SRC_UTILS_H_
25#define ROUTER_SRC_ROUTING_GUIDELINES_SRC_UTILS_H_
40std::string
str_strip(
const std::string &s,
41 const std::string &chars =
" \r\n\t");
43inline bool str_eq(std::string_view a, std::string_view b) {
49 return ::_stricmp(a, b) == 0;
51 return ::strcasecmp(a, b) == 0;
55inline bool str_caseeq(
const char *a,
const char *b,
size_t n) {
57 return ::_strnicmp(a, b,
n) == 0;
59 return ::strncasecmp(a, b,
n) == 0;
63inline bool str_caseeq(std::string_view lhs, std::string_view rhs) {
73 return ::_stricmp(a, b);
75 return ::strcasecmp(a, b);
79inline int str_casecmp(
const std::string &a,
const std::string &b) {
84 if (prefix.size() >
str.size())
return false;
86 for (
size_t i = 0; i < prefix.size(); ++i) {
97 return str.starts_with(prefix);
121template <
typename Container>
128bool is_ipv4(
const std::string &address);
129bool is_ipv6(
const std::string &address);
132std::string
network(
const std::string &address,
unsigned int bitlen);
141 const rapidjson::ParseResult &ok,
size_t chars);
static bool equal(const Item *i1, const Item *i2, const Field *f2)
Definition: sql_select.cc:3910
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1117
Definition: atomics_array.h:39
bool transform(const dd::Spatial_reference_system *source_srs, const Geometry &in, const dd::Spatial_reference_system *target_srs, const char *func_name, std::unique_ptr< Geometry > *out) noexcept
Transforms a geometry from one SRS to another.
Definition: transform.cc:216
char tolower(const char &ch)
Definition: parsing_helpers.h:41
Definition: my_rapidjson_size_t.h:38
Definition: routing_guidelines_datatypes.h:30
bool str_ibeginswith(std::string_view str, std::string_view prefix)
Definition: utils.h:83
bool json_document_complete(const std::string &s)
Is JSON document held by the string complete or not.
Definition: utils.cc:230
bool is_ipv6(const std::string &host)
Definition: utils.cc:192
std::string str_upper(std::string_view s)
Convert a copy of an ASCII string to uppercase and return.
Definition: utils.h:101
std::string like_to_regexp(std::string_view pattern)
Definition: utils.cc:115
bool str_caseeq(const char *a, const char *b)
Definition: utils.h:47
std::string str_strip(const std::string &s, const std::string &chars)
Definition: utils.cc:63
std::string mysql_unescape_string(std::string_view s)
process escapes in a string , keep synchronous with sql_load unescape ("ntrb0ZN")
Definition: utils.cc:82
int str_casecmp(const char *a, const char *b)
Compares 2 strings case insensitive (for ascii)
Definition: utils.h:71
bool case_contains(const Container &container, std::string_view str)
Check if container contains identincal string independent of case.
Definition: utils.h:122
bool is_ipv4(const std::string &address)
Definition: utils.cc:188
std::string format_json_error(const std::string &s, const rapidjson::ParseResult &ok, size_t chars)
Format JSON parse error adding responsible JSON part.
Definition: utils.cc:70
std::string str_lower(std::string_view s)
Convert a copy of an ASCII string to lowercase and return.
Definition: utils.h:108
bool str_beginswith(std::string_view str, std::string_view prefix)
Definition: utils.h:96
std::string network(const std::string &address, unsigned int bitlen)
Compute network part of an IPv4 address.
Definition: utils.cc:208
bool str_eq(std::string_view a, std::string_view b)
Definition: utils.h:43
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:86
int n
Definition: xcom_base.cc:509