Started developing conditions

This commit is contained in:
Dr. Patrick Urbanke
2025-05-01 08:56:29 +02:00
parent ebc80d616d
commit 2e63914ec7
3 changed files with 104 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
#ifndef SQLGEN_DYNAMIC_COLUMNORVALUE_HPP_
#define SQLGEN_DYNAMIC_COLUMNORVALUE_HPP_
#include <rfl.hpp>
#include "Column.hpp"
#include "Value.hpp"
namespace sqlgen::dynamic {
using ColumnOrValue = rfl::TaggedUnion<"type", Column, Value>;
} // namespace sqlgen::dynamic
#endif

View File

@@ -0,0 +1,64 @@
#ifndef SQLGEN_DYNAMIC_CONDITION_HPP_
#define SQLGEN_DYNAMIC_CONDITION_HPP_
#include <rfl.hpp>
#include "../Ref.hpp"
#include "Column.hpp"
#include "ColumnOrValue.hpp"
namespace sqlgen::dynamic {
struct Condition {
struct And {
Ref<Condition> op1;
Ref<Condition> op2;
};
struct Equals {
Column op1;
ColumnOrValue op2;
};
struct GreaterEqual {
Column op1;
ColumnOrValue op2;
};
struct GreaterThan {
Column op1;
ColumnOrValue op2;
};
struct NotEquals {
Column op1;
ColumnOrValue op2;
};
struct LesserEqual {
Column op1;
ColumnOrValue op2;
};
struct LesserThan {
Column op1;
ColumnOrValue op2;
};
struct Or {
Ref<Condition> op1;
Ref<Condition> op2;
};
using ReflectionType =
rfl::TaggedUnion<"what", And, Equals, GreaterEqual, GreaterThan,
NotEquals, LesserEqual, LesserThan, Or>;
ReflectionType reflection() const { return val; }
ReflectionType val;
};
} // namespace sqlgen::dynamic
#endif

View File

@@ -0,0 +1,25 @@
#ifndef SQLGEN_DYNAMIC_VALUE_HPP_
#define SQLGEN_DYNAMIC_VALUE_HPP_
#include <rfl.hpp>
#include <string>
namespace sqlgen::dynamic {
struct Float {
double val;
};
struct Integer {
int64_t val;
};
struct String {
std::string val;
};
using Value = rfl::TaggedUnion<"type", Float, Integer, String>;
} // namespace sqlgen::dynamic
#endif