// ***************************************************************************
// bamtools_filter_engine.h (c) 2010 Derek Barnett, Erik Garrison
// Marth Lab, Department of Biology, Boston College
-// All rights reserved.
// ---------------------------------------------------------------------------
-// Last modified: 21 September 2010
+// Last modified: 3 May 2013
// ---------------------------------------------------------------------------
// Provides a generic filter engine based on filter-sets of properties,
// with possible "rules" (compound logical expressions) to create more complex
#ifndef BAMTOOLS_FILTER_ENGINE_H
#define BAMTOOLS_FILTER_ENGINE_H
+#include "utils/utils_global.h"
+#include "utils/bamtools_filter_properties.h"
+#include "utils/bamtools_filter_ruleparser.h"
+#include "utils/bamtools_utilities.h"
+
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
-#include <sstream>
#include <string>
#include <utility>
#include <vector>
-#include "bamtools_filter_properties.h"
-#include "bamtools_filter_ruleparser.h"
-#include "bamtools_utilities.h"
namespace BamTools {
-struct FilterCompareType {
+struct UTILS_EXPORT FilterCompareType {
enum Type { AND = 0
, NOT
, OR
// FilterEngine
template <typename FilterChecker>
-class FilterEngine {
+class UTILS_EXPORT FilterEngine {
// ctor & dtor
public:
// token parsing (for property filter generation)
public:
template<typename T>
- bool parseToken(const std::string& token, T& value, PropertyFilterValue::ValueCompareType& type);
+ static bool parseToken(const std::string& token, T& value, PropertyFilterValue::ValueCompareType& type);
// query evaluation
public:
std::stack<bool> resultStack;
FilterMap::const_iterator filterIter;
- FilterMap::const_iterator filterEnd = m_filters.end();
std::queue<std::string> ruleQueueCopy = m_ruleQueue;
while ( !ruleQueueCopy.empty() ) {
const std::string& token = ruleQueueCopy.front();
else {
// look up PropertyFilter that matches this token
filterIter = m_filters.find(token);
- BAMTOOLS_ASSERT_MESSAGE( (filterIter != filterEnd), "Filter mentioned in rule, not found in FilterEngine" );
+ BAMTOOLS_ASSERT_MESSAGE( (filterIter != m_filters.end() ), "Filter mentioned in rule, not found in FilterEngine" );
const PropertyFilter& filter = (*filterIter).second;
bool result = m_checker.check(filter, query);
resultStack.push( result );
switch ( firstChar ) {
case ( FilterEngine<FilterChecker>::NOT_CHAR ) :
-
strippedToken = token.substr(1);
type = PropertyFilterValue::NOT;
-
break;
case ( FilterEngine<FilterChecker>::GREATER_THAN_CHAR ) :
break;
default :
-
// check for str* case (STARTS_WITH)
if ( token.at( token.length() - 1 ) == FilterEngine<FilterChecker>::WILDCARD_CHAR ) {
if ( token.length() == 2 ) return false;
} // namespace BamTools
-#endif // BAMTOOLS_FILTER_ENGINE_H
\ No newline at end of file
+#endif // BAMTOOLS_FILTER_ENGINE_H