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