00001
00002
00003
00004
00005
00006
00007 #ifndef LDIF_READER_H
00008 #define LDIF_READER_H
00009
00010 #include <LDAPEntry.h>
00011 #include <iosfwd>
00012 #include <list>
00013
00014 typedef std::list< std::pair<std::string, std::string> > LdifRecord;
00015 class LdifReader
00016 {
00017 public:
00018 LdifReader( std::istream &input );
00019
00020 inline bool isEntryRecords() const
00021 {
00022 return !m_ldifTypeRequest;
00023 }
00024
00025 inline bool isChangeRecords() const
00026 {
00027 return m_ldifTypeRequest;
00028 }
00029
00030 inline int getVersion() const
00031 {
00032 return m_version;
00033 }
00034
00035 LDAPEntry getEntryRecord();
00036 int readNextRecord( bool first=false );
00037
00038
00039 private:
00040 int getLdifLine(std::string &line);
00041
00042 void splitLine(const std::string& line,
00043 std::string &type,
00044 std::string &value ) const;
00045
00046 std::string readIncludeLine( const std::string &line) const;
00047
00048 std::istream &m_ldifstream;
00049 LdifRecord m_currentRecord;
00050 int m_version;
00051 int m_curRecType;
00052 int m_lineNumber;
00053 bool m_ldifTypeRequest;
00054 bool m_currentIsFirst;
00055 };
00056
00057 #endif