kateindentscriptabstracts.h
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2005 Joseph Wenninger <jowenn@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 version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 00017 */ 00018 00019 #ifndef _KATEINDENTSCRIPTABSTRACTS_H_ 00020 #define _KATEINDENTSCRIPTABSTRACTS_H_ 00021 00022 #include <tqstring.h> 00023 #include <kdebug.h> 00024 00025 namespace Kate { 00026 class View; 00027 } 00028 00029 class KateDocCursor; 00030 00031 00032 class KateIndentScriptImplAbstract { 00033 public: 00034 friend class KateIndentScript; 00035 KateIndentScriptImplAbstract(const TQString& internalName, 00036 const TQString &filePath, const TQString &niceName, 00037 const TQString ©right, double version); 00038 virtual ~KateIndentScriptImplAbstract(); 00039 00040 virtual bool processChar( class Kate::View *view, TQChar c, TQString &errorMsg )=0; 00041 virtual bool processLine( class Kate::View *view, const KateDocCursor &line, TQString &errorMsg )=0; 00042 virtual bool processNewline( class Kate::View *view, const KateDocCursor &begin, bool needcontinue, TQString &errorMsg )=0; 00043 protected: 00044 virtual void decRef(); 00045 long refCount() {return m_refcount;} 00046 TQString filePath() const {return m_filePath;} 00047 private: 00048 void incRef(); 00049 long m_refcount; 00050 TQString m_internalName; 00051 TQString m_filePath; 00052 TQString m_niceName; 00053 TQString m_copyright; 00054 double m_version; 00055 }; 00056 00057 00058 class KateIndentScript { 00059 public: 00060 KateIndentScript(KateIndentScriptImplAbstract *scr):m_scr(scr) { if (scr) scr->incRef(); } 00061 ~KateIndentScript() {if (m_scr) m_scr->decRef();} 00062 KateIndentScript():m_scr(0) {} 00063 KateIndentScript(const KateIndentScript &p):m_scr(p.m_scr){if (m_scr) m_scr->incRef();} 00064 KateIndentScript &operator=(const KateIndentScript &p) { 00065 if (m_scr==p.m_scr) return *this; 00066 if (m_scr) m_scr->decRef(); 00067 m_scr=p.m_scr; 00068 if (m_scr) m_scr->incRef(); 00069 return *this; 00070 } 00071 /*operator KateIndentJScript*() const { return m_scr; }*/ 00072 bool processChar( class Kate::View *view, TQChar c, TQString &errorMsg ) { 00073 kdDebug(13050)<<"KateIndentScript::processChar: m_scr:"<<m_scr<<endl; 00074 if (m_scr) return m_scr->processChar(view,c,errorMsg); else return true; 00075 } 00076 bool processLine( class Kate::View *view, const KateDocCursor& line, TQString &errorMsg ) { 00077 kdDebug(13050)<<"KateIndentScript::processLine: m_scr:"<<m_scr<<endl; 00078 if (m_scr) return m_scr->processLine(view,line,errorMsg); else return true; 00079 } 00080 bool processNewline( class Kate::View *view, const KateDocCursor& begin, bool needcontinue, TQString &errorMsg ) { 00081 kdDebug(13050)<<"KateIndentScript::processNewLine: m_scr:"<<m_scr<<endl; 00082 if (m_scr) return m_scr->processNewline(view,begin,needcontinue,errorMsg); else return true; 00083 } 00084 00085 bool isNull () const {return (m_scr==0);} 00086 private: 00087 KateIndentScriptImplAbstract *m_scr; 00088 }; 00089 00090 class KateIndentScriptManagerAbstract 00091 { 00092 00093 public: 00094 KateIndentScriptManagerAbstract () {}; 00095 virtual ~KateIndentScriptManagerAbstract () {}; 00096 virtual KateIndentScript script(const TQString &scriptname)=0; 00097 }; 00098 00099 #endif