Soprano 2.9.4
languagetag.h
Go to the documentation of this file.
1/*
2 * This file is part of Soprano Project.
3 *
4 * Copyright (C) 2009 Greg Beauchesne <greg_b@vision-play.com>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 */
21
22#ifndef SOPRANO_LANGUAGETAG_H
23#define SOPRANO_LANGUAGETAG_H
24
25#include <QtCore/QSharedDataPointer>
26#include <QtCore/QTextStream>
27#include <QtCore/QLocale>
28#include <QtCore/QFlags>
29#include <QtCore/QMetaType>
30
31#include "soprano_export.h"
32
33namespace Soprano
34{
45 {
46 public:
55 MatchFilterBasic = 0,
56
62 MatchFilterExtended = 1
63 };
64
71 LookupFlagNone = 0,
73 LookupFlagNoFallback = 1
74 };
75 Q_DECLARE_FLAGS(LookupFlags, LookupFlag)
76
77 public:
87
93 LanguageTag( const LanguageTag &other );
94
100 LanguageTag( const char * tag );
101
108
114 LanguageTag( const QString &tag );
115
122 explicit LanguageTag( const QLocale &locale );
123
131 LanguageTag( QLocale::Language lang, QLocale::Country country = QLocale::AnyCountry );
132
138
147
154 bool operator==( const LanguageTag& other ) const;
155
161 bool operator!=( const LanguageTag& other ) const;
162
167 bool operator<( const LanguageTag& other ) const;
168
173 bool operator<=( const LanguageTag& other ) const;
174
179 bool operator>( const LanguageTag& other ) const;
180
185 bool operator>=( const LanguageTag& other ) const;
186
196 bool matches( const LanguageTag& range, MatchFilter scheme = MatchFilterBasic ) const;
198
203
207 bool isEmpty() const;
208
224 bool isValid() const;
225
230
232
243
251
269
277 inline operator QString() const { return toString(); }
279
280
321 static int lookup(
322 const QList<LanguageTag> & choices,
323 const QList<LanguageTag> & priority,
324 LookupFlags flags = LookupFlagNone,
325 MatchFilter scheme = MatchFilterBasic
326 );
327
344 static int lookup(
345 const QList<LanguageTag> & choices,
346 const LanguageTag & priority,
347 LookupFlags flags = LookupFlagNone,
348 MatchFilter scheme = MatchFilterBasic
349 );
350
351 private:
352 class Private;
354 };
355
356 SOPRANO_EXPORT uint qHash( const LanguageTag& node );
357}
358
359Q_DECLARE_METATYPE( Soprano::LanguageTag )
360Q_DECLARE_TYPEINFO( Soprano::LanguageTag, Q_MOVABLE_TYPE );
361
362Q_DECLARE_OPERATORS_FOR_FLAGS(Soprano::LanguageTag::LookupFlags)
363
364SOPRANO_EXPORT QDebug operator<<( QDebug s, const Soprano::LanguageTag& );
365SOPRANO_EXPORT QTextStream& operator<<( QTextStream& s, const Soprano::LanguageTag& );
366
367#endif // SOPRANO_LANGUAGETAG_H
A LanguageTag represents a language according to RFC 3066 and RFC 4646.
Definition languagetag.h:45
static int lookup(const QList< LanguageTag > &choices, const LanguageTag &priority, LookupFlags flags=LookupFlagNone, MatchFilter scheme=MatchFilterBasic)
QString toPrettyString() const
bool isValid() const
QString toString() const
LanguageTag(const QLatin1String &tag)
bool operator!=(const LanguageTag &other) const
LanguageTag(const char *tag)
QLocale toLocale() const
LanguageTag(QLocale::Language lang, QLocale::Country country=QLocale::AnyCountry)
LanguageTag & operator=(const LanguageTag &other)
bool operator>=(const LanguageTag &other) const
LanguageTag(const QLocale &locale)
bool operator==(const LanguageTag &other) const
bool matches(const LanguageTag &range, MatchFilter scheme=MatchFilterBasic) const
bool isEmpty() const
bool operator<(const LanguageTag &other) const
static int lookup(const QList< LanguageTag > &choices, const QList< LanguageTag > &priority, LookupFlags flags=LookupFlagNone, MatchFilter scheme=MatchFilterBasic)
LanguageTag(const QString &tag)
bool operator>(const LanguageTag &other) const
LanguageTag(const LanguageTag &other)
QStringList subTags() const
bool operator<=(const LanguageTag &other) const
Q_DECLARE_TYPEINFO(Soprano::LanguageTag, Q_MOVABLE_TYPE)
SOPRANO_EXPORT uint qHash(const LanguageTag &node)
#define SOPRANO_EXPORT