• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kiten/lib

Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
DictQuery Class Reference

#include <dictquery.h>

Public Types

enum  FilterType { NoFilter, Rare, CommonUncommon }
 
enum  MatchType { Exact, Beginning, Ending, Anywhere }
 
enum  MatchWordType {
  Any, Verb, Noun, Adjective,
  Adverb, Prefix, Suffix, Expression
}
 
enum  StringTypeEnum {
  Kanji, Kana, Latin, Mixed,
  ParseError
}
 

Public Member Functions

 DictQuery ()
 
 DictQuery (const QString &str)
 
 DictQuery (const DictQuery &orig)
 
 ~DictQuery ()
 
void clear ()
 
DictQuery * clone () const
 
QStringList getDictionaries () const
 
FilterType getFilterType () const
 
MatchType getMatchType () const
 
MatchWordType getMatchWordType () const
 
QString getMeaning () const
 
QString getPronunciation () const
 
QString getProperty (const QString &key) const
 
QString getWord () const
 
bool hasProperty (const QString &key) const
 
bool isEmpty () const
 
const QList< QString > listPropertyKeys () const
 
 operator QString () const
 
DictQuery & operator+= (const DictQuery &old)
 
DictQuery & operator+= (const QString &old)
 
DictQuery & operator= (const DictQuery &old)
 
DictQuery & operator= (const QString &old)
 
DictQuery & operator= (const char *)
 
const QString operator[] (const QString &key) const
 
QString operator[] (const QString &key)
 
bool removeProperty (const QString &key)
 
void setDictionaries (const QStringList &newDictionaries)
 
void setFilterType (FilterType newType)
 
void setMatchType (MatchType newType)
 
void setMatchWordType (MatchWordType newType)
 
bool setMeaning (const QString &newMeaning)
 
bool setPronunciation (const QString &newPronunciation)
 
bool setProperty (const QString &key, const QString &value)
 
bool setWord (const QString &newWord)
 
QString takeProperty (const QString &key)
 
const QString toString () const
 

Static Public Member Functions

static StringTypeEnum charTypeCheck (const QChar &ch)
 
static StringTypeEnum stringTypeCheck (const QString &in)
 

Static Public Attributes

static const QString mainDelimiter
 
static const QString propertySeperator
 

Friends

KITEN_EXPORT friend bool operator!= (const DictQuery &other, const DictQuery &query)
 
KITEN_EXPORT friend DictQuery operator+ (const DictQuery &a, const DictQuery &b)
 
KITEN_EXPORT friend bool operator< (const DictQuery &a, const DictQuery &b)
 
KITEN_EXPORT friend bool operator<= (const DictQuery &a, const DictQuery &b)
 
KITEN_EXPORT friend bool operator== (const DictQuery &a, const DictQuery &b)
 

Detailed Description

A class to allow users of libkiten to properly setup a database query.

In general, you either pass or parse in parameters from users or automated programs to be later sent to the dictionary manager.

This class is one of the three critical classes (along with dictionary and EntryList) that are needed to use libkiten. Essentially... you feed the dictionary class a DictQuery, and dictionary will return an EntryList that matches the query.

dictionary dictManager();
//Load some dictionaries via dictionary class methods
EntryList *results;
DictQuery myQuery("kanji");
results = dictManager.doSearch(myQuery);
//Print results (if any)

The internal implementation understands four distinct types of data: Japanese Kanji Japanese Kana English Characters Property Pairs of the form <i>name</i>:<i>value</i>

It is left up to the individual dictionary types to parse these values for matching and appropriateness to each dictionary. You can use the setDictionaries() method to narrow the range of the dictionaries that it will apply to.

A DictQuery object can be considered an "unordered set" of values. When testing for equality or comparison, each property or text entry above is seen as a unique item in a set. Order is not important for these operations. The object will attempt to preserve the order from parsed strings, but it does not consider this order to be important.

In general, application level programs are expected to use the QString based interfaces, and dictionary implementations and other parts of libkiten are expected to use the direct accessors and mutators, although specialized interfaces (such as kitenradselect) may use property mutators for a limited set of properties. (in this case, radicals)

The query string input is of the following format: <QS> ::= <M>DictQuery::mainDelimiter<QS>|<R>DictQuery::mainDelimiter<QS>| <O>DictQuery::mainDelimiter<QS>|NULL <M> ::= kana<M>|kana <R> ::= character<R>|character <O> ::= <C>DictQuery::propertySeparator<D> <C> ::= character<C>|character <D> ::= character<D>|character

Author
Joseph Kerian <jkeri.nosp@m.an@g.nosp@m.mail..nosp@m.com>

Definition at line 89 of file dictquery.h.

Member Enumeration Documentation

enum DictQuery::FilterType
Enumerator
NoFilter 
Rare 
CommonUncommon 

Definition at line 325 of file dictquery.h.

