2008-03-28 07:05:10 -04:00
|
|
|
// $OpenLDAP$
|
2008-03-17 12:08:51 -04:00
|
|
|
/*
|
2017-01-03 15:36:47 -05:00
|
|
|
* Copyright 2008-2017 The OpenLDAP Foundation, All Rights Reserved.
|
2008-03-17 12:08:51 -04:00
|
|
|
* 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 );
|
2008-03-20 09:24:49 -04:00
|
|
|
|
|
|
|
|
inline bool isEntryRecords() const
|
|
|
|
|
{
|
|
|
|
|
return !m_ldifTypeRequest;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool isChangeRecords() const
|
|
|
|
|
{
|
|
|
|
|
return m_ldifTypeRequest;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline int getVersion() const
|
|
|
|
|
{
|
|
|
|
|
return m_version;
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-17 12:08:51 -04:00
|
|
|
LDAPEntry getEntryRecord();
|
2008-03-20 09:24:49 -04:00
|
|
|
int readNextRecord( bool first=false );
|
|
|
|
|
//LDAPRequest getChangeRecord();
|
2008-03-17 12:08:51 -04:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int getLdifLine(std::string &line);
|
|
|
|
|
|
2008-03-20 12:10:37 -04:00
|
|
|
void splitLine(const std::string& line,
|
2008-03-17 12:08:51 -04:00
|
|
|
std::string &type,
|
2008-03-20 12:10:37 -04:00
|
|
|
std::string &value ) const;
|
2008-03-17 12:08:51 -04:00
|
|
|
|
|
|
|
|
std::string readIncludeLine( const std::string &line) const;
|
|
|
|
|
|
|
|
|
|
std::istream &m_ldifstream;
|
|
|
|
|
LdifRecord m_currentRecord;
|
2008-03-20 09:24:49 -04:00
|
|
|
int m_version;
|
2008-03-17 12:08:51 -04:00
|
|
|
int m_curRecType;
|
2008-03-20 12:10:37 -04:00
|
|
|
int m_lineNumber;
|
2008-03-20 09:24:49 -04:00
|
|
|
bool m_ldifTypeRequest;
|
|
|
|
|
bool m_currentIsFirst;
|
2008-03-17 12:08:51 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif /* LDIF_READER_H */
|