Kate
kateindentscriptabstracts.h
Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 #ifndef _KATEINDENTSCRIPTABSTRACTS_H_
00020 #define _KATEINDENTSCRIPTABSTRACTS_H_
00021 
00022 #include <qstring.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 QString& internalName,
00036         const QString  &filePath, const QString &niceName,
00037         const QString ©right, double version);
00038     virtual ~KateIndentScriptImplAbstract();
00039     
00040     virtual bool processChar( class Kate::View *view, QChar c, QString &errorMsg )=0;
00041     virtual bool processLine( class Kate::View *view, const KateDocCursor &line, QString &errorMsg )=0;
00042     virtual bool processNewline( class Kate::View *view, const KateDocCursor &begin, bool needcontinue, QString &errorMsg )=0;
00043   protected:
00044     virtual void decRef();
00045     long refCount() {return m_refcount;}
00046     QString filePath() const {return m_filePath;}
00047   private:
00048     void incRef();
00049     long m_refcount;
00050     QString m_internalName;
00051     QString m_filePath;
00052     QString m_niceName;
00053     QString 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     
00072     bool processChar( class Kate::View *view, QChar c, QString &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, QString &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, QString &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 QString &scriptname)=0;
00097 };
00098 
00099 #endif