ldapsdk  0.0.1
Public Member Functions | Friends | List of all members
LDAPAttribute Class Reference

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

#include <LDAPAttribute.h>

Public Member Functions

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

Detailed Description

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

Constructor & Destructor Documentation

◆ LDAPAttribute() [1/6]

LDAPAttribute::LDAPAttribute ( )

Default constructor.

initializes an empty object.

References DEBUG, and LDAP_DEBUG_CONSTRUCT.

◆ LDAPAttribute() [2/6]

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() [3/6]

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() [4/6]

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() [5/6]

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() [6/6]

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::~LDAPAttribute ( )

Destructor.

References DEBUG, and LDAP_DEBUG_DESTROY.

Member Function Documentation

◆ addValue() [1/2]

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().

◆ addValue() [2/2]

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.

◆ getBerValues()

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().

◆ getName()

const string & LDAPAttribute::getName ( ) const

◆ getNumValues()

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

References DEBUG, and LDAP_DEBUG_TRACE.

◆ getValues()

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().

◆ isNotPrintable()

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

Referenced by operator<<().

◆ setName()

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.

◆ setValues() [1/3]

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.

◆ setValues() [2/3]

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.

◆ setValues() [3/3]

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.

◆ toLDAPMod()

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

◆ operator<<

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: