X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Futil.h;h=85d79108218b35feee7a3a62a7dcb8d30f792c96;hp=25f6cc5b406cddd7f17324398901df87713b19af;hb=8f1b4ca33d65b7d9b0e5be399dbff13c9591fbce;hpb=695758015a80eb8c158a9ac4c0f1c0b547e70df3 diff --git a/src/common/util.h b/src/common/util.h index 25f6cc5b..85d79108 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2015 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -18,19 +18,16 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -#ifndef UTIL_H -#define UTIL_H +#pragma once -#include -#include +#include #include -#include +#include -// TODO Use versions from Network instead -QString nickFromMask(QString mask); -QString userFromMask(QString mask); -QString hostFromMask(QString mask); -bool isChannelName(QString str); +QString nickFromMask(const QString &mask); +QString userFromMask(const QString &mask); +QString hostFromMask(const QString &mask); +bool isChannelName(const QString &str); //! Strip mIRC format codes QString stripFormatCodes(QString); @@ -75,4 +72,24 @@ QList fromVariantList(const QVariantList &variants) QByteArray prettyDigest(const QByteArray &digest); -#endif +/** + * Format a string with %%%% to current date/timestamp via QDateTime. + * + * @param[in] formatStr String with format codes + * @return String with current date/time substituted in via formatting codes + */ +QString formatCurrentDateTimeInString(const QString &formatStr); + +/** Check if a scope rule matches a string + * + * Checks that the string does NOT match ANY inverted rules (prefixed by '!'), then checks that + * it matches AT LEAST one normal (non-inverted) rule. + * + * If only inverted rules are specified, it'll match so long as the string does not match any + * inverted rules (implicit wildcard). + * + * @param scopeRule A ';'-separated list of wildcard expressions, prefix of '!' inverts subrule + * @param string String to test, e.g. network/channel name + * @return True if matches, otherwise false + */ +bool scopeMatch(const QString &scopeRule, const QString &string);