1 /* $NetBSD: LdifReader.h,v 1.3 2021/08/14 16:14:49 christos Exp $ */ 2 3 // $OpenLDAP$ 4 /* 5 * Copyright 2008-2021 The OpenLDAP Foundation, All Rights Reserved. 6 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file 7 */ 8 9 #ifndef LDIF_READER_H 10 #define LDIF_READER_H 11 12 #include <LDAPEntry.h> 13 #include <iosfwd> 14 #include <list> 15 16 typedef std::list< std::pair<std::string, std::string> > LdifRecord; 17 class LdifReader 18 { 19 public: 20 LdifReader( std::istream &input ); 21 isEntryRecords()22 inline bool isEntryRecords() const 23 { 24 return !m_ldifTypeRequest; 25 } 26 isChangeRecords()27 inline bool isChangeRecords() const 28 { 29 return m_ldifTypeRequest; 30 } 31 getVersion()32 inline int getVersion() const 33 { 34 return m_version; 35 } 36 37 LDAPEntry getEntryRecord(); 38 int readNextRecord( bool first=false ); 39 //LDAPRequest getChangeRecord(); 40 41 private: 42 int getLdifLine(std::string &line); 43 44 void splitLine(const std::string& line, 45 std::string &type, 46 std::string &value ) const; 47 48 std::string readIncludeLine( const std::string &line) const; 49 50 std::istream &m_ldifstream; 51 LdifRecord m_currentRecord; 52 int m_version; 53 int m_curRecType; 54 int m_lineNumber; 55 bool m_ldifTypeRequest; 56 bool m_currentIsFirst; 57 }; 58 59 #endif /* LDIF_READER_H */ 60