summaryrefslogtreecommitdiffstats
path: root/lib/util/filetemplate.h
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit114a878c64ce6f8223cfd22d76a20eb16d177e5e (patch)
treeacaf47eb0fa12142d3896416a69e74cbf5a72242 /lib/util/filetemplate.h
downloadtdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.tar.gz
tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'lib/util/filetemplate.h')
-rw-r--r--lib/util/filetemplate.h88
1 files changed, 88 insertions, 0 deletions
diff --git a/lib/util/filetemplate.h b/lib/util/filetemplate.h
new file mode 100644
index 00000000..e126176d
--- /dev/null
+++ b/lib/util/filetemplate.h
@@ -0,0 +1,88 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002 Bernd Gehrmann <bernd@kdevelop.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef _FILETEMPLATE_H_
+#define _FILETEMPLATE_H_
+
+#include <qstring.h>
+
+class KDevPlugin;
+class QDomDocument;
+
+/**
+@file filetemplate.h
+FileTemplate class with utility methods to work with file templates.
+*/
+
+/**
+Utilities to work with file templates in the current project.
+*/
+class FileTemplate
+{
+public:
+
+ /**Policy of finding file templates.*/
+ typedef enum {
+ Default /**<Checks for templates in project and also for global filecreate templates.*/,
+ Custom /**<Checks for templates in custom directories. This usually means that
+ full paths are given for FileTemplate methods.*/
+ } Policy;
+
+ /**
+ * @return Whether a template with the given name
+ * exists in the current project. File templates
+ * are stored in the "templates" subdirectory of a project or in application shared dirs.
+ */
+ static bool exists(KDevPlugin *part, const QString &name, Policy p = Default);
+
+ /**
+ * Reads a template with the given name (e.g. "cpp")
+ * and makes variable substitutions (like $AUTHOR$ etc.)
+ * in it. The resulting string is returned.
+ */
+ static QString read(KDevPlugin *part, const QString &name, Policy p = Default);
+
+ /**
+ * Reads a template with the given URL
+ * and makes variable substitutions (like $AUTHOR$ etc.)
+ * in it. The resulting string is returned.
+ */
+ static QString readFile(KDevPlugin *part, const QString &fileName);
+
+ /**
+ * Makes variable substitutions on a text, based on a specified QDomDocument
+ * describing a KDevelop project file. The resulting string is returned.
+ */
+ static QString makeSubstitutions(QDomDocument &dom, const QString &text);
+
+ /**
+ * Copies a file template with the given name to the
+ * file with the name dest and - while copying -
+ * performs variable substitutions.
+ */
+ static bool copy(KDevPlugin *part, const QString &name,
+ const QString &dest, Policy p = Default);
+ /**
+ * Translates a template name into a full path, or suggests a full path
+ * for the template in the project directory if it doesn't exist.
+ */
+ static QString fullPathForName(KDevPlugin *part, const QString &name, Policy p = Default);
+};
+
+#endif