ModErn Text Analysis
META Enumerates Textual Applications
Public Types | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
meta::analyzers::filters::list_filter Class Reference

Filter that either removes or keeps tokens from a given list. More...

#include <list_filter.h>

Inheritance diagram for meta::analyzers::filters::list_filter:
meta::util::multilevel_clonable< Root, Base, Derived >

Public Types

enum  type { ACCEPT, REJECT }
 Strongly typed flag to indicate whether the list_filter rejects tokens in the list or only accepts tokens in the list.
 

Public Member Functions

 list_filter (std::unique_ptr< token_stream > source, const std::string &filename, type method=type::REJECT)
 Creates a list_filter reading tokens from the given source and filtering based on the tokens specified in the given file. More...
 
 list_filter (const list_filter &other)
 Copy constructor. More...
 
void set_content (const std::string &content) override
 Sets the content for the beginning of the filter chain. More...
 
std::string next () override
 
 operator bool () const override
 Determines whether there are more tokens available in the stream.
 
- Public Member Functions inherited from meta::util::multilevel_clonable< Root, Base, Derived >
virtual std::unique_ptr< Root > clone () const
 Clones the given object. More...
 

Static Public Attributes

static const std::string id = "list"
 Identifier for this filter.
 

Private Member Functions

void next_token ()
 Advances internal state to the next valid token.
 

Private Attributes

std::unique_ptr< token_streamsource_
 The source to read tokens from.
 
util::optional< std::string > token_
 The next buffered token.
 
std::unordered_set< std::string > list_
 The set of tokens used for filtering.
 
type method_
 Whether or not this filter accepts or rejects tokens in the list.
 

Detailed Description

Filter that either removes or keeps tokens from a given list.

Constructor & Destructor Documentation

meta::analyzers::filters::list_filter::list_filter ( std::unique_ptr< token_stream source,
const std::string &  filename,
type  method = type::REJECT 
)

Creates a list_filter reading tokens from the given source and filtering based on the tokens specified in the given file.

The method by default is to reject any tokens specified in the file, but it may be optionally set to type::ACCEPT to allow only tokens that appear in that list.

Parameters
sourceThe source to construct the filter from
filenameA file that lists tokens that should either be accepted or rejected
methodWhether to accept or reject tokens from the list
meta::analyzers::filters::list_filter::list_filter ( const list_filter other)

Copy constructor.

Parameters
otherThe list_filter to copy into this one

Member Function Documentation

void meta::analyzers::filters::list_filter::set_content ( const std::string &  content)
override

Sets the content for the beginning of the filter chain.

Parameters
contentThe string content to set
std::string meta::analyzers::filters::list_filter::next ( )
override
Returns
the next token in the sequence.

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