Public Member Functions | Protected Types | Protected Attributes

APFilterList Class Reference

Collect a sequence of APFilter objects and apply them in turn when a value is found for an attribute/property. More...

#include <ie_exp_RTF_AttrProp.h>

List of all members.

Public Member Functions

const gchar * operator() (const gchar *szName, const gchar *szValue) const
void append (m_filter_t f)
void push_back (m_filter_t f)

Protected Types

typedef boost::function2
< std::string, const gchar
*, const std::string & > 
typedef std::list< m_filter_tm_filterlist_t

Protected Attributes

std::string m_cache
m_filterlist_t m_filterlist

Detailed Description

Collect a sequence of APFilter objects and apply them in turn when a value is found for an attribute/property.

Useful when you wish to mutate some of the values for either the attribute or properties but you do not wish to have to track the memory of your mutation. This class contains a single std::string cache so the caller can rely on the return value being sane until the next call to operator(); Many APFilter functors can be called on the same attr/prop and the result is: push_back(f1); push_back(f2); this->operator()( name, value ) == f2( name, f1(name, value ))

If there are no filter objects then the degenerate case is to just return the szValue given directly. Thus a APFilterList object without any filtering should not present a significant performance overhead. Since this is a template, the compiler has the option to inline the code and perpahs the empty() test on the filterlist also so that the cost becomes very very minimal.

Added by monkeyiq in June 2011 in order to delete part of the markup inside the revision attribute when a copy and paste is happening. Specifically, the markers as to if a paragraph is deleted need to be removed for pasted content as that content is considered fresh and content will have been coalesed.

Note that you can apply this filterlist to Attributes or Properties depending on where you source the pValue from.

Usage: APFilterList al; al.push_back( f2 ); ... somehow get szName and pValue from an AP return al( szName, pValue );

Where f2 is a filter like this: struct APFilterDropParaDeleteMarkers { std::string operator()( const gchar * szName, const std::string& value ) const { if( !strcmp( szName, "foo" )) return "bar"; return value; } };

Member Typedef Documentation

typedef boost::function2< std::string, const gchar *, const std::string& > APFilterList::m_filter_t [protected]
typedef std::list< m_filter_t > APFilterList::m_filterlist_t [protected]

Member Function Documentation

void APFilterList::append ( m_filter_t  f  )  [inline]

References m_filterlist.

Referenced by push_back().

const gchar* APFilterList::operator() ( const gchar *  szName,
const gchar *  szValue 
) const [inline]

References m_cache, and m_filterlist.

void APFilterList::push_back ( m_filter_t  f  )  [inline]

Member Data Documentation

std::string APFilterList::m_cache [mutable, protected]

Referenced by operator()().

Referenced by append(), and operator()().

The documentation for this class was generated from the following file: