X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2Futils%2Fbamtools_filter_engine.h;h=9fb2f591fa3ee21c328989b23874563e6c96801d;hb=75af0fbc1c88cb67f2a91f79de53b0ec7a7211c3;hp=924b043119b7cd3b96e6826aa18371ca7cb5a28b;hpb=c66ba836246a1eada3557a5c8dcc9d3558ed093b;p=bamtools.git diff --git a/src/utils/bamtools_filter_engine.h b/src/utils/bamtools_filter_engine.h index 924b043..9fb2f59 100644 --- a/src/utils/bamtools_filter_engine.h +++ b/src/utils/bamtools_filter_engine.h @@ -1,9 +1,8 @@ // *************************************************************************** // 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 @@ -42,23 +41,24 @@ #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 #include #include #include #include #include -#include #include #include #include -#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 @@ -69,7 +69,7 @@ struct FilterCompareType { // FilterEngine template -class FilterEngine { +class UTILS_EXPORT FilterEngine { // ctor & dtor public: @@ -126,7 +126,7 @@ class FilterEngine { // token parsing (for property filter generation) public: template - 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: @@ -294,7 +294,6 @@ bool FilterEngine::evaluateFilterRules(const T& query) { std::stack resultStack; FilterMap::const_iterator filterIter; - FilterMap::const_iterator filterEnd = m_filters.end(); std::queue ruleQueueCopy = m_ruleQueue; while ( !ruleQueueCopy.empty() ) { const std::string& token = ruleQueueCopy.front(); @@ -325,7 +324,7 @@ bool FilterEngine::evaluateFilterRules(const T& query) { 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 ); @@ -377,10 +376,8 @@ bool FilterEngine::parseToken(const std::string& token, T& value, switch ( firstChar ) { case ( FilterEngine::NOT_CHAR ) : - strippedToken = token.substr(1); type = PropertyFilterValue::NOT; - break; case ( FilterEngine::GREATER_THAN_CHAR ) : @@ -435,7 +432,6 @@ bool FilterEngine::parseToken(const std::string& token, T& value, break; default : - // check for str* case (STARTS_WITH) if ( token.at( token.length() - 1 ) == FilterEngine::WILDCARD_CHAR ) { if ( token.length() == 2 ) return false; @@ -553,4 +549,4 @@ inline void FilterEngine::setRule(const std::string& ruleString) } // namespace BamTools -#endif // BAMTOOLS_FILTER_ENGINE_H \ No newline at end of file +#endif // BAMTOOLS_FILTER_ENGINE_H