lib

interpreter.h
1/***************************************************************************
2 * interpreter.h
3 * This file is part of the KDE project
4 * copyright (C)2004-2005 by Sebastian Sauer (mail@dipe.org)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this program; see the file COPYING. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 ***************************************************************************/
19
20#ifndef KROSS_API_INTERPRETER_H
21#define KROSS_API_INTERPRETER_H
22
23#include <tqstring.h>
24#include <tqmap.h>
25
26#include "object.h"
27
28namespace Kross { namespace Api {
29
30 // Forward declaration.
31 class Manager;
32 class ScriptContainer;
33 class Script;
34 class Interpreter;
35
41 class KOFFICE_EXPORT InterpreterInfo
42 {
43 public:
44
49 class Option
50 {
51 public:
52
56 typedef TQMap<TQString, Option*> Map;
57
66 Option(const TQString& name, const TQString& comment, const TQVariant& value)
68
70 TQString name;
71
73 TQString comment;
74
76 TQVariant value;
77 };
78
82 InterpreterInfo(const TQString& interpretername, const TQString& library, const TQString& wildcard, TQStringList mimetypes, Option::Map options);
83
88
92 const TQString getInterpretername();
93
100 const TQString getWildcard();
101
108 const TQStringList getMimeTypes();
109
113 bool hasOption(const TQString& key);
114
118 Option* getOption(const TQString name);
119
125 const TQVariant getOptionValue(const TQString name, TQVariant defaultvalue = TQVariant());
126
131
137
138 private:
140 TQString m_interpretername;
142 TQString m_library;
144 TQString m_wildcard;
146 TQStringList m_mimetypes;
148 Option::Map m_options;
150 Interpreter* m_interpreter;
151 };
152
162 class KOFFICE_EXPORT Interpreter
163 {
164 public:
165
173
177 virtual ~Interpreter();
178
187 virtual Script* createScript(ScriptContainer* scriptcontainer) = 0;
188
189 protected:
192 };
193
194}}
195
196#endif
197
Each interpreter is able to define options we could use to manipulate the interpreter behaviour.
Definition interpreter.h:50
TQString name
The short name of the option.
Definition interpreter.h:70
TQString comment
A description of the option.
Definition interpreter.h:73
TQVariant value
The value the option has.
Definition interpreter.h:76
Option(const TQString &name, const TQString &comment, const TQVariant &value)
Constructor.
Definition interpreter.h:66
TQMap< TQString, Option * > Map
Map of options.
Definition interpreter.h:56
While the Interpreter is the implemented interpreter this class is used to provide some abstract info...
Definition interpreter.h:42
const TQStringList getMimeTypes()
List of mimetypes this interpreter supports.
const TQString getWildcard()
Interpreter * getInterpreter()
const TQString getInterpretername()
InterpreterInfo(const TQString &interpretername, const TQString &library, const TQString &wildcard, TQStringList mimetypes, Option::Map options)
Constructor.
Option * getOption(const TQString name)
bool hasOption(const TQString &key)
const TQVariant getOptionValue(const TQString name, TQVariant defaultvalue=TQVariant())
Base class for interpreters.
InterpreterInfo * m_interpreterinfo
The InterpreterInfo instance this interpreter belongs to.
virtual Script * createScript(ScriptContainer *scriptcontainer)=0
Create and return a new interpreter dependend Script instance.
Interpreter(InterpreterInfo *info)
Constructor.
The Manager class is the main entry point to work with Kross.
Definition manager.h:55
The ScriptContainer class is something like a single standalone scriptfile.
Base class for interpreter dependend functionality each script provides.
Definition script.h:46
The common Kross API used as common codebase.
Definition callable.h:33
The Kross scripting bridge to embed scripting functionality into an application.
Definition callable.h:33