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>
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 & > | m_filter_t |
typedef std::list< m_filter_t > | m_filterlist_t |
Protected Attributes | |
std::string | m_cache |
m_filterlist_t | m_filterlist |
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; } };
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] |
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] |
References append().
Referenced by s_RTF_AttrPropAdapter_AP::s_RTF_AttrPropAdapter_AP().
std::string APFilterList::m_cache [mutable, protected] |
Referenced by operator()().
m_filterlist_t APFilterList::m_filterlist [protected] |
Referenced by append(), and operator()().