mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-04 21:40:03 +00:00
added not filter node
This commit is contained in:
parent
806e9a2888
commit
ba6edc55d4
@ -108,7 +108,7 @@ opencs_units_noqt (model/settings
|
|||||||
)
|
)
|
||||||
|
|
||||||
opencs_units_noqt (model/filter
|
opencs_units_noqt (model/filter
|
||||||
node unarynode narynode leafnode booleannode parser andnode ornode
|
node unarynode narynode leafnode booleannode parser andnode ornode notnode
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_hdrs_noqt (model/filter
|
opencs_hdrs_noqt (model/filter
|
||||||
|
10
apps/opencs/model/filter/notnode.cpp
Normal file
10
apps/opencs/model/filter/notnode.cpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
#include "notnode.hpp"
|
||||||
|
|
||||||
|
CSMFilter::NotNode::NotNode (boost::shared_ptr<Node> child) : UnaryNode (child, "not") {}
|
||||||
|
|
||||||
|
bool CSMFilter::NotNode::test (const CSMWorld::IdTable& table, int row,
|
||||||
|
const std::map<int, int>& columns) const
|
||||||
|
{
|
||||||
|
return !getChild().test (table, row, columns);
|
||||||
|
}
|
21
apps/opencs/model/filter/notnode.hpp
Normal file
21
apps/opencs/model/filter/notnode.hpp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef CSM_FILTER_NOTNODE_H
|
||||||
|
#define CSM_FILTER_NOTNODE_H
|
||||||
|
|
||||||
|
#include "unarynode.hpp"
|
||||||
|
|
||||||
|
namespace CSMFilter
|
||||||
|
{
|
||||||
|
class NotNode : public UnaryNode
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
NotNode (boost::shared_ptr<Node> child);
|
||||||
|
|
||||||
|
virtual bool test (const CSMWorld::IdTable& table, int row,
|
||||||
|
const std::map<int, int>& columns) const;
|
||||||
|
///< \return Can the specified table row pass through to filter?
|
||||||
|
/// \param columns column ID to column index mapping
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -10,6 +10,7 @@
|
|||||||
#include "booleannode.hpp"
|
#include "booleannode.hpp"
|
||||||
#include "ornode.hpp"
|
#include "ornode.hpp"
|
||||||
#include "andnode.hpp"
|
#include "andnode.hpp"
|
||||||
|
#include "notnode.hpp"
|
||||||
|
|
||||||
namespace CSMFilter
|
namespace CSMFilter
|
||||||
{
|
{
|
||||||
@ -209,7 +210,7 @@ CSMFilter::Token CSMFilter::Parser::getNextToken()
|
|||||||
return Token (Token::Type_None);
|
return Token (Token::Type_None);
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseImp()
|
boost::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseImp (bool allowEmpty)
|
||||||
{
|
{
|
||||||
if (Token token = getNextToken())
|
if (Token token = getNextToken())
|
||||||
{
|
{
|
||||||
@ -228,8 +229,21 @@ boost::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseImp()
|
|||||||
|
|
||||||
return parseNAry (token);
|
return parseNAry (token);
|
||||||
|
|
||||||
|
case Token::Type_Keyword_Not:
|
||||||
|
{
|
||||||
|
boost::shared_ptr<CSMFilter::Node> node = parseImp();
|
||||||
|
|
||||||
|
if (mError)
|
||||||
|
return boost::shared_ptr<Node>();
|
||||||
|
|
||||||
|
return boost::shared_ptr<CSMFilter::Node> (new NotNode (node));
|
||||||
|
}
|
||||||
|
|
||||||
case Token::Type_EOS:
|
case Token::Type_EOS:
|
||||||
|
|
||||||
|
if (!allowEmpty)
|
||||||
|
error();
|
||||||
|
|
||||||
return boost::shared_ptr<Node>();
|
return boost::shared_ptr<Node>();
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -260,12 +274,6 @@ boost::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseNAry (const Token& ke
|
|||||||
if (mError)
|
if (mError)
|
||||||
return boost::shared_ptr<Node>();
|
return boost::shared_ptr<Node>();
|
||||||
|
|
||||||
if (!node.get())
|
|
||||||
{
|
|
||||||
error();
|
|
||||||
return boost::shared_ptr<Node>();
|
|
||||||
}
|
|
||||||
|
|
||||||
nodes.push_back (node);
|
nodes.push_back (node);
|
||||||
|
|
||||||
Token token = getNextToken();
|
Token token = getNextToken();
|
||||||
@ -309,7 +317,7 @@ bool CSMFilter::Parser::parse (const std::string& filter)
|
|||||||
mInput = filter;
|
mInput = filter;
|
||||||
mIndex = 0;
|
mIndex = 0;
|
||||||
|
|
||||||
boost::shared_ptr<Node> node = parseImp();
|
boost::shared_ptr<Node> node = parseImp (true);
|
||||||
|
|
||||||
if (mError)
|
if (mError)
|
||||||
return false;
|
return false;
|
||||||
|
@ -25,7 +25,7 @@ namespace CSMFilter
|
|||||||
Token checkKeywords (const Token& token);
|
Token checkKeywords (const Token& token);
|
||||||
///< Turn string token into keyword token, if possible.
|
///< Turn string token into keyword token, if possible.
|
||||||
|
|
||||||
boost::shared_ptr<Node> parseImp();
|
boost::shared_ptr<Node> parseImp (bool allowEmpty = false);
|
||||||
///< Will return a null-pointer, if there is nothing more to parse.
|
///< Will return a null-pointer, if there is nothing more to parse.
|
||||||
|
|
||||||
boost::shared_ptr<Node> parseNAry (const Token& keyword);
|
boost::shared_ptr<Node> parseNAry (const Token& keyword);
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
|
|
||||||
#include "unarynode.hpp"
|
#include "unarynode.hpp"
|
||||||
|
|
||||||
CSMFilter::UnaryNode::UnaryNode (boost::shared_ptr<Node> child) : mChild (child) {}
|
CSMFilter::UnaryNode::UnaryNode (boost::shared_ptr<Node> child, const std::string& name)
|
||||||
|
: mChild (child), mName (name)
|
||||||
|
{}
|
||||||
|
|
||||||
const CSMFilter::Node& CSMFilter::UnaryNode::getChild() const
|
const CSMFilter::Node& CSMFilter::UnaryNode::getChild() const
|
||||||
{
|
{
|
||||||
@ -23,3 +25,7 @@ bool CSMFilter::UnaryNode::isSimple() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string CSMFilter::UnaryNode::toString (bool numericColumns) const
|
||||||
|
{
|
||||||
|
return mName + " " + mChild->toString (numericColumns);
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef CSM_FILTER_UNARIYNODE_H
|
#ifndef CSM_FILTER_UNARYNODE_H
|
||||||
#define CSM_FILTER_UNARIYNODE_H
|
#define CSM_FILTER_UNARYNODE_H
|
||||||
|
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
@ -10,10 +10,11 @@ namespace CSMFilter
|
|||||||
class UnaryNode : public Node
|
class UnaryNode : public Node
|
||||||
{
|
{
|
||||||
boost::shared_ptr<Node> mChild;
|
boost::shared_ptr<Node> mChild;
|
||||||
|
std::string mName;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
UnaryNode (boost::shared_ptr<Node> child);
|
UnaryNode (boost::shared_ptr<Node> child, const std::string& name);
|
||||||
|
|
||||||
const Node& getChild() const;
|
const Node& getChild() const;
|
||||||
|
|
||||||
@ -26,6 +27,10 @@ namespace CSMFilter
|
|||||||
virtual bool isSimple() const;
|
virtual bool isSimple() const;
|
||||||
///< \return Can this filter be displayed in simple mode.
|
///< \return Can this filter be displayed in simple mode.
|
||||||
|
|
||||||
|
virtual std::string toString (bool numericColumns) const;
|
||||||
|
///< Return a string that represents this node.
|
||||||
|
///
|
||||||
|
/// \param numericColumns Use numeric IDs instead of string to represent columns.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user