ldif.h

00001 /*
00002     This file is part of libkabc.
00003     Copyright (c) 2004 Szombathelyi Gyorgy <gyurco@freemail.hu>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General  Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018     Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef _K_LDIF_H_
00022 #define _K_LDIF_H_
00023 
00024 #include <qstring.h>
00025 #include <qcstring.h>
00026 #include <qmemarray.h>
00027 
00028 #include <kdelibs_export.h>
00029 
00030 namespace KABC {
00031 
00040   class KABC_EXPORT LDIF 
00041   {
00042   public:
00043 
00044     typedef enum ParseVal{ None, NewEntry, EndEntry, Item, Control, Err, MoreData };
00045     typedef enum EntryType{ Entry_None, Entry_Add, Entry_Del, Entry_Mod, Entry_Modrdn };
00046     typedef enum ModType{ Mod_None, Mod_Add, Mod_Replace, Mod_Del };
00047     LDIF();
00048     virtual ~LDIF();
00049     
00058     static QCString assembleLine( const QString &fieldname, 
00059       const QByteArray &value, uint linelen=0, bool url=false );
00064     static QCString assembleLine( const QString &fieldname, 
00065       const QCString &value, uint linelen=0, bool url=false );
00070     static QCString assembleLine( const QString &fieldname, 
00071       const QString &value, uint linelen=0, bool url=false );
00072       
00077     static bool splitLine( const QCString &line, QString &fieldname, QByteArray &value );
00085     static bool splitControl( const QCString &line, QString &oid, bool &critical,
00086       QByteArray &value );
00090     void startParsing();
00094     ParseVal processLine();
00106     ParseVal nextItem();
00111     void setLDIF( const QByteArray &ldif ) { mLdif = ldif; mPos = 0; };
00116     void endLDIF();
00120     EntryType entryType() const { return mEntryType; }
00124     int modType() const { return mModType; }
00128     const QString& dn() const { return mDn; }
00132     const QString& newRdn() const { return mNewRdn; }
00136     const QString& newSuperior() const { return mNewSuperior; }
00140     bool delOldRdn() const { return mDelOldRdn; }
00144     const QString& attr() const { return mAttr; }
00148     const QByteArray& val() const { return mVal; }
00152     bool isUrl() const { return mUrl; }
00156     bool critical() const { return mCritical; }
00160     const QString& oid() const { return mOid; }
00164     uint lineNo() const { return mLineNo; }
00165   private:
00166     int mModType;
00167     bool mDelOldRdn, mUrl;
00168     QString mDn,mAttr,mNewRdn,mNewSuperior, mOid;
00169     QByteArray mLdif, mVal;
00170     EntryType mEntryType;
00171     
00172     bool mIsNewLine, mIsComment,mCritical;
00173     ParseVal mLastParseVal;
00174     uint mPos,mLineNo;  
00175     QCString line;
00176         
00177     class LDIFPrivate;
00178     LDIFPrivate *d;
00179   };
00180 }
00181 
00182 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys