tools.h
00001 /* 00002 * This file is part of the syndication library 00003 * 00004 * Copyright (C) 2006 Frank Osterfeld <osterfeld@kde.org> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Library General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Library General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Library General Public License 00017 * along with this library; see the file COPYING.LIB. If not, write to 00018 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 * 00021 */ 00022 00023 #ifndef SYNDICATION_TOOLS_H 00024 #define SYNDICATION_TOOLS_H 00025 00026 #include <syndication/person.h> 00027 #include "ksyndication_export.h" 00028 00029 00030 #include <QtCore/QString> 00031 00032 #include <ctime> 00033 00034 class QByteArray; 00035 class QString; 00036 00037 namespace Syndication { 00038 00041 enum DateFormat 00042 { 00043 ISODate, 00047 RFCDate 00048 }; 00049 00059 //KDE5: uint, not time_t 00060 SYNDICATION_EXPORT 00061 time_t parseISODate(const QString& str); 00062 00071 //KDE5: uint, not time_t 00072 SYNDICATION_EXPORT 00073 time_t parseRFCDate(const QString& str); 00074 00088 //KDE5: uint, not time_t 00089 SYNDICATION_EXPORT 00090 time_t parseDate(const QString& str, DateFormat hint=RFCDate); 00091 00092 00102 //KDE5: uint, not time_t 00103 SYNDICATION_EXPORT 00104 QString dateTimeToString(time_t date); 00105 00111 SYNDICATION_EXPORT 00112 QString resolveEntities(const QString& str); 00113 00119 SYNDICATION_EXPORT 00120 QString escapeSpecialCharacters(const QString& str); 00121 00126 SYNDICATION_EXPORT 00127 QString convertNewlines(const QString& str); 00128 00134 SYNDICATION_EXPORT 00135 QString plainTextToHtml(const QString& plainText); 00136 00143 SYNDICATION_EXPORT 00144 QString htmlToPlainText(const QString& html); 00145 00153 SYNDICATION_EXPORT 00154 bool isHtml(const QString& str); 00155 00165 SYNDICATION_EXPORT 00166 bool stringContainsMarkup(const QString& str); 00167 00177 SYNDICATION_EXPORT 00178 QString normalize(const QString& str); 00179 00198 SYNDICATION_EXPORT 00199 QString normalize(const QString& str, bool isCDATA, bool containsMarkup); 00200 00209 SYNDICATION_EXPORT 00210 PersonPtr personFromString(const QString& str); 00211 00216 unsigned int calcHash(const QString& str); 00217 00222 unsigned int calcHash(const QByteArray& array); 00223 00228 QString calcMD5Sum(const QString& str); 00229 00230 //@cond PRIVATE 00235 struct ElementType 00236 { 00237 ElementType(const QString& localnamep, 00238 const QString& nsp=QString()); // implicit 00239 00240 bool operator==(const ElementType& other) const; 00241 00242 QString ns; 00243 QString localname; 00244 }; 00245 //@endcond 00246 00247 } // namespace Syndication 00248 00249 #endif // SYNDICATION_TOOLS_H