#include <ldif.h>
This class supports LDIF attribute mapping, and a heuristics mechanism for parsing LDIF fields that may not have consistent data.
To use this class, create an instance of it, then call DumpLdif(), passing the Contact record object to base the work on. Output will be written to the stream you provide. ReadLdif() goes in the other direction.
To override LDIF attribute mapping, call Map() or Unmap() as appropriate.
To get a list of supported Barry::Contact field names, call GetFieldNames(). This function returns a pointer to an array of ContactLdif::NameToFunc structures, ending with NameToFunc::name as null. You can cycle through the array with code like this:
for( ContactLdif::NameToFunc *n = o.GetFieldNames(); n->name; n++ ) { ... }
Note that all Get/Set functions used in attribute mapping are virtual, and can be overridden by a derived class. This includes the heuristics functions, which are called by DumpLdif().
Definition at line 64 of file ldif.h.
Public Types | |
typedef std::string(ContactLdif::*) | GetFunctionType (const Barry::Contact &) const |
typedef void(ContactLdif::*) | SetFunctionType (Barry::Contact &, const std::string &) const |
typedef std::map< LdifAttribute, AccessPair > | AccessMapType |
typedef std::map< std::string, std::string * > | HookMapType |
Public Member Functions | |
ContactLdif (const std::string &baseDN) | |
virtual | ~ContactLdif () |
const NameToFunc * | GetFieldNames () const |
const NameToFunc * | GetField (const std::string &fieldname) const |
std::string | GetFieldReadName (GetFunctionType read) const |
std::string | GetFieldWriteName (SetFunctionType write) const |
bool | Map (const LdifAttribute &ldifname, const std::string &readField, const std::string &writeField) |
void | Map (const LdifAttribute &ldifname, GetFunctionType read, SetFunctionType write) |
void | Unmap (const LdifAttribute &ldifname) |
void | SetBaseDN (const std::string &baseDN) |
bool | SetDNAttr (const LdifAttribute &name) |
Sets the LDIF attribute name to use when constructing the FQDN. | |
bool | SetObjectClass (const LdifAttribute &name, const std::string &objectClass) |
bool | SetObjectOrder (const LdifAttribute &name, int order) |
virtual std::string | Email (const Barry::Contact &con) const |
virtual std::string | Phone (const Barry::Contact &con) const |
virtual std::string | Fax (const Barry::Contact &con) const |
virtual std::string | WorkPhone (const Barry::Contact &con) const |
virtual std::string | HomePhone (const Barry::Contact &con) const |
virtual std::string | MobilePhone (const Barry::Contact &con) const |
virtual std::string | Pager (const Barry::Contact &con) const |
virtual std::string | PIN (const Barry::Contact &con) const |
virtual std::string | FirstName (const Barry::Contact &con) const |
virtual std::string | LastName (const Barry::Contact &con) const |
virtual std::string | Company (const Barry::Contact &con) const |
virtual std::string | DefaultCommunicationsMethod (const Barry::Contact &con) const |
virtual std::string | Address1 (const Barry::Contact &con) const |
virtual std::string | Address2 (const Barry::Contact &con) const |
virtual std::string | Address3 (const Barry::Contact &con) const |
virtual std::string | City (const Barry::Contact &con) const |
virtual std::string | Province (const Barry::Contact &con) const |
virtual std::string | PostalCode (const Barry::Contact &con) const |
virtual std::string | Country (const Barry::Contact &con) const |
virtual std::string | JobTitle (const Barry::Contact &con) const |
virtual std::string | PublicKey (const Barry::Contact &con) const |
virtual std::string | Notes (const Barry::Contact &con) const |
virtual std::string | PostalAddress (const Barry::Contact &con) const |
virtual std::string | FullName (const Barry::Contact &con) const |
virtual std::string | FQDN (const Barry::Contact &con) const |
virtual bool | IsArrayFunc (GetFunctionType getf) const |
void | ClearArrayState () const |
virtual void | SetEmail (Barry::Contact &con, const std::string &val) const |
virtual void | SetPhone (Barry::Contact &con, const std::string &val) const |
virtual void | SetFax (Barry::Contact &con, const std::string &val) const |
virtual void | SetWorkPhone (Barry::Contact &con, const std::string &val) const |
virtual void | SetHomePhone (Barry::Contact &con, const std::string &val) const |
virtual void | SetMobilePhone (Barry::Contact &con, const std::string &val) const |
virtual void | SetPager (Barry::Contact &con, const std::string &val) const |
virtual void | SetPIN (Barry::Contact &con, const std::string &val) const |
virtual void | SetFirstName (Barry::Contact &con, const std::string &val) const |
virtual void | SetLastName (Barry::Contact &con, const std::string &val) const |
virtual void | SetCompany (Barry::Contact &con, const std::string &val) const |
virtual void | SetDefaultCommunicationsMethod (Barry::Contact &con, const std::string &val) const |
virtual void | SetAddress1 (Barry::Contact &con, const std::string &val) const |
virtual void | SetAddress2 (Barry::Contact &con, const std::string &val) const |
virtual void | SetAddress3 (Barry::Contact &con, const std::string &val) const |
virtual void | SetCity (Barry::Contact &con, const std::string &val) const |
virtual void | SetProvince (Barry::Contact &con, const std::string &val) const |
virtual void | SetPostalCode (Barry::Contact &con, const std::string &val) const |
virtual void | SetCountry (Barry::Contact &con, const std::string &val) const |
virtual void | SetJobTitle (Barry::Contact &con, const std::string &val) const |
virtual void | SetPublicKey (Barry::Contact &con, const std::string &val) const |
virtual void | SetNotes (Barry::Contact &con, const std::string &val) const |
virtual void | SetPostalAddress (Barry::Contact &con, const std::string &val) const |
virtual void | SetFullName (Barry::Contact &con, const std::string &val) const |
virtual void | SetFQDN (Barry::Contact &con, const std::string &val) const |
virtual void | ClearHeuristics () |
virtual bool | RunHeuristics (Barry::Contact &con) |
void | DumpLdif (std::ostream &os, const Barry::Contact &contact) const |
Output contact data to os in LDAP LDIF format. | |
bool | ReadLdif (std::istream &is, Barry::Contact &contact) |
void | DumpMap (std::ostream &os) const |
Static Public Member Functions | |
static std::string | MakeLdifData (const std::string &str) |
static bool | NeedsEncoding (const std::string &str) |
Protected Member Functions | |
void | DoWrite (Barry::Contact &con, const std::string &attr, const std::string &data) |
void | Hook (const std::string &ldifname, std::string *var) |
Protected Attributes | |
AccessMapType | m_map |
std::string | m_baseDN |
HookMapType | m_hookMap |
LdifAttribute | m_dnAttr |
unsigned int | m_emailIndex |
std::string | m_cn |
std::string | m_displayName |
std::string | m_sn |
std::string | m_givenName |
Static Protected Attributes | |
static const NameToFunc | FieldMap [] |
Classes | |
struct | AccessPair |
struct | LdifAttribute |
struct | NameToFunc |
Used to create a List of supported Barry field names, including calculated names, such as full postal address. More... |
bool Barry::ContactLdif::SetDNAttr | ( | const LdifAttribute & | name | ) |
void Barry::ContactLdif::DumpLdif | ( | std::ostream & | os, | |
const Barry::Contact & | contact | |||
) | const |
Output contact data to os in LDAP LDIF format.
Definition at line 616 of file ldif.cc.
References ClearArrayState(), FirstName(), FullName(), Barry::Contact::GetID(), IsArrayFunc(), LastName(), m_map, and MakeLdifData().
Referenced by Contact2Ldif::operator()().