Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "ldifio.h"
00023
00024 namespace Barry {
00025
00026 LdifStore::LdifStore(const std::string &filename)
00027 : m_ifs( new std::ifstream(filename.c_str()) )
00028 , m_is(*m_ifs)
00029 , m_os(*m_ofs)
00030
00031 , m_end_of_file(false)
00032 , m_ldif("")
00033 {
00034 }
00035
00036 LdifStore::LdifStore(std::istream &is)
00037 : m_is(is)
00038 , m_os(*m_ofs)
00039 , m_end_of_file(false)
00040 , m_ldif("")
00041 {
00042 }
00043
00044
00045 LdifStore::LdifStore(const std::string &filename,
00046 const std::string &baseDN,
00047 const std::string &dnattr)
00048 : m_ofs( new std::ofstream(filename.c_str()) )
00049 , m_is(*m_ifs)
00050 , m_os(*m_ofs)
00051 , m_end_of_file(false)
00052 , m_ldif(baseDN)
00053 {
00054 m_ldif.SetDNAttr(dnattr);
00055 }
00056
00057 LdifStore::LdifStore(std::ostream &os,
00058 const std::string &baseDN,
00059 const std::string &dnattr)
00060 : m_is(*m_ifs)
00061 , m_os(os)
00062 , m_end_of_file(false)
00063 , m_ldif(baseDN)
00064 {
00065 m_ldif.SetDNAttr(dnattr);
00066 }
00067
00068
00069 void LdifStore::operator() (const Contact &rec)
00070 {
00071 m_ldif.DumpLdif(m_os, rec);
00072 }
00073
00074
00075 bool LdifStore::operator() (Contact &rec, const Barry::Builder &builder)
00076 {
00077 if( m_end_of_file )
00078 return false;
00079
00080
00081
00082
00083 while( m_is ) {
00084 if( m_ldif.ReadLdif(m_is, rec) )
00085 return true;
00086 }
00087
00088 m_end_of_file = true;
00089 return false;
00090 }
00091
00092 }
00093