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