Commit 01dbe675 by maarten

a first select

git-svn-id: svn+ssh://gitlab/srv/svn-repos/pdb-redo/trunk@451 a1961a4f-ab94-4bcc-80e8-33b5a54de466
parent a825cfc6
...@@ -767,6 +767,21 @@ struct anyMatchesConditionImpl : public ConditionImpl ...@@ -767,6 +767,21 @@ struct anyMatchesConditionImpl : public ConditionImpl
std::regex mRx; std::regex mRx;
}; };
struct allConditionImpl : public ConditionImpl
{
allConditionImpl() {}
virtual bool test(const Category& c, const Row& r) const
{
return true;
}
virtual std::string str() const
{
return "ALL";
}
};
struct andConditionImpl : public ConditionImpl struct andConditionImpl : public ConditionImpl
{ {
andConditionImpl(Condition&& a, Condition&& b) andConditionImpl(Condition&& a, Condition&& b)
...@@ -837,6 +852,37 @@ struct orConditionImpl : public ConditionImpl ...@@ -837,6 +852,37 @@ struct orConditionImpl : public ConditionImpl
ConditionImpl* mB; ConditionImpl* mB;
}; };
struct notConditionImpl : public ConditionImpl
{
notConditionImpl(Condition&& a)
: mA(nullptr)
{
std::swap(mA, a.mImpl);
}
~notConditionImpl()
{
delete mA;
}
virtual void prepare(const Category& c)
{
mA->prepare(c);
}
virtual bool test(const Category& c, const Row& r) const
{
return not mA->test(c, r);
}
virtual std::string str() const
{
return "NOT (" + mA->str() + ")";
}
ConditionImpl* mA;
};
} }
inline Condition operator&&(Condition&& a, Condition&& b) inline Condition operator&&(Condition&& a, Condition&& b)
...@@ -961,6 +1007,16 @@ Condition any::operator==(const std::regex& rx) const ...@@ -961,6 +1007,16 @@ Condition any::operator==(const std::regex& rx) const
return Condition(new detail::anyMatchesConditionImpl(rx)); return Condition(new detail::anyMatchesConditionImpl(rx));
} }
inline Condition All()
{
return Condition(new detail::allConditionImpl());
}
inline Condition Not(Condition&& cond)
{
return Condition(new detail::notConditionImpl(std::move(cond)));
}
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// class RowSet is used to return find results. Use it to re-order the results // class RowSet is used to return find results. Use it to re-order the results
// or to group them // or to group them
...@@ -1113,6 +1169,7 @@ class Category ...@@ -1113,6 +1169,7 @@ class Category
// return index for known column, or the next available column index // return index for known column, or the next available column index
size_t getColumnIndex(const string& name) const; size_t getColumnIndex(const string& name) const;
bool hasColumn(const string& name) const;
const string& getColumnName(size_t columnIndex) const; const string& getColumnName(size_t columnIndex) const;
vector<string> getColumnNames() const; vector<string> getColumnNames() const;
......
...@@ -1175,6 +1175,11 @@ void Category::setValidator(Validator* v) ...@@ -1175,6 +1175,11 @@ void Category::setValidator(Validator* v)
mCatValidator = nullptr; mCatValidator = nullptr;
} }
bool Category::hasColumn(const string& name) const
{
return getColumnIndex(name) < mColumns.size();
}
size_t Category::getColumnIndex(const string& name) const size_t Category::getColumnIndex(const string& name) const
{ {
size_t result; size_t result;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment