initial matador ng commit

This commit is contained in:
2025-02-02 20:37:12 +01:00
parent 19de5714f4
commit ded3daceb3
378 changed files with 14913 additions and 13431 deletions
+65 -13
View File
@@ -1,13 +1,37 @@
#ifndef QUERY_STRING_HPP
#define QUERY_STRING_HPP
#ifndef STRING_HPP
#define STRING_HPP
#include "matador/utils/convert.hpp"
#include "matador/utils/export.hpp"
#include "matador/utils/types.hpp"
#include <list>
#include <string>
#include <vector>
namespace matador::utils {
/**
* Converts each byte of the given binary data
* into is hex string representation and return
* all bytes of blob as string.
*
* @param data Binary data to be converted
* @return Binary data as string
*/
MATADOR_UTILS_API std::string to_string(const blob &data);
/**
* Splits a string by a delimiter and
* add the string tokens to a vector. The
* size of the vector is returned.
*
* @param str The string to split.
* @param delim The delimiter character.
* @param values The result vector.
* @return The size of the vector.
*/
MATADOR_UTILS_API size_t split(const std::string &str, char delim, std::vector<std::string> &values);
/**
* Splits a string by a delimiter and
* add the string tokens to a vector. The
@@ -15,9 +39,32 @@ namespace matador::utils {
*
* @param str The string to split.
* @param delim The delimiter character.
* @return The the vector with split strings.
* @return The vector with split strings.
*/
std::vector<std::string> split(const std::string &str, char delim);
MATADOR_UTILS_API std::vector<std::string> split(const std::string &str, char delim);
/**
* Splits a string by a delimiter and
* add the string tokens to a list. The
* size of the list is returned.
*
* @param str The string to split.
* @param delim The delimiter character.
* @param values The result list.
* @return The size of the list.
*/
MATADOR_UTILS_API size_t split(const std::string &str, char delim, std::list<std::string> &values);
/**
* @fn std::string trim(const std::string& str, const std::string&)
* Trims a string by removing leading and trailing characters
* The default characters are spaces and tabs
*
* @param str The string to be trimmed
* @param whitespace The trimming characters
* @return the trimmed string
*/
MATADOR_UTILS_API std::string trim(const std::string& str, const std::string& whitespace = " \t");
/**
* Replaces all occurrences of string from in given string
@@ -27,23 +74,28 @@ std::vector<std::string> split(const std::string &str, char delim);
* @param from The string to be replaced
* @param to The new string
*/
void replace_all(std::string &in, const std::string &from, const std::string &to);
const std::string& to_string(const std::string &str);
std::string to_string(const blob &data);
MATADOR_UTILS_API void replace_all(std::string &in, const std::string &from, const std::string &to);
template <typename Type >
std::string to_string(const Type &value) {
const auto res = to<std::string>(value);
if (res.is_ok()) {
return *res;
}
return "";
}
/**
* Joins a range of elements as string within a list
* with a given delimiter and writes it to the
* given stream
*
* @tparam R Type og the range (e.g. map, list, vector, etc)
* @tparam Range Type og the range (e.g. map, list, vector, etc)
* @param range The range with the elements to join_left
* @param delim The delimiter for the elements
* @return The ostream reference
*/
template < class R >
std::string join(R &range, const std::string &delim)
template < class Range >
std::string join(const Range &range, const std::string &delim)
{
std::string result {};
if (range.size() < 2) {
@@ -61,4 +113,4 @@ std::string join(R &range, const std::string &delim)
}
}
#endif //QUERY_STRING_HPP
#endif //STRING_HPP