MacroExpander: Allow registering local expansions

This allows a MacroExpander also to describe an expansion it can
do which was restricted to the global VariableManager only.

The global is now just a thin (unneeded) wrapper about new "standard"
functionality.

Change-Id: Ida7ca70cf3d319eae4220ea8d12f3dd1c0d4042c
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
hjk
2014-10-13 12:49:05 +02:00
parent e43af30faa
commit e279c7e007
35 changed files with 475 additions and 525 deletions

View File

@@ -33,50 +33,11 @@
#include "core_global.h"
#include <functional>
#include <QFileInfo>
#include <QString>
namespace Utils { class AbstractMacroExpander; }
#include <utils/macroexpander.h>
namespace Core {
namespace Internal { class MainWindow; }
class CORE_EXPORT VariableManager
{
public:
static QString value(const QByteArray &variable, bool *found = 0);
static QString expandedString(const QString &stringWithVariables);
static Utils::AbstractMacroExpander *macroExpander();
typedef std::function<QString(QString)> PrefixFunction;
typedef std::function<QString()> StringFunction;
typedef std::function<int()> IntFunction;
static void registerPrefix(const QByteArray &prefix,
const QString &description, const PrefixFunction &value);
static void registerVariable(const QByteArray &variable,
const QString &description, const StringFunction &value);
static void registerIntVariable(const QByteArray &variable,
const QString &description, const IntFunction &value);
static void registerFileVariables(const QByteArray &prefix,
const QString &heading, const StringFunction &value);
static QList<QByteArray> variables();
static QString variableDescription(const QByteArray &variable);
private:
VariableManager();
~VariableManager();
friend class Core::Internal::MainWindow;
};
CORE_EXPORT Utils::MacroExpander *globalMacroExpander();
} // namespace Core