LDAPAttribute Class Reference

Represents the name an value(s) of an Attribute. More...

#include <LDAPAttribute.h>

List of all members.

Public Member Functions

 LDAPAttribute ()
 Default constructor.
 LDAPAttribute (const LDAPAttribute &attr)
 Copy constructor.
 LDAPAttribute (const std::string &name, const std::string &value="")
 Construct an Attribute with a single string value.
 LDAPAttribute (const char *name, char **values)
 Construct an attribute with multiple string values.
 LDAPAttribute (const std::string &name, const StringList &values)
 Construct an attribute with multiple string values.
 LDAPAttribute (const char *name, BerValue **values)
 Construct an attribute with multiple binary coded values.
 ~LDAPAttribute ()
 Destructor.
void addValue (const std::string &value)
 Add a single string value(bin/char) to the Attribute.
int addValue (const BerValue *value)
 Add a single binary value to the Attribute.
int setValues (char **values)
 Set the values of the attribute.
int setValues (BerValue **values)
 Set the values of the attribute.
void setValues (const StringList &values)
 Set the values of the attribute.
BerValue ** getBerValues () const
 For interal use only.
const StringListgetValues () const
int getNumValues () const
const std::string & getName () const
void setName (const std::string &name)
 Sets the Attribute's name (type).
LDAPMod * toLDAPMod () const
 For internal use only.
bool isNotPrintable () const

Friends

std::ostream & operator<< (std::ostream &s, const LDAPAttribute &attr)
 This method can be used to dump the data of a LDAPResult-Object.

Detailed Description

Represents the name an value(s) of an Attribute.


Constructor & Destructor Documentation

LDAPAttribute::LDAPAttribute (  ) 

Default constructor.

initializes an empty object.

References DEBUG, and LDAP_DEBUG_CONSTRUCT.

LDAPAttribute::LDAPAttribute ( const LDAPAttribute attr  ) 

Copy constructor.

Copies all values of an Attribute to a new one

Parameters:
attr The Attribute that should be copied

References DEBUG, LDAP_DEBUG_CONSTRUCT, and LDAP_DEBUG_PARAMETER.

LDAPAttribute::LDAPAttribute ( const std::string &  name,
const std::string &  value = "" 
)

Construct an Attribute with a single string value.

Parameters:
name The attribute's name (type)
value The string value of the attribute, if "" the attribute will have no values, for LDAPv3 this values must be UTF-8 encoded
LDAPAttribute::LDAPAttribute ( const char *  name,
char **  values 
)

Construct an attribute with multiple string values.

Parameters:
name The attribute's name (type)
values A 0-terminated array of char*. Each char* specifies one value of the attribute (UTF-8 encoded)

References DEBUG, LDAP_DEBUG_CONSTRUCT, LDAP_DEBUG_PARAMETER, setName(), and setValues().

LDAPAttribute::LDAPAttribute ( const std::string &  name,
const StringList values 
)

Construct an attribute with multiple string values.

Parameters:
name The attribute's name (type)
values A list of strings. Each element specifies one value of the attribute (UTF-8 or binary encoded)
LDAPAttribute::LDAPAttribute ( const char *  name,
BerValue **  values 
)

Construct an attribute with multiple binary coded values.

Parameters:
name The attribute's name (type)
values 0-terminated array of binary attribute values The BerValue struct is declared as:
struct berval{ unsigned long bv_len; char *bv_val; } BerValue;

References DEBUG, LDAP_DEBUG_CONSTRUCT, LDAP_DEBUG_PARAMETER, setName(), and setValues().

LDAPAttribute::~LDAPAttribute (  ) 

Destructor.

References DEBUG, and LDAP_DEBUG_DESTROY.


Member Function Documentation

int LDAPAttribute::addValue ( const BerValue *  value  ) 

Add a single binary value to the Attribute.

Parameters:
value The binary coded value that should be added to the Attribute.
Returns:
0 no problem
-1 failure (mem. allocation problem)

References addValue(), DEBUG, and LDAP_DEBUG_TRACE.

void LDAPAttribute::addValue ( const std::string &  value  ) 

Add a single string value(bin/char) to the Attribute.

Parameters:
value Value that should be added, it is copied inside the object

Referenced by addValue(), LdifReader::getEntryRecord(), and setValues().

BerValue ** LDAPAttribute::getBerValues (  )  const

For interal use only.

This method is used to translate the values of the Attribute to 0-terminated Array of BerValue-structs as used by the C-API

Returns:
The Values of the Attribute as an 0-terminated Array of BerValue* (is dynamically allocated, delete it after usage)
0-pointer in case of error

References StringList::begin(), DEBUG, StringList::end(), LDAP_DEBUG_TRACE, and StringList::size().

Referenced by LDAPCompareRequest::sendRequest(), and toLDAPMod().

const string & LDAPAttribute::getName (  )  const
int LDAPAttribute::getNumValues (  )  const
Returns:
The number of values of the attribute

References DEBUG, LDAP_DEBUG_TRACE, and StringList::size().

const StringList & LDAPAttribute::getValues (  )  const
Returns:
The values of the array as a list of strings

References DEBUG, and LDAP_DEBUG_TRACE.

Referenced by LDAPAttributeList::addAttribute().

bool LDAPAttribute::isNotPrintable (  )  const
Returns:
true If the attribute contains non-printable attributes

References StringList::begin(), and StringList::end().

Referenced by operator<<().

void LDAPAttribute::setName ( const std::string &  name  ) 

Sets the Attribute's name (type).

Parameters:
the new name of the object

Referenced by LDAPAttribute().

void LDAPAttribute::setValues ( const StringList values  ) 

Set the values of the attribute.

If the object does already contain some values, they will be deleted

Parameters:
values A list of string-Objects. Each string is representing a string or binary value to add to the entry

References DEBUG, and LDAP_DEBUG_TRACE.

int LDAPAttribute::setValues ( BerValue **  values  ) 

Set the values of the attribute.

If the object does already contain some values, they will be deleted

Parameters:
values 0-terminated array of BerValue*, each BerValue representing a binary value to add to the entry
Returns:
0 no problem
-1 failure (mem. allocation problem)

References addValue(), StringList::clear(), DEBUG, and LDAP_DEBUG_TRACE.

int LDAPAttribute::setValues ( char **  values  ) 

Set the values of the attribute.

If the object contains some values already, they are deleted

Parameters:
values 0-terminated array of char*, each char* representing a string value to add to the entry
Returns:
0 no problem
-1 failure (mem. allocation problem)

References addValue(), StringList::clear(), DEBUG, and LDAP_DEBUG_TRACE.

Referenced by LDAPAttribute().

LDAPMod * LDAPAttribute::toLDAPMod (  )  const

For internal use only.

This method translate the attribute of the object into a LDAPMod-Structure as used by the C-API

References DEBUG, getBerValues(), and LDAP_DEBUG_TRACE.

Referenced by LDAPModification::toLDAPMod().


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  s,
const LDAPAttribute attr 
) [friend]

This method can be used to dump the data of a LDAPResult-Object.

It is only useful for debugging purposes at the moment


The documentation for this class was generated from the following files:
Generated on Mon Jul 5 13:45:11 2010 for ldapsdk by  doxygen 1.6.3