ldapsdk 0.0.1
Public Member Functions | Friends

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::stringgetName () 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, LDAP_DEBUG_CONSTRUCT, and string.

LDAPAttribute::LDAPAttribute ( const LDAPAttribute attr)

Copy constructor.

Copies all values of an Attribute to a new one

Parameters:
attrThe 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:
nameThe attribute's name (type)
valueThe 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:
nameThe attribute's name (type)
valuesA 0-terminated array of char*. Each char* specifies one value of the attribute (UTF-8 encoded)

References DEBUG, LDAP_DEBUG_CONSTRUCT, and LDAP_DEBUG_PARAMETER.

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

Construct an attribute with multiple string values.

Parameters:
nameThe attribute's name (type)
valuesA 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:
nameThe attribute's name (type)
values0-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, and LDAP_DEBUG_PARAMETER.

LDAPAttribute::~LDAPAttribute ( )

Destructor.

References DEBUG, and LDAP_DEBUG_DESTROY.


Member Function Documentation

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

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

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

Referenced by LdifReader::getEntryRecord().

int LDAPAttribute::addValue ( const BerValue *  value)

Add a single binary value to the Attribute.

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

References DEBUG, and LDAP_DEBUG_TRACE.

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 DEBUG, and LDAP_DEBUG_TRACE.

Referenced by LDAPCompareRequest::sendRequest().

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

References DEBUG, and LDAP_DEBUG_TRACE.

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

Referenced by operator<<().

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

Sets the Attribute's name (type)

Parameters:
thenew name of the object

References DEBUG, LDAP_DEBUG_PARAMETER, 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:
values0-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 DEBUG, and LDAP_DEBUG_TRACE.

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:
valuesA 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:
values0-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 DEBUG, and LDAP_DEBUG_TRACE.

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, and LDAP_DEBUG_TRACE.


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: