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