X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcommon%2Futil.h;h=85d79108218b35feee7a3a62a7dcb8d30f792c96;hb=f2e4560b71a1888599ca2153eee36a9b4136c902;hp=77191467bfd19c607ea6ced2b70c13f5f6399482;hpb=dcd6c362d77ab4cb5ea73b7e54ce944a68aa3f06;p=quassel.git diff --git a/src/common/util.h b/src/common/util.h index 77191467..85d79108 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2016 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,20 +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 +#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); @@ -76,6 +72,24 @@ QList fromVariantList(const QVariantList &variants) QByteArray prettyDigest(const QByteArray &digest); -QString formatCurrentDateTimeInString(QString str); +/** + * 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); -#endif +/** 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);