enum DictQuery::MatchType

This enum is used to define the type of matching this query is supposed to do.

The names are fairly self-explanatory

Enumerator
Exact 
Beginning 
Ending 
Anywhere 

Definition at line 285 of file dictquery.h.

enum DictQuery::MatchWordType

This enum is used to define the type of matching this query is supposed to do.

Enumerator
Any 
Verb 
Noun 
Adjective 
Adverb 
Prefix 
Suffix 
Expression 

Definition at line 305 of file dictquery.h.

enum DictQuery::StringTypeEnum

This enum is used as the return type for the two utility functions, stringTypeCheck and charTypeCheck.

Enumerator
Kanji 
Kana 
Latin 
Mixed 
ParseError 

Definition at line 345 of file dictquery.h.

Constructor & Destructor Documentation

DictQuery::DictQuery ( )

Normal constructor.

This will create an empty query object.

Definition at line 79 of file dictquery.cpp.

DictQuery::DictQuery ( const QString &  str)

Constructor with a given QString.

Parameters
strthe QString will be parsed as described below in operator=(const QString&)

Definition at line 83 of file dictquery.cpp.

DictQuery::DictQuery ( const DictQuery &  orig)

Copy constructor.

Parameters
origthe original DictQuery to be copied

Definition at line 89 of file dictquery.cpp.

DictQuery::~DictQuery ( )

Destructor.

Definition at line 106 of file dictquery.cpp.

Member Function Documentation

DictQuery::StringTypeEnum DictQuery::charTypeCheck ( const QChar &  ch)
static

This utility does the same thing for QChar as stringTypeCheck does for QString.

Private utility method for the stringTypeCheck Just checks and returns the type of the first character in the string that is passed to it.

At the moment the implementation is rather simple, and it assumes that anything that is not latin1 or kana is a kanji.

Definition at line 418 of file dictquery.cpp.

void DictQuery::clear ( )

Removes all text/entries from the DictQuery.

Definition at line 118 of file dictquery.cpp.

DictQuery * DictQuery::clone ( ) const

The clone method.

Definition at line 95 of file dictquery.cpp.

QStringList DictQuery::getDictionaries ( ) const

Returns a list of the dictionaries that this particular query will target.

An empty list (the default) will search all dictionaries that the user has selected.

Definition at line 583 of file dictquery.cpp.

DictQuery::FilterType DictQuery::getFilterType ( ) const

Get which filter is currently set on the DictQuery.

Definition at line 596 of file dictquery.cpp.

DictQuery::MatchType DictQuery::getMatchType ( ) const

Get which match type is currently set on the DictQuery.

Definition at line 606 of file dictquery.cpp.

DictQuery::MatchWordType DictQuery::getMatchWordType ( ) const

Get which word type is currently set on the DictQuery.

Definition at line 616 of file dictquery.cpp.

QString DictQuery::getMeaning ( ) const

Accessor for the non-japanese meaning field.

Definition at line 502 of file dictquery.cpp.

QString DictQuery::getPronunciation ( ) const

Accessor for the Pronunciation field (generally kana)

Definition at line 528 of file dictquery.cpp.

QString DictQuery::getProperty ( const QString &  key) const

Get a specific property by key (is the same as using operator[] const)

Definition at line 440 of file dictquery.cpp.

QString DictQuery::getWord ( ) const

Accessor for the Word/Kanji field (this is usually used for anything containing kanji).

Definition at line 554 of file dictquery.cpp.

bool DictQuery::hasProperty ( const QString &  key) const

Verify if a given DictQuery object has a search parameter of a particular property.

Definition at line 460 of file dictquery.cpp.

bool DictQuery::isEmpty ( ) const
Returns
true if the DictQuery is completely empty

Definition at line 111 of file dictquery.cpp.

const QList< QString > DictQuery::listPropertyKeys ( ) const

Use this to get a list of all the property keys in the query.

Definition at line 445 of file dictquery.cpp.

DictQuery::operator QString ( ) const

This is a convertion to a QString...

useful in a surprising number of cases.

Definition at line 100 of file dictquery.cpp.

DictQuery & DictQuery::operator+= ( const DictQuery &  old)

This will append the properties and other elements of the added kanji onto the elements of the current element.

If regenerated as a string, it should look something like concatenation

Definition at line 150 of file dictquery.cpp.

DictQuery& DictQuery::operator+= ( const QString &  old)

A simple override of operator+=( const DictQuery& )

DictQuery & DictQuery::operator= ( const DictQuery &  old)

The assignment copy operator.

Definition at line 131 of file dictquery.cpp.

DictQuery & DictQuery::operator= ( const QString &  old)

A simple string parser, look above for examples and explanations.

Definition at line 312 of file dictquery.cpp.

DictQuery& DictQuery::operator= ( const char *  )

