kdecore: format and indent

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-06-19 07:20:37 +03:00
parent 4a47d9f369
commit d2b312f5a1
3 changed files with 40 additions and 39 deletions

View file

@ -23,11 +23,12 @@
#define KMACROEXPANDER_H #define KMACROEXPANDER_H
#include <kdecore_export.h> #include <kdecore_export.h>
#include <QtCore/QChar>
#include <QChar>
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
#include <QHash> #include <QHash>
class KMacroExpanderBasePrivate; class KMacroExpanderBasePrivate;
/** /**
@ -38,14 +39,14 @@ class KMacroExpanderBasePrivate;
* *
* @author Oswald Buddenhagen <ossi@kde.org> * @author Oswald Buddenhagen <ossi@kde.org>
*/ */
class KDECORE_EXPORT KMacroExpanderBase { class KDECORE_EXPORT KMacroExpanderBase
{
public: public:
/** /**
* Constructor. * Constructor.
* @param c escape char indicating start of macros, or null QChar for none * @param c escape char indicating start of macros, or null QChar for none
*/ */
explicit KMacroExpanderBase( QChar c = QLatin1Char('%') ); explicit KMacroExpanderBase(QChar c = QLatin1Char('%'));
/** /**
* Destructor. * Destructor.
@ -57,7 +58,7 @@ public:
* *
* @param str the string in which macros are expanded in-place * @param str the string in which macros are expanded in-place
*/ */
void expandMacros( QString &str ); void expandMacros(QString &str);
// TODO: This documentation is relevant for end-users. Where to put it? // TODO: This documentation is relevant for end-users. Where to put it?
/** /**
@ -97,19 +98,19 @@ public:
* or brace outside any shell construct is @em not an error (unlike in * or brace outside any shell construct is @em not an error (unlike in
* the function below), but still prematurely terminates processing. * the function below), but still prematurely terminates processing.
*/ */
bool expandMacrosShellQuote( QString &str, int &pos ); bool expandMacrosShellQuote(QString &str, int &pos);
/** /**
* Same as above, but always starts at position 0, and unmatched closing * Same as above, but always starts at position 0, and unmatched closing
* parens and braces are treated as errors. * parens and braces are treated as errors.
*/ */
bool expandMacrosShellQuote( QString &str ); bool expandMacrosShellQuote(QString &str);
/** /**
* Set the macro escape character. * Set the macro escape character.
* @param c escape char indicating start of macros, or null QChar if none * @param c escape char indicating start of macros, or null QChar if none
*/ */
void setEscapeChar( QChar c ); void setEscapeChar(QChar c);
/** /**
* Obtain the macro escape character. * Obtain the macro escape character.
@ -131,7 +132,7 @@ protected:
* than zero, subtract this value from @p pos (to skip a macro, i.e., * than zero, subtract this value from @p pos (to skip a macro, i.e.,
* substitute it with itself). If zero, no macro starts at @p pos. * substitute it with itself). If zero, no macro starts at @p pos.
*/ */
virtual int expandPlainMacro( const QString &str, int pos, QStringList &ret ); virtual int expandPlainMacro(const QString &str, int pos, QStringList &ret);
/** /**
* This function is called every time the escape char is found if it is * This function is called every time the escape char is found if it is
@ -148,7 +149,7 @@ protected:
* substitute it with itself). If zero, scanning continues as if no * substitute it with itself). If zero, scanning continues as if no
* escape char was encountered at all. * escape char was encountered at all.
*/ */
virtual int expandEscapedMacro( const QString &str, int pos, QStringList &ret ); virtual int expandEscapedMacro(const QString &str, int pos, QStringList &ret);
private: private:
KMacroExpanderBasePrivate * const d; KMacroExpanderBasePrivate * const d;
@ -204,20 +205,20 @@ private:
* *
* @author Oswald Buddenhagen <ossi@kde.org> * @author Oswald Buddenhagen <ossi@kde.org>
*/ */
class KDECORE_EXPORT KWordMacroExpander : public KMacroExpanderBase { class KDECORE_EXPORT KWordMacroExpander : public KMacroExpanderBase
{
public: public:
/** /**
* Constructor. * Constructor.
* @param c escape char indicating start of macros, or null QChar for none * @param c escape char indicating start of macros, or null QChar for none
*/ */
explicit KWordMacroExpander( QChar c = QLatin1Char('%') ) : KMacroExpanderBase( c ) {} explicit KWordMacroExpander(QChar c = QLatin1Char('%')) : KMacroExpanderBase(c) {}
protected: protected:
/** \internal Not to be called or reimplemented. */ /** \internal Not to be called or reimplemented. */
int expandPlainMacro( const QString &str, int pos, QStringList &ret ) final; int expandPlainMacro(const QString &str, int pos, QStringList &ret) final;
/** \internal Not to be called or reimplemented. */ /** \internal Not to be called or reimplemented. */
int expandEscapedMacro( const QString &str, int pos, QStringList &ret ) final; int expandEscapedMacro(const QString &str, int pos, QStringList &ret) final;
/** /**
* Return substitution list @p ret for string macro @p str. * Return substitution list @p ret for string macro @p str.
@ -226,7 +227,7 @@ protected:
* when expandMacro is entered. * when expandMacro is entered.
* @return @c true iff @p chr was a recognized macro name * @return @c true iff @p chr was a recognized macro name
*/ */
virtual bool expandMacro( const QString &str, QStringList &ret ) = 0; virtual bool expandMacro(const QString &str, QStringList &ret) = 0;
}; };
/** /**
@ -240,20 +241,20 @@ protected:
* *
* @author Oswald Buddenhagen <ossi@kde.org> * @author Oswald Buddenhagen <ossi@kde.org>
*/ */
class KDECORE_EXPORT KCharMacroExpander : public KMacroExpanderBase { class KDECORE_EXPORT KCharMacroExpander : public KMacroExpanderBase
{
public: public:
/** /**
* Constructor. * Constructor.
* @param c escape char indicating start of macros, or null QChar for none * @param c escape char indicating start of macros, or null QChar for none
*/ */
explicit KCharMacroExpander( QChar c = QLatin1Char('%') ) : KMacroExpanderBase( c ) {} explicit KCharMacroExpander(QChar c = QLatin1Char('%')) : KMacroExpanderBase(c) {}
protected: protected:
/** \internal Not to be called or reimplemented. */ /** \internal Not to be called or reimplemented. */
int expandPlainMacro( const QString &str, int pos, QStringList &ret ) final; int expandPlainMacro(const QString &str, int pos, QStringList &ret) final;
/** \internal Not to be called or reimplemented. */ /** \internal Not to be called or reimplemented. */
int expandEscapedMacro( const QString &str, int pos, QStringList &ret ) final; int expandEscapedMacro(const QString &str, int pos, QStringList &ret) final;
/** /**
* Return substitution list @p ret for single-character macro @p chr. * Return substitution list @p ret for single-character macro @p chr.
@ -262,7 +263,7 @@ protected:
* when expandMacro is entered. * when expandMacro is entered.
* @return @c true iff @p chr was a recognized macro name * @return @c true iff @p chr was a recognized macro name
*/ */
virtual bool expandMacro( QChar chr, QStringList &ret ) = 0; virtual bool expandMacro(QChar chr, QStringList &ret) = 0;
}; };
/** /**
@ -290,7 +291,7 @@ namespace KMacroExpander {
* // s is now "% Title: /tmp/myfile.txt:My File"; * // s is now "% Title: /tmp/myfile.txt:My File";
* \endcode * \endcode
*/ */
KDECORE_EXPORT QString expandMacros( const QString &str, const QHash<QChar,QString> &map, QChar c = QLatin1Char('%') ); KDECORE_EXPORT QString expandMacros(const QString &str, const QHash<QChar,QString> &map, QChar c = QLatin1Char('%'));
/** /**
* Perform safe macro expansion (substitution) on a string for use * Perform safe macro expansion (substitution) on a string for use
@ -315,8 +316,8 @@ namespace KMacroExpander {
* system(QFile::encodeName(s)); * system(QFile::encodeName(s));
* \endcode * \endcode
*/ */
KDECORE_EXPORT QString expandMacrosShellQuote( const QString &str, const QHash<QChar,QString> &map, KDECORE_EXPORT QString expandMacrosShellQuote(const QString &str, const QHash<QChar,QString> &map,
QChar c = QLatin1Char('%') ); QChar c = QLatin1Char('%') );
/** /**
* Perform safe macro expansion (substitution) on a string. * Perform safe macro expansion (substitution) on a string.
@ -341,8 +342,8 @@ namespace KMacroExpander {
* // s is now "Title: /tmp/myfile.txt-My File"; * // s is now "Title: /tmp/myfile.txt-My File";
* \endcode * \endcode
*/ */
KDECORE_EXPORT QString expandMacros( const QString &str, const QHash<QString,QString> &map, KDECORE_EXPORT QString expandMacros(const QString &str, const QHash<QString,QString> &map,
QChar c = QLatin1Char('%') ); QChar c = QLatin1Char('%'));
/** /**
* Perform safe macro expansion (substitution) on a string for use * Perform safe macro expansion (substitution) on a string for use
@ -371,17 +372,17 @@ namespace KMacroExpander {
* system(QFile::encodeName(s)); * system(QFile::encodeName(s));
* \endcode * \endcode
*/ */
KDECORE_EXPORT QString expandMacrosShellQuote( const QString &str, const QHash<QString,QString> &map, KDECORE_EXPORT QString expandMacrosShellQuote(const QString &str, const QHash<QString,QString> &map,
QChar c = QLatin1Char('%') ); QChar c = QLatin1Char('%'));
/** /**
* Same as above, except that the macros expand to string lists that * Same as above, except that the macros expand to string lists that
* are simply join(" ")ed together. * are simply join(" ")ed together.
*/ */
KDECORE_EXPORT QString expandMacros( const QString &str, const QHash<QChar,QStringList> &map, KDECORE_EXPORT QString expandMacros(const QString &str, const QHash<QChar,QStringList> &map,
QChar c = QLatin1Char('%') ); QChar c = QLatin1Char('%'));
KDECORE_EXPORT QString expandMacros( const QString &str, const QHash<QString,QStringList> &map, KDECORE_EXPORT QString expandMacros(const QString &str, const QHash<QString,QStringList> &map,
QChar c = QLatin1Char('%') ); QChar c = QLatin1Char('%'));
/** /**
* Same as above, except that the macros expand to string lists. * Same as above, except that the macros expand to string lists.
@ -389,10 +390,10 @@ namespace KMacroExpander {
* join(" ")ed together; otherwise every element expands to a separate * join(" ")ed together; otherwise every element expands to a separate
* quoted string. * quoted string.
*/ */
KDECORE_EXPORT QString expandMacrosShellQuote( const QString &str, const QHash<QChar,QStringList> &map, KDECORE_EXPORT QString expandMacrosShellQuote(const QString &str, const QHash<QChar,QStringList> &map,
QChar c = QLatin1Char('%') ); QChar c = QLatin1Char('%'));
KDECORE_EXPORT QString expandMacrosShellQuote( const QString &str, const QHash<QString,QStringList> &map, KDECORE_EXPORT QString expandMacrosShellQuote(const QString &str, const QHash<QString,QStringList> &map,
QChar c = QLatin1Char('%') ); QChar c = QLatin1Char('%'));
} }
#endif /* KMACROEXPANDER_H */ #endif /* KMACROEXPANDER_H */

View file

@ -27,7 +27,7 @@
class KMacroExpanderBasePrivate class KMacroExpanderBasePrivate
{ {
public: public:
KMacroExpanderBasePrivate( QChar c ) : escapechar(c) {} KMacroExpanderBasePrivate(QChar c) : escapechar(c) {}
QChar escapechar; QChar escapechar;
}; };

View file

@ -136,7 +136,7 @@ bool KMacroExpanderBase::expandMacrosShellQuote(QString &str, int &pos)
} }
// always swallow the char -> prevent anomalies due to expansion // always swallow the char -> prevent anomalies due to expansion
} else if (cc == '`') { } else if (cc == '`') {
str.replace(pos, 1, QLatin1String("$( " )); // add space -> avoid creating $(( str.replace(pos, 1, QLatin1String("$( ")); // add space -> avoid creating $((
pos2 = pos += 3; pos2 = pos += 3;
for (;;) { for (;;) {
if (pos2 >= str.length()) { if (pos2 >= str.length()) {