LdifReader.h 1.28 KB
Newer Older
1
// $OpenLDAP$
2
/*
Quanah Gibson-Mount's avatar
Quanah Gibson-Mount committed
3
 * Copyright 2008-2018 The OpenLDAP Foundation, All Rights Reserved.
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 * 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 );
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

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

        inline bool isChangeRecords() const
        {
            return m_ldifTypeRequest;
        }

        inline int getVersion() const
        {
            return m_version;
        }

35
        LDAPEntry getEntryRecord();
36
37
        int readNextRecord( bool first=false );
        //LDAPRequest getChangeRecord();
38
39
40
41

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

Quanah Gibson-Mount's avatar
Quanah Gibson-Mount committed
42
        void splitLine(const std::string& line, 
43
                    std::string &type,
Quanah Gibson-Mount's avatar
Quanah Gibson-Mount committed
44
                    std::string &value ) const;
45
46
47
48
49

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

        std::istream &m_ldifstream;
        LdifRecord m_currentRecord;
50
        int m_version;
51
        int m_curRecType;
Quanah Gibson-Mount's avatar
Quanah Gibson-Mount committed
52
        int m_lineNumber;
53
54
        bool m_ldifTypeRequest;
        bool m_currentIsFirst;
55
56
57
};

#endif /* LDIF_READER_H */