Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

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

Private Attributes

std::string m_name
StringList m_values

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.

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

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)

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;

LDAPAttribute::~LDAPAttribute  ) 
 

Destructor.


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)

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

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

const string & LDAPAttribute::getName  )  const
 

Returns:
The name(type) of the attribute

int LDAPAttribute::getNumValues  )  const
 

Returns:
The number of values of the attribute

const StringList & LDAPAttribute::getValues  )  const
 

Returns:
The values of the array as a list of strings

bool LDAPAttribute::isNotPrintable  )  const
 

Returns:
true If the attribute contains non-printable attributes

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

Sets the Attribute's name (type).

Parameters:
the new name of the object

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

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)

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)

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


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


Member Data Documentation

std::string LDAPAttribute::m_name [private]
 

StringList LDAPAttribute::m_values [private]
 


The documentation for this class was generated from the following files:
Generated on Wed Nov 12 02:19:04 2008 for ldapsdk by  doxygen 1.3.9.1