An ascii cast variant of the operator= Only available if QT_NO_CAST_ASCII is not defined on lib compilation.

const QString DictQuery::operator[] ( const QString &  key) const

Returns a given extended attribute.

Definition at line 450 of file dictquery.cpp.

QString DictQuery::operator[] ( const QString &  key)

Sets a given extended attribute.

Definition at line 455 of file dictquery.cpp.

bool DictQuery::removeProperty ( const QString &  key)

Remove all instances of a property.

Returns
true if the DictQuery had properties of the given type

Definition at line 484 of file dictquery.cpp.

void DictQuery::setDictionaries ( const QStringList &  newDictionaries)

Set the list of dictionaries to search.

This will be read and used by the dictionary manager.

Definition at line 588 of file dictquery.cpp.

void DictQuery::setFilterType ( FilterType  newType)

Set whether or not the query should output results separated in common and uncommon sections.

Definition at line 601 of file dictquery.cpp.

void DictQuery::setMatchType ( MatchType  newType)

Set a match type.

If this is not called, the default is matchExact.

Definition at line 611 of file dictquery.cpp.

void DictQuery::setMatchWordType ( MatchWordType  newType)

Set a word type.

If this is not called, the default value is 'Any'.

Definition at line 621 of file dictquery.cpp.

bool DictQuery::setMeaning ( const QString &  newMeaning)

Mutator for the Meaning field.

Definition at line 507 of file dictquery.cpp.

bool DictQuery::setPronunciation ( const QString &  newPronunciation)

Mutator for the Pronunciation field.

Definition at line 533 of file dictquery.cpp.

bool DictQuery::setProperty ( const QString &  key,
const QString &  value 
)

Set a particular property...

this does significantly more error checking than the operator[] version, and will return false if there was a problem (an empty value or bad key)

Parameters
keythe key for this entry
valuethe value to set this to, will overwrite the current contents of this location
Returns
false on failure

Definition at line 467 of file dictquery.cpp.

bool DictQuery::setWord ( const QString &  newWord)

Mutator for the Word/Kanji field.

If what you are setting contains only kana, consider using the setPronunciation instead.

Definition at line 559 of file dictquery.cpp.

DictQuery::StringTypeEnum DictQuery::stringTypeCheck ( const QString &  in)
static

A simple utility routine to tell us what sort of string we have If the string contains only kanji, kana or non-kanji/kana characters, the result is strTypeKanji, strTypeKana or strTypeLatin (perhaps a misnomer...

Private utility method for the above...

but so far it's valid). If the string contains both kanji and kana, the type returned is strTypeKanji If the string contains any other combination, the return type is mixed.

confirms that an entire string is either completely japanese or completely english

Definition at line 382 of file dictquery.cpp.

QString DictQuery::takeProperty ( const QString &  key)

Returns and removes the property.

Definition at line 493 of file dictquery.cpp.

const QString DictQuery::toString ( ) const

This returns a QString that represents the query.

This may be the same as the original string, but some slight changes may have occurred if you have done any manipulations on the DictQuery.

Definition at line 279 of file dictquery.cpp.

Friends And Related Function Documentation

KITEN_EXPORT friend bool operator!= ( const DictQuery &  other,
const DictQuery &  query 
)
friend

Convenient inverted override of operator==( DictQuery, DictQuery )

Definition at line 215 of file dictquery.cpp.

KITEN_EXPORT friend DictQuery operator+ ( const DictQuery &  a,
const DictQuery &  b 
)
friend

Simple addition...

similer to operator+=

Definition at line 191 of file dictquery.cpp.

KITEN_EXPORT friend bool operator< ( const DictQuery &  a,
const DictQuery &  b 
)
friend

Set-wise strictly less than.

A better way to think of this might be the "subset" operator

Definition at line 220 of file dictquery.cpp.

KITEN_EXPORT friend bool operator<= ( const DictQuery &  a,
const DictQuery &  b 
)
friend

Convenient override of operator<( DictQuery, DictQuery ) and operator==.

KITEN_EXPORT friend bool operator== ( const DictQuery &  a,
const DictQuery &  b 
)
friend

A simple setwise comparison of two DictQuery objects Note that order is not important here...

only each element that is one of the DictQuery objects appears in the other.

Definition at line 198 of file dictquery.cpp.

Member Data Documentation

const QString DictQuery::mainDelimiter
static

This is the main delimiter that the DictQuery uses when parsing strings.

It is set to "space" at the moment.

Definition at line 96 of file dictquery.h.

const QString DictQuery::propertySeperator
static

This is the delimiter that DictQuery uses when parsing property strings of the form strokes:4.

It is set to ":" at the moment.

Definition at line 101 of file dictquery.h.


The documentation for this class was generated from the following files:
  • dictquery.h
  • dictquery.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:16:38 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kiten/lib

Skip menu "kiten/lib"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal