maint: added make-apt.sh to create signed apt repositories
[barry/progweb.git] / src / ldifio.h
blob7fceb5aabfb1ccaaa167c5640cd3f3690a589a0f
1 ///
2 /// \file ldifio.h
3 /// Storage, parser, and builder classes for ldif operations.
4 ///
6 /*
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__
25 #include "dll.h"
26 #include "ldif.h"
27 #include <memory>
28 #include <iostream>
29 #include <fstream>
31 namespace Barry {
33 class Builder;
36 // LdifStore
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.
41 ///
42 /// Examples:
43 /// Read contacts from an ldif stream on stdin:
44 /// new RecordBuilder<Contact, LdifStore>( new LdifStore(cin) );
45 ///
46 /// Write contacts to an ldif stream on stdout:
47 /// new RecordParser<Contact, LdifStore>(
48 /// new LdifStore(cout, baseDN, dnAttr) );
49 ///
50 class BXEXPORT LdifStore
52 std::auto_ptr<std::ifstream> m_ifs;
53 std::auto_ptr<std::ofstream> m_ofs;
54 std::istream &m_is;
55 std::ostream &m_os;
56 bool m_end_of_file;
58 Barry::ContactLdif m_ldif;
60 public:
61 // input constructors
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);
71 // storage operator
72 void operator() (const Contact &rec);
74 // retrieval operator
75 bool operator() (Contact &rec, const Builder &builder);
80 #endif