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 "koscript_context.h"
00031 #include "koscript_parsenode.h"
00032 #include "koscript_ptr.h"
00033 #include "koscript_value.h"
00034 
00035 class QTextStream;
00036 class QIODevice;
00037 
00045 class KSInterpreter : public QShared
00046 {
00047 public:
00048   typedef KSSharedPtr<KSInterpreter> Ptr;
00049 
00054   KSInterpreter();
00058   virtual ~KSInterpreter();
00059 
00068   QString runScript( const QString& filename, const QStringList& args );
00069 
00081   bool runModule( KSContext& context, const QString& name, const QString& filename, const QStringList& args );
00082 
00088   bool runModule( KSContext& context, const QString& name );
00093   KSModule::Ptr module( const QString& name );
00094 
00100   KSContext& context() { return m_globalContext; }
00101 
00107   void addSearchPath( const QString& p ) { m_searchPaths.prepend( p ); }
00108 
00116   virtual bool processExtension( KSContext& context, KSParseNode* node );
00117 
00121   KRegExp* regexp();
00122 
00126   QString readInput();
00127 
00131   KSValue::Ptr lastInputLine() const;
00132 
00137   KSNamespace* globalNamespace() { return m_global; }
00138 
00139 protected:
00143   KSNamespace* m_global;
00148   KSContext m_globalContext;
00154   QMap<QString,KSModule::Ptr> m_modules;
00158   QStringList m_searchPaths;
00162   KRegExp m_regexp;
00167   QStringList m_args;
00175   int m_currentArg;
00181   QTextStream* m_outStream;
00185   QIODevice* m_outDevice;
00191   KSValue::Ptr m_lastInputLine;
00192 };
00193 
00194 #endif
KDE Logo
This file is part of the documentation for lib Library Version 1.3.5.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Mar 11 11:47:43 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003