started query builder
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
#ifndef QUERY_CONSTRAINTS_HPP
|
||||
#define QUERY_CONSTRAINTS_HPP
|
||||
|
||||
namespace matador::utils {
|
||||
|
||||
enum class constraints : unsigned char {
|
||||
NONE = 0,
|
||||
NOT_NULL = 1 << 0,
|
||||
INDEX = 1 << 1,
|
||||
UNIQUE = 1 << 2,
|
||||
PRIMARY_KEY = 1 << 3,
|
||||
FOREIGN_KEY = 1 << 4,
|
||||
DEFAULT = 1 << 5,
|
||||
UNIQUE_NOT_NULL = UNIQUE | NOT_NULL
|
||||
};
|
||||
|
||||
//static std::unordered_map<constraints, std::string> constraints_to_name_map();
|
||||
|
||||
inline constraints operator|(constraints a, constraints b)
|
||||
{
|
||||
return static_cast<constraints>(static_cast<unsigned int>(a) | static_cast<unsigned int>(b));
|
||||
}
|
||||
|
||||
inline constraints operator&(constraints a, constraints b)
|
||||
{
|
||||
return static_cast<constraints>(static_cast<unsigned int>(a) & static_cast<unsigned int>(b));
|
||||
}
|
||||
|
||||
inline bool is_constraint_set(constraints source, constraints needle)
|
||||
{
|
||||
return static_cast<int>(source & needle) > 0;
|
||||
}
|
||||
|
||||
}
|
||||
#endif //QUERY_CONSTRAINTS_HPP
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef QUERY_FIELD_ATTRIBUTES_HPP
|
||||
#define QUERY_FIELD_ATTRIBUTES_HPP
|
||||
|
||||
#include "constraints.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
namespace matador::utils {
|
||||
|
||||
class field_attributes
|
||||
{
|
||||
public:
|
||||
field_attributes() = default;
|
||||
field_attributes(size_t size); // NOLINT(*-explicit-constructor)
|
||||
field_attributes(constraints options); // NOLINT(*-explicit-constructor)
|
||||
field_attributes(size_t size, constraints options);
|
||||
field_attributes(const field_attributes &x) = default;
|
||||
field_attributes& operator=(const field_attributes &x) = default;
|
||||
field_attributes(field_attributes &&x) = default;
|
||||
field_attributes& operator=(field_attributes &&x) = default;
|
||||
~field_attributes() = default;
|
||||
|
||||
[[nodiscard]] size_t size() const;
|
||||
[[nodiscard]] constraints options() const;
|
||||
|
||||
private:
|
||||
size_t size_ = 0;
|
||||
constraints options_ = constraints::NONE;
|
||||
};
|
||||
|
||||
const field_attributes null_attributes {};
|
||||
|
||||
}
|
||||
#endif //QUERY_FIELD_ATTRIBUTES_HPP
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef QUERY_STRING_HPP
|
||||
#define QUERY_STRING_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace matador::utils {
|
||||
|
||||
/**
|
||||
* Replaces all occurrences of string from in given string
|
||||
* with string to.
|
||||
*
|
||||
* @param in Source string where the replacement takes place
|
||||
* @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);
|
||||
|
||||
}
|
||||
#endif //QUERY_STRING_HPP
|
||||
Reference in New Issue
Block a user