]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/LDAPControl.h
use URIs instead of hostname/port
[openldap] / contrib / ldapc++ / src / LDAPControl.h
1 /*
2  * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
3  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
4  */
5
6
7 #ifndef LDAP_CONTROL_H
8 #define LDAP_CONTROL_H
9 #include <string>
10 #include <ldap.h>
11
12 /**
13  * This class is used to store Controls. Controls are a mechanism to extend
14  * and modify LDAP-Operations.
15  */
16 class LDAPCtrl{
17     public :
18         /**
19          * Copy-constructor
20          */
21         LDAPCtrl(const LDAPCtrl& c);
22
23         /**
24          * Constructor.
25          * @param oid:  The Object Identifier of the Control
26          * @param critical: "true" if the Control should be handled
27          *                  critical by the server.
28          * @param data: If there is data for the control, put it here.
29          * @param length: The length of the data field
30          */
31         LDAPCtrl(const char *oid, bool critical, const char *data=0, 
32                 int length=0);
33
34         /**
35          * Constructor.
36          * @param oid:  The Object Identifier of the Control
37          * @param critical: "true" if the Control should be handled
38          *                  critical by the server.
39          * @param data: If there is data for the control, put it here.
40          */
41         LDAPCtrl(const std::string& oid, bool critical=false,
42                 const std::string& data=std::string());
43
44         /**
45          * Creates a copy of the Control that "ctrl is pointing to
46          */
47         LDAPCtrl(const LDAPControl* ctrl);
48
49         /**
50          * Destructor
51          */
52         ~LDAPCtrl();
53        
54         /**
55          * @return The OID of the control
56          */
57         std::string getOID() const;
58
59         /**
60          * @return The Data of the control as a std::string-Objekt
61          */
62         std::string getData() const;
63
64         /**
65          * @return "true" if the control is critical
66          */
67         bool isCritical() const;
68
69         /**
70          * For internal use only.
71          *
72          * Translates the control to a LDAPControl-structure as needed by
73          * the C-API
74          */
75         LDAPControl* getControlStruct() const;
76         static void freeLDAPControlStruct(LDAPControl *ctrl);
77
78     private :
79         std::string m_oid;
80         std::string m_data;
81         bool m_isCritical;
82 };
83
84 #endif //LDAP_CONTROL_H