Sql: S_ structures are now == != comparable

git-svn-id: svn://ultimatepp.org/upp/trunk@1726 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2009-11-29 15:13:10 +00:00
parent 24664f8e30
commit ed89fad462
3 changed files with 20 additions and 0 deletions

View file

@ -54,6 +54,8 @@ void td_array(SqlSet& set, const String& prefix, const char *x, int cnt);
void td_var(SqlSet& set, const String& prefix, const char *x, SqlSet (*f)(const String&));
void td_shrink(String *array, int cnt);
bool EqualFields(Fields a, Fields b);
// ----------
class SqlCase {

View file

@ -12,6 +12,8 @@ public:\
void FieldLayoutRaw(FieldOperator& f, const String& prefix = String()); \
void FieldLayout(FieldOperator& f); \
operator Fields() { return callback(this, &S_##Table::FieldLayout); } \
bool operator==(const S_##Table& x) const { return EqualFields(const_cast<S_##Table&>(*this), const_cast<S_##Table&>(x)); } \
bool operator!=(const S_##Table& x) const { return !EqualFields(const_cast<S_##Table&>(*this), const_cast<S_##Table&>(x)); } \
S_##Table();
#define TYPE(Table) CODETYPE(Table, __NIL)

View file

@ -24,4 +24,20 @@ void td_shrink(String *array, int cnt) {
}
}
struct NfEqual : FieldOperator {
ValueArray va;
virtual void Field(const char *name, Ref f) {
va.Add(f);
}
};
bool EqualFields(Fields a, Fields b)
{
NfEqual fa, fb;
a(fa);
b(fb);
return fa.table == fb.table && fa.va == fb.va;
}
END_UPP_NAMESPACE