ldif.h
00001 /* 00002 This file is part of libtdeabc. 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 <tqstring.h> 00025 #include <tqcstring.h> 00026 #include <tqmemarray.h> 00027 00028 #include <tdelibs_export.h> 00029 00030 namespace TDEABC { 00031 00040 class KABC_EXPORT LDIF 00041 { 00042 public: 00043 00044 enum ParseVal{ None, NewEntry, EndEntry, Item, Control, Err, MoreData }; 00045 enum EntryType{ Entry_None, Entry_Add, Entry_Del, Entry_Mod, Entry_Modrdn }; 00046 enum ModType{ Mod_None, Mod_Add, Mod_Replace, Mod_Del }; 00047 LDIF(); 00048 virtual ~LDIF(); 00049 00058 static TQCString assembleLine( const TQString &fieldname, 00059 const TQByteArray &value, uint linelen=0, bool url=false ); 00064 static TQCString assembleLine( const TQString &fieldname, 00065 const TQCString &value, uint linelen=0, bool url=false ); 00070 static TQCString assembleLine( const TQString &fieldname, 00071 const TQString &value, uint linelen=0, bool url=false ); 00072 00077 static bool splitLine( const TQCString &line, TQString &fieldname, TQByteArray &value ); 00085 static bool splitControl( const TQCString &line, TQString &oid, bool &critical, 00086 TQByteArray &value ); 00090 void startParsing(); 00094 ParseVal processLine(); 00106 ParseVal nextItem(); 00111 void setLDIF( const TQByteArray &ldif ) { mLdif = ldif; mPos = 0; } 00116 void endLDIF(); 00120 EntryType entryType() const { return mEntryType; } 00124 int modType() const { return mModType; } 00128 const TQString& dn() const { return mDn; } 00132 const TQString& newRdn() const { return mNewRdn; } 00136 const TQString& newSuperior() const { return mNewSuperior; } 00140 bool delOldRdn() const { return mDelOldRdn; } 00144 const TQString& attr() const { return mAttr; } 00148 const TQByteArray& val() const { return mVal; } 00152 bool isUrl() const { return mUrl; } 00156 bool critical() const { return mCritical; } 00160 const TQString& oid() const { return mOid; } 00164 uint lineNo() const { return mLineNo; } 00165 private: 00166 int mModType; 00167 bool mDelOldRdn, mUrl; 00168 TQString mDn,mAttr,mNewRdn,mNewSuperior, mOid; 00169 TQByteArray mLdif, mVal; 00170 EntryType mEntryType; 00171 00172 bool mIsNewLine, mIsComment,mCritical; 00173 ParseVal mLastParseVal; 00174 uint mPos,mLineNo; 00175 TQCString line; 00176 00177 class LDIFPrivate; 00178 LDIFPrivate *d; 00179 }; 00180 } 00181 00182 #endif