10#include "ers/FilterStream.h"
11#include "ers/InvalidReferenceIssue.h"
12#include "ers/StreamFactory.h"
13#include "ers/NotImplemented.h"
25 ers::Stream *create_stream(
const std::string &protocol,
const std::string &uri) {
47 return new FilterStream(target_stream,include_list,exclude_list);
58 std::string::size_type include_start = params.find(INCLUDE_TAG);
59 std::string::size_type exclude_start = params.find(EXCLUDE_TAG);
60 std::string::size_type target_start = params.find(TARGET_TAG);
61 std::string include_str = params.substr(include_start+1,exclude_start-1);
62 std::string exclude_str = params.substr(exclude_start+1,target_start-exclude_start-1);
63 std::string target_str = params.substr(target_start+1);
65 return factory(include_str,exclude_str,target_str);
93include_list,
const std::vector<std::string> & exclude_list) :
ers::
Stream() {
106 delete(m_target_stream_ptr) ;
118 if (! qualifiers.empty()) {
119 std::vector<std::string>::const_iterator e_pos ;
120 for(e_pos = m_exclude.begin();e_pos!=m_exclude.end();e_pos++) {
121 std::string::size_type conflict = qualifiers.find(*e_pos) ;
122 if (conflict!=std::string::npos) {
127 if (! m_include.empty()) {
128 std::vector<std::string>::const_iterator i_pos ;
129 for(i_pos = m_include.begin();i_pos!=m_include.end();i_pos++) {
130 std::string::size_type match = qualifiers.find(*i_pos) ;
131 if (match!=std::string::npos) {
150 if (is_accept(issue_ptr)) {
152 m_target_stream_ptr->send(issue_ptr);
163 stream << FILTER_STREAM_TAG <<
':' ;
164 std::vector<std::string>::const_iterator i_pos ;
165 stream << INCLUDE_TAG ;
166 for(i_pos = m_include.begin();i_pos!=m_include.end();i_pos++) {
167 if (i_pos!=m_include.begin()) {
168 stream << SEPARATORS ;
172 stream << EXCLUDE_TAG ;
173 std::vector<std::string>::const_iterator e_pos ;
174 for(e_pos = m_exclude.begin();e_pos!=m_exclude.end();e_pos++) {
175 if (e_pos!=m_exclude.begin()) {
176 stream << SEPARATORS ;
180 stream << TARGET_TAG ;
181 stream << *m_target_stream_ptr ;
efhlt::Interface * factory(void)
static std::vector< std::string > tokenize(const std::string &text, const std::string &separators)
static FilterStream * factory(const std::string &include_str, const ::std::string &exclude_str, const std::string &target_str)
factory method for partially parse information
std::vector< std::string > m_include
include list
static const char *const TARGET_TAG
tag used to mark the target stream
virtual void print_to(std::ostream &stream) const
static const char *const FILTER_STREAM_TAG
tag used to identity this stream
static const char *const EXCLUDE_TAG
tag used to mark the start of the exclude list
static const char *const SEPARATORS
separators between include and exclude qualifiers
Stream * m_target_stream_ptr
chained target stream
virtual void send(const Issue *issue_ptr)
send method
std::vector< std::string > m_exclude
exclude list
~FilterStream()
destructor
static const char *const INCLUDE_TAG
tag used to mark the start of the include list
virtual bool is_accept(const Issue *issue_ptr)
filter method
const std::string & get_value(const std::string &key, const std::string &def) const
Reads the property list.
static const char *const QUALIFIER_LIST_KEY
key used to store the qualifier list
Stream * create_stream(severity_t s)
create a stream for severity_t
bool register_factory(const std::string &name, create_stream_callback callback)
register a factory method
static StreamFactory * instance()
return the singleton