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 
33 namespace Soprano
34 {
45  {
46  public:
47  enum MatchFilter {
55  MatchFilterBasic = 0,
56 
62  MatchFilterExtended = 1
63  };
64 
70  enum LookupFlag {
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 
107  LanguageTag( const QLatin1String &tag );
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 
242  QString toString() const;
243 
251 
268  QLocale toLocale() const;
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 
359 Q_DECLARE_METATYPE( Soprano::LanguageTag )
360 Q_DECLARE_TYPEINFO( Soprano::LanguageTag, Q_MOVABLE_TYPE );
361 
362 Q_DECLARE_OPERATORS_FOR_FLAGS(Soprano::LanguageTag::LookupFlags)
363 
364 SOPRANO_EXPORT QDebug operator<<( QDebug s, const Soprano::LanguageTag& );
365 SOPRANO_EXPORT QTextStream& operator<<( QTextStream& s, const Soprano::LanguageTag& );
366 
367 #endif // SOPRANO_LANGUAGETAG_H
Soprano::LanguageTag::lookup
static int lookup(const QList< LanguageTag > &choices, const QList< LanguageTag > &priority, LookupFlags flags=LookupFlagNone, MatchFilter scheme=MatchFilterBasic)
soprano_export.h
Soprano::LanguageTag::LanguageTag
LanguageTag(const QLocale &locale)
Soprano::LanguageTag::operator<
bool operator<(const LanguageTag &other) const
Soprano::LanguageTag::LanguageTag
LanguageTag()
Soprano::LanguageTag::toLocale
QLocale toLocale() const
Soprano::LanguageTag::~LanguageTag
~LanguageTag()
Soprano::LanguageTag::LanguageTag
LanguageTag(QLocale::Language lang, QLocale::Country country=QLocale::AnyCountry)
QSharedDataPointer< Private >
Soprano::Vocabulary::RDFS::range
SOPRANO_EXPORT QUrl range()
SOPRANO_EXPORT
#define SOPRANO_EXPORT
Definition: soprano_export.h:37
QList
Soprano::LanguageTag::operator>=
bool operator>=(const LanguageTag &other) const
Soprano::LanguageTag::operator>
bool operator>(const LanguageTag &other) const
Q_DECLARE_TYPEINFO
Q_DECLARE_TYPEINFO(Soprano::LanguageTag, Q_MOVABLE_TYPE)
QLocale
Soprano::LanguageTag
A LanguageTag represents a language according to RFC 3066 and RFC 4646.
Definition: languagetag.h:45
Soprano::LanguageTag::isValid
bool isValid() const
Soprano::LanguageTag::subTags
QStringList subTags() const
Soprano::LanguageTag::toPrettyString
QString toPrettyString() const
Soprano::LanguageTag::operator=
LanguageTag & operator=(const LanguageTag &other)
Soprano::LanguageTag::LanguageTag
LanguageTag(const char *tag)
QTextStream
Soprano::LanguageTag::operator!=
bool operator!=(const LanguageTag &other) const
Soprano::LanguageTag::matches
bool matches(const LanguageTag &range, MatchFilter scheme=MatchFilterBasic) const
Soprano::qHash
SOPRANO_EXPORT uint qHash(const LanguageTag &node)
Soprano::LanguageTag::LanguageTag
LanguageTag(const QString &tag)
Soprano::LanguageTag::operator==
bool operator==(const LanguageTag &other) const
QLatin1String
Soprano::LanguageTag::LanguageTag
LanguageTag(const LanguageTag &other)
Soprano::LanguageTag::lookup
static int lookup(const QList< LanguageTag > &choices, const LanguageTag &priority, LookupFlags flags=LookupFlagNone, MatchFilter scheme=MatchFilterBasic)
Soprano::LanguageTag::LanguageTag
LanguageTag(const QLatin1String &tag)
Soprano
Definition: backend.h:36
Soprano::LanguageTag::MatchFilter
MatchFilter
Definition: languagetag.h:47
Soprano::LanguageTag::toString
QString toString() const
QString
Soprano::LanguageTag::isEmpty
bool isEmpty() const
Soprano::LanguageTag::LookupFlag
LookupFlag
Definition: languagetag.h:70
QStringList
Soprano::LanguageTag::operator<=
bool operator<=(const LanguageTag &other) const