lib Library API Documentation

koscript.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 1998, 1999, 2000 Torben Weis <weis@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017    Boston, MA 02111-1307, USA.
00018 */
00019 
00020 #ifndef __KSCRIPT_H__
00021 #define __KSCRIPT_H__
00022 
00023 #include <qstring.h>
00024 #include <qmap.h>
00025 #include <qshared.h>
00026 #include <qstringlist.h>
00027 
00028 #include <kregexp.h>
00029 
00030 #include <../kofficecore/koffice_export.h>
00031 
00032 #include "koscript_context.h"
00033 #include "koscript_parsenode.h"
00034 #include "koscript_ptr.h"
00035 #include "koscript_value.h"
00036 
00037 class QTextStream;
00038 class QIODevice;
00039 
00047 class KOSCRIPT_EXPORT KSInterpreter : public QShared
00048 {
00049 public:
00050   typedef KSSharedPtr<KSInterpreter> Ptr;
00051 
00056   KSInterpreter();
00060   virtual ~KSInterpreter();
00061 
00071   QString runScript( const QString& filename, const QStringList& args );
00072 
00086   bool runModule( KSContext& context, const QString& name, const QString& filename, const QStringList& args );
00087 
00093   bool runModule( KSContext& context, const QString& name );
00098   KSModule::Ptr module( const QString& name );
00099 
00105   KSContext& context() { return m_globalContext; }
00106 
00112   void addSearchPath( const QString& p ) { m_searchPaths.prepend( p ); }
00113 
00121   virtual bool processExtension( KSContext& context, KSParseNode* node );
00122 
00126   KRegExp* regexp();
00127 
00131   QString readInput();
00132 
00136   KSValue::Ptr lastInputLine() const;
00137 
00142   KSNamespace* globalNamespace() { return m_global; }
00143 
00144 protected:
00148   KSNamespace* m_global;
00153   KSContext m_globalContext;
00159   QMap<QString,KSModule::Ptr> m_modules;
00163   QStringList m_searchPaths;
00167   KRegExp m_regexp;
00172   QStringList m_args;
00180   int m_currentArg;
00186   QTextStream* m_outStream;
00190   QIODevice* m_outDevice;
00196   KSValue::Ptr m_lastInputLine;
00197 };
00198 
00199 #endif
KDE Logo
This file is part of the documentation for lib Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:40:05 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003