3 /// Storage, parser, and builder classes for ldif operations.
7 Copyright (C) 2010-2011, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #ifndef __BARRY_LDIFIO_H__
23 #define __BARRY_LDIFIO_H__
38 /// Storage class suitable for use in a RecordParser<> or RecordBuilder<>.
39 /// Be sure to use the input constructors for RecordBuilder<> objects
40 /// and output constructors for RecordParser<> objects.
43 /// Read contacts from an ldif stream on stdin:
44 /// new RecordBuilder<Contact, LdifStore>( new LdifStore(cin) );
46 /// Write contacts to an ldif stream on stdout:
47 /// new RecordParser<Contact, LdifStore>(
48 /// new LdifStore(cout, baseDN, dnAttr) );
50 class BXEXPORT LdifStore
52 std::auto_ptr
<std::ifstream
> m_ifs
;
53 std::auto_ptr
<std::ofstream
> m_ofs
;
58 Barry::ContactLdif m_ldif
;
62 LdifStore(const std::string
&filename
);
63 LdifStore(std::istream
&is
);
65 // output constructors
66 LdifStore(const std::string
&filename
, const std::string
&baseDN
,
67 const std::string
&dnattr
);
68 LdifStore(std::ostream
&os
, const std::string
&baseDN
,
69 const std::string
&dnattr
);
72 void operator() (const Contact
&rec
);
75 bool operator() (Contact
&rec
, const Builder
&builder
);