24 #include "personimpl.h"
26 #include <kcharsets.h>
28 #include <kdatetime.h>
30 #include <QtCore/QByteArray>
31 #include <QtCore/QDateTime>
32 #include <QtCore/QRegExp>
33 #include <QtCore/QString>
37 namespace Syndication {
41 unsigned int calcHash(
const QString& str)
43 return calcHash(str.
toUtf8());
54 const char* s = array.
data();
55 unsigned int hash = 5381;
57 while ( ( c = *s++ ) ) hash = ((hash << 5) + hash) + c;
64 static time_t toTimeT(KDateTime& kdt)
67 if (kdt.isDateOnly()) {
68 kdt.setTimeSpec(KDateTime::UTC);
69 kdt.setTime(
QTime(12, 0));
71 return kdt.toTime_t();
76 time_t parseISODate(
const QString& str)
78 KDateTime kdt = KDateTime::fromString(str, KDateTime::ISODate);
82 time_t parseRFCDate(
const QString& str)
84 KDateTime kdt = KDateTime::fromString(str, KDateTime::RFCDate);
88 time_t parseDate(
const QString& str, DateFormat hint)
95 time_t t = parseRFCDate(str);
96 return t != 0 ? t : parseISODate(str);
100 time_t t = parseISODate(str);
101 return t != 0 ? t : parseRFCDate(str);
105 QString dateTimeToString(time_t date)
118 md5Machine.update(str.
toUtf8());
124 return KCharsets::resolveEntities(str);
161 str = resolveEntities(str);
167 static bool tagRegExpSet =
false;
170 bool stringContainsMarkup(
const QString& str)
188 bool isHtml(
const QString& str)
211 return isHtml(str) ? str.
trimmed() : plainTextToHtml(str);
214 QString normalize(
const QString& strp,
bool isCDATA,
bool containsMarkup)
222 QString str = resolveEntities(strp);
223 str = escapeSpecialCharacters(str);
224 str = convertNewlines(str);
230 QString str = escapeSpecialCharacters(strp);
237 PersonPtr personFromString(
const QString& strp)
241 return PersonPtr(
new PersonImpl());
243 str = resolveEntities(str);
254 int pos = remail.indexIn(str);
258 email = remail.cap(1);
278 if (rename.exactMatch(name))
280 name = rename.cap(1);
288 return PersonPtr(
new PersonImpl());
290 return PersonPtr(
new PersonImpl(name, uri, email));
293 ElementType::ElementType(
const QString& localnamep,
294 const QString& nsp) : ns(nsp), localname(localnamep)
298 bool ElementType::operator==(
const ElementType& other)
const
300 return localname == other.localname && ns == other.ns;
QString toString(Qt::DateFormat format) const
QString simplified() const
QString & remove(int position, int n)
bool contains(QChar ch, Qt::CaseSensitivity cs) const
QString & replace(int position, int n, QChar after)
void setTime_t(uint seconds)
QByteArray toUtf8() const