r39543 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r39542‎ | r39543 | r39544 >
Date:18:18, 17 August 2008
Author:river
Status:old
Tags:
Comment:
add missing file
Modified paths:
  • /trunk/extensions/AbuseFilter/parser_native/filter_evaluator.cpp (added) (history)

Diff [purge]

Index: trunk/extensions/AbuseFilter/parser_native/filter_evaluator.cpp
@@ -0,0 +1,53 @@
 2+/*
 3+ * Copyright (c) 2008 Andrew Garrett.
 4+ * Copyright (c) 2008 River Tarnell <river@wikimedia.org>
 5+ * Derived from public domain code contributed by Victor Vasiliev.
 6+ *
 7+ * Permission is granted to anyone to use this software for any purpose,
 8+ * including commercial applications, and to alter it and redistribute it
 9+ * freely. This software is provided 'as-is', without any express or
 10+ * implied warranty.
 11+ */
 12+
 13+#include "filter_evaluator.h"
 14+
 15+namespace afp {
 16+
 17+filter_evaluator::filter_evaluator()
 18+{
 19+ e.add_function(make_astring<UChar32, char>("length"), af_length<UChar32>);
 20+ e.add_function(make_astring<UChar32, char>("lcase"), af_lcase<UChar32>);
 21+ e.add_function(make_astring<UChar32, char>("ccnorm"), af_ccnorm<UChar32>);
 22+ e.add_function(make_astring<UChar32, char>("rmdoubles"), af_rmdoubles<UChar32>);
 23+ e.add_function(make_astring<UChar32, char>("specialratio"), af_specialratio<UChar32>);
 24+ e.add_function(make_astring<UChar32, char>("rmspecials"), af_rmspecials<UChar32>);
 25+ e.add_function(make_astring<UChar32, char>("norm"), af_norm<UChar32>);
 26+ e.add_function(make_astring<UChar32, char>("count"), af_count<UChar32>);
 27+}
 28+
 29+void
 30+filter_evaluator::clear_variables()
 31+{
 32+ e.clear_variables();
 33+}
 34+
 35+bool
 36+filter_evaluator::evaluate(u32fray const &filter) const
 37+{
 38+ try {
 39+ return e.evaluate(filter).toBool();
 40+ } catch (std::exception &e) {
 41+ std::cerr << "can't evaluate filter: " << e.what() << '\n';
 42+ return false;
 43+ }
 44+}
 45+
 46+void
 47+filter_evaluator::add_variable(
 48+ u32fray const &key,
 49+ u32datum const &value)
 50+{
 51+ e.add_variable(key, value);
 52+}
 53+
 54+} // namespace afp

Status & tagging log