crawlserv++  [under development]
Application for crawling and analyzing textual content of websites.
crawlservpp::Wrapper::AspellChecker Class Reference

RAII wrapper for aspell spell checkers. More...

#include <AspellChecker.hpp>

Classes

class  Exception
 Class for aspell spell checker-specific exceptions. More...
 

Construction and Destruction

 AspellChecker ()=default
 Default constructor. More...
 
virtual ~AspellChecker ()
 Destructor deleting the spell checker, if necessary. More...
 

Getters

AspellSpeller * get ()
 Gets a pointer to the underlying spell checker. More...
 
const AspellSpeller * getc () const
 Gets a constant pointer to the underlying spell checker. More...
 
bool valid () const
 Gets whether the spell checker is valid. More...
 

Creation

void create (AspellConfig &configuration)
 Creates the spell checker. More...
 

Spell Check

bool check (const std::string &token, std::vector< std::string > &suggestionsTo)
 Checks whether a token is correctly spelled. More...
 

Cleanup

void clear ()
 Deletes the spell checker, if necessary. More...
 

Copy and Move

The class is not copyable, only moveable.

 AspellChecker (AspellChecker &)=delete
 Deleted copy constructor. More...
 
AspellCheckeroperator= (AspellChecker &)=delete
 Deleted copy assignment operator. More...
 
 AspellChecker (AspellChecker &&other) noexcept
 Move constructor. More...
 
AspellCheckeroperator= (AspellChecker &&other) noexcept
 Move assignment operator. More...
 

Detailed Description

RAII wrapper for aspell spell checkers.

Creates the spell checker on construction and deletes it on destruction, if still necessary, avoiding memory leaks.

Note
The class does not own the underlying pointer, but takes care of its deletion via API call.

Constructor & Destructor Documentation

◆ AspellChecker() [1/3]

crawlservpp::Wrapper::AspellChecker::AspellChecker ( )
default

Default constructor.

◆ ~AspellChecker()

crawlservpp::Wrapper::AspellChecker::~AspellChecker ( )
inlinevirtual

Destructor deleting the spell checker, if necessary.

See also
clear

References clear().

◆ AspellChecker() [2/3]

crawlservpp::Wrapper::AspellChecker::AspellChecker ( AspellChecker )
delete

Deleted copy constructor.

◆ AspellChecker() [3/3]

crawlservpp::Wrapper::AspellChecker::AspellChecker ( AspellChecker &&  other)
inlinenoexcept

Move constructor.

Moves the spell checker from the specified location into this instance of the class.

Note
The other spell checker will be invalidated by this move.
Parameters
otherThe spell checker to move from.
See also
valid

Member Function Documentation

◆ check()

bool crawlservpp::Wrapper::AspellChecker::check ( const std::string &  token,
std::vector< std::string > &  suggestionsTo 
)
inline

Checks whether a token is correctly spelled.

Parameters
tokenConstant reference to a string containing the token to be checked.
suggestionsToReference to a vector to which correction suggestions for the token will be appended, if the token is not correctly spelled, according to aspell.
Returns
True, if the token is correctly spellec according to aspell and the language set in the current configuration. Returns false otherwise.
Exceptions
AspellChecker::Exceptionif the spell checker is not valid, or an error occured while checking the token.

References crawlservpp::Wrapper::AspellList::next().

Referenced by crawlservpp::Data::TokenCorrect::correct().

◆ clear()

void crawlservpp::Wrapper::AspellChecker::clear ( )
inline

Deletes the spell checker, if necessary.

Referenced by create(), operator=(), and ~AspellChecker().

◆ create()

void crawlservpp::Wrapper::AspellChecker::create ( AspellConfig configuration)
inline

Creates the spell checker.

Delets the old one, if necessary.

Parameters
configurationThe aspell configuration used by the aspell spell checker.
Exceptions
AspellChecker::Exceptionif the configuration is not valid, or the spell checker could not be created.

References clear(), crawlservpp::Wrapper::AspellConfig::get(), and crawlservpp::Wrapper::AspellConfig::valid().

Referenced by crawlservpp::Data::TokenCorrect::TokenCorrect().

◆ get()

AspellSpeller * crawlservpp::Wrapper::AspellChecker::get ( )
inline

Gets a pointer to the underlying spell checker.

Returns
A pointer to the underlying spell checker or nullptr if the spell checker is not valid.
See also
getc, valid

◆ getc()

const AspellSpeller * crawlservpp::Wrapper::AspellChecker::getc ( ) const
inline

Gets a constant pointer to the underlying spell checker.

Returns
A constant pointer to the underlying spell checker or nullptr if the spell checker is not valid.
See also
get, valid

◆ operator=() [1/2]

AspellChecker& crawlservpp::Wrapper::AspellChecker::operator= ( AspellChecker )
delete

Deleted copy assignment operator.

◆ operator=() [2/2]

AspellChecker & crawlservpp::Wrapper::AspellChecker::operator= ( AspellChecker &&  other)
inlinenoexcept

Move assignment operator.

Moves the spell checker from the specified location into this instance of the class.

Note
The other spell checker will be invalidated by this move.
Nothing will be done if used on itself.
Parameters
otherThe spell checker to move from.
Returns
A reference to the instance containing the spell checker after moving (i.e. *this).
See also
valid

References clear().

◆ valid()

bool crawlservpp::Wrapper::AspellChecker::valid ( ) const
inline

Gets whether the spell checker is valid.

Returns
True, if the spell checker is valid. False otherwise.

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