summaryrefslogtreecommitdiffstats
path: root/contrib/ldapc++/src/LdifReader.h
blob: 5217338f0ea7c7216ff985238045d66fe297a8ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// $OpenLDAP$
/*
 * Copyright 2008-2018 The OpenLDAP Foundation, All Rights Reserved.
 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 */

#ifndef LDIF_READER_H
#define LDIF_READER_H

#include <LDAPEntry.h>
#include <iosfwd>
#include <list>

typedef std::list< std::pair<std::string, std::string> > LdifRecord;
class LdifReader
{
    public:
        LdifReader( std::istream &input );

        inline bool isEntryRecords() const
        {
            return !m_ldifTypeRequest;
        }

        inline bool isChangeRecords() const
        {
            return m_ldifTypeRequest;
        }

        inline int getVersion() const
        {
            return m_version;
        }

        LDAPEntry getEntryRecord();
        int readNextRecord( bool first=false );
        //LDAPRequest getChangeRecord();

    private:
        int getLdifLine(std::string &line);

        void splitLine(const std::string& line, 
                    std::string &type,
                    std::string &value ) const;

        std::string readIncludeLine( const std::string &line) const;

        std::istream &m_ldifstream;
        LdifRecord m_currentRecord;
        int m_version;
        int m_curRecType;
        int m_lineNumber;
        bool m_ldifTypeRequest;
        bool m_currentIsFirst;
};

#endif /* LDIF_READER_H */