FougTools  0.7.0dev-046fb6a
Handy tools for C++, Qt and OpenCascade
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
qstring_utils.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** FougTools
3 ** Copyright Fougue (30 Mar. 2015)
4 ** contact@fougue.pro
5 **
6 ** This software is a computer program whose purpose is to provide utility
7 ** tools for the C++ language and the Qt toolkit.
8 **
9 ** This software is governed by the CeCILL-C license under French law and
10 ** abiding by the rules of distribution of free software. You can use,
11 ** modify and/ or redistribute the software under the terms of the CeCILL-C
12 ** license as circulated by CEA, CNRS and INRIA at the following URL
13 ** "http://www.cecill.info".
14 ****************************************************************************/
15 
16 #pragma once
17 
18 #include "core.h"
19 #include <QtCore/QString>
20 
21 namespace qtcore {
22 
29 {
30 public:
32  inline static bool iequals(const QString& s1, const QString& s2);
33 
35  inline static bool iequals(const QString& s1, QLatin1String s2);
37  inline static bool iequals(QLatin1String s1, const QString& s2);
39  inline static bool iequals(const QString& s1, const QStringRef& s2);
41  inline static bool iequals(const QStringRef& s1, const QString& s2);
42 };
43 
49 {
50  inline bool operator()(const QString& lhs, const QString& rhs) const
51  { return QString::localeAwareCompare(lhs, rhs) == 0; }
52 };
53 
59 {
60  inline bool operator()(const QString& lhs, const QString& rhs) const
61  { return QString::localeAwareCompare(lhs, rhs) != 0; }
62 };
63 
69 {
70  inline bool operator()(const QString& lhs, const QString& rhs) const
71  { return QString::localeAwareCompare(lhs, rhs) < 0; }
72 };
73 
79 {
80  inline bool operator()(const QString& lhs, const QString& rhs) const
81  { return QString::localeAwareCompare(lhs, rhs) <= 0; }
82 };
83 
89 {
90  inline bool operator()(const QString& lhs, const QString& rhs) const
91  { return QString::localeAwareCompare(lhs, rhs) > 0; }
92 };
93 
99 {
100  inline bool operator()(const QString& lhs, const QString& rhs) const
101  { return QString::localeAwareCompare(lhs, rhs) >= 0; }
102 };
103 
104 
105 // --
106 // -- Implementation
107 // --
108 
109 bool QStringUtils::iequals(const QString &s1, const QString &s2)
110 {
111  return QString::compare(s1, s2, Qt::CaseInsensitive) == 0;
112 }
113 
114 bool QStringUtils::iequals(const QString &s1, QLatin1String s2)
115 {
116  return QString::compare(s1, s2, Qt::CaseInsensitive) == 0;
117 }
118 
119 bool QStringUtils::iequals(QLatin1String s1, const QString &s2)
120 {
121  return QString::compare(s1, s2, Qt::CaseInsensitive) == 0;
122 }
123 
124 bool QStringUtils::iequals(const QString& s1, const QStringRef& s2)
125 {
126  return QString::compare(s1, s2, Qt::CaseInsensitive) == 0;
127 }
128 
129 bool QStringUtils::iequals(const QStringRef& s1, const QString& s2)
130 {
131  // There is no QString::compare(QStringRef, QString) overload
132  return QString::compare(s2, s1, Qt::CaseInsensitive) == 0;
133 }
134 
135 } // namespace qtcore
bool operator()(const QString &lhs, const QString &rhs) const
Definition: qstring_utils.h:70
Provides a collection of tools around QString.
Definition: qstring_utils.h:28
bool operator()(const QString &lhs, const QString &rhs) const
Definition: qstring_utils.h:90
Definition: qstring_utils.h:58
Definition: qstring_utils.h:88
bool operator()(const QString &lhs, const QString &rhs) const
Definition: qstring_utils.h:80
#define QTTOOLS_CORE_EXPORT
Definition: core.h:27
static bool iequals(const QString &s1, const QString &s2)
Definition: qstring_utils.h:109
Definition: grid_numbering.cpp:19
bool operator()(const QString &lhs, const QString &rhs) const
Definition: qstring_utils.h:50
Definition: qstring_utils.h:48
Definition: qstring_utils.h:78
bool operator()(const QString &lhs, const QString &rhs) const
Definition: qstring_utils.h:100
Definition: qstring_utils.h:98
Definition: qstring_utils.h:68
bool operator()(const QString &lhs, const QString &rhs) const
Definition: qstring_utils.h:60