AcceptLanguageList Class Reference

#include <AcceptLanguageList.h>

Public Member Functions

 AcceptLanguageList ()
 
 AcceptLanguageList (const AcceptLanguageList &acceptLanguages)
 
 ~AcceptLanguageList ()
 
AcceptLanguageListoperator= (const AcceptLanguageList &acceptLanguages)
 
Uint32 size () const
 
LanguageTag getLanguageTag (Uint32 index) const
 
Real32 getQualityValue (Uint32 index) const
 
void insert (const LanguageTag &languageTag, Real32 qualityValue)
 
void remove (Uint32 index)
 
Uint32 find (const LanguageTag &languageTag) const
 
void clear ()
 
Boolean operator== (const AcceptLanguageList &acceptLanguages) const
 
Boolean operator!= (const AcceptLanguageList &acceptLanguages) const
 

Detailed Description

This class represents an list of languages that a reader can understand (as may be specified in an HTTP Accept-Language header value). It is managed as a prioritized list of LanguageTag objects and quality values.

Constructor & Destructor Documentation

◆ AcceptLanguageList() [1/2]

AcceptLanguageList::AcceptLanguageList ( )

Constructs an empty AcceptLanguageList object.

◆ AcceptLanguageList() [2/2]

AcceptLanguageList::AcceptLanguageList ( const AcceptLanguageList acceptLanguages)

Copy constructor.

Parameters
acceptLanguagesThe AcceptLanguageList object to copy.

◆ ~AcceptLanguageList()

AcceptLanguageList::~AcceptLanguageList ( )

Destructor.

Member Function Documentation

◆ clear()

void AcceptLanguageList::clear ( )

Removes all the LanguageTags and quality values from the AcceptLanguageList object.

◆ find()

Uint32 AcceptLanguageList::find ( const LanguageTag languageTag) const

Finds the first occurrence of the specified LanguageTag in the AcceptLanguageList object and returns its index.

Parameters
languageTagThe LanguageTag to find.
Returns
Integer index of the element, if found; otherwise PEG_NOT_FOUND.

◆ getLanguageTag()

LanguageTag AcceptLanguageList::getLanguageTag ( Uint32  index) const

Accesses an LanguageTag at a specified index.

Parameters
indexInteger index of the LanguageTag to access. Valid indices range from 0 to size()-1.
Returns
The LanguageTag corresponding to the specified index.
Exceptions
IndexOutOfBoundsExceptionIf the specified index is out of range.

◆ getQualityValue()

Real32 AcceptLanguageList::getQualityValue ( Uint32  index) const

Accesses a quality value at a specified index (corresponding to a language tag).

Parameters
indexInteger index of the quality value to access. Valid indices range from 0 to size()-1.
Returns
The quality value corresponding to the specified index.
Exceptions
IndexOutOfBoundsExceptionIf the specified index is out of range.

◆ insert()

void AcceptLanguageList::insert ( const LanguageTag languageTag,
Real32  qualityValue 
)

Inserts a LanguageTag and quality value into the AcceptLanguageList object. The element is inserted in order of descending quality value and after any other elements with the same quality value.

Parameters
languageTagThe LanguageTag to insert.
qualityValueThe quality value to insert.

◆ operator!=()

Boolean AcceptLanguageList::operator!= ( const AcceptLanguageList acceptLanguages) const

Tests AcceptLanguageList objects for inequality.

Parameters
acceptLanguagesAn AcceptLanguageList object to be compared.
Returns
False if the AcceptLanguageList objects contain the same LanguageTags and quality values in the same order, true otherwise.

◆ operator=()

AcceptLanguageList& AcceptLanguageList::operator= ( const AcceptLanguageList acceptLanguages)

Assignment operator.

Parameters
acceptLanguagesThe AcceptLanguageList object to copy.

◆ operator==()

Boolean AcceptLanguageList::operator== ( const AcceptLanguageList acceptLanguages) const

Tests AcceptLanguageList objects for equality.

Parameters
acceptLanguagesAn AcceptLanguageList object to be compared.
Returns
True if the AcceptLanguageList objects contain the same LanguageTags and quality values in the same order, false otherwise.

◆ remove()

void AcceptLanguageList::remove ( Uint32  index)

Removes the specified LanguageTag and quality value from the AcceptLanguageList object.

Parameters
indexInteger index of the element to remove.
Exceptions
IndexOutOfBoundsExceptionIf the specified index is out of range.

◆ size()

Uint32 AcceptLanguageList::size ( ) const

Returns the number of LanguagesTags in the AcceptLanguageList object.

Returns
Integer size of the AcceptLanguageList list.

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