libqutim  0.3.1.0
utils.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** qutIM - instant messenger
4 **
5 ** Copyright © 2011 Aleksey Sidorov <gorthauer87@yandex.ru>
6 ** Copyright © 2012 Ruslan Nigmatullin <euroelessar@yandex.ru>
7 **
8 *****************************************************************************
9 **
10 ** $QUTIM_BEGIN_LICENSE$
11 ** This program is free software: you can redistribute it and/or modify
12 ** it under the terms of the GNU General Public License as published by
13 ** the Free Software Foundation, either version 3 of the License, or
14 ** (at your option) any later version.
15 **
16 ** This program is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 ** See the GNU General Public License for more details.
20 **
21 ** You should have received a copy of the GNU General Public License
22 ** along with this program. If not, see http://www.gnu.org/licenses/.
23 ** $QUTIM_END_LICENSE$
24 **
25 ****************************************************************************/
26 
27 #ifndef UTILS_H
28 #define UTILS_H
29 #include "libqutim_global.h"
30 
31 namespace qutim_sdk_0_3
32 {
33 
34 template<typename T>
35 Q_INLINE_TEMPLATE T sender_cast(QObject *sender)
36 {
37  Q_ASSERT(qobject_cast<T>(sender));
38  return static_cast<T>(sender);
39 }
40 
42 {
43 public:
44  enum Flag {
45  None = 0x00,
46  Html = 0x01
47  };
48  Q_DECLARE_FLAGS(Flags, Flag)
49  struct UrlToken
50  {
51  QStringRef text;
52  QString url;
53  };
54  typedef QList<UrlToken> UrlTokenList;
55 
56  static UrlTokenList tokenize(const QString &text, Flags flags = None);
57  static QString parseUrls(const QString &text, Flags flags = None);
58 private:
59  UrlParser();
60  ~UrlParser();
61 };
62 
63 } //namespace qutim_sdk_0_3
64 
65 Q_DECLARE_OPERATORS_FOR_FLAGS(qutim_sdk_0_3::UrlParser::Flags)
66 
67 #endif // UTILS_H
68 

Generated by Doxygen