]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/LDAPMessage.h
ITS#8605 - spelling fixes
[openldap] / contrib / ldapc++ / src / LDAPMessage.h
1 // $OpenLDAP$
2 /*
3  * Copyright 2000-2017 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6
7
8 #ifndef LDAP_MSG_H
9 #define LDAP_MSG_H
10 #include <ldap.h>
11
12 #include <LDAPControlSet.h>
13
14 class LDAPRequest;
15 /**
16  * This class represents any type of LDAP- Message returned 
17  * from the server.
18  *
19  * This class is never not instantiated directly. Only
20  * its subclasses are used. The main feature of this class is the
21  * static method create() (see below)
22  */
23 class LDAPMsg{
24     public:
25         //public Constants defining the response message types
26         static const int BIND_RESPONSE=LDAP_RES_BIND;
27         static const int SEARCH_ENTRY=LDAP_RES_SEARCH_ENTRY;
28         static const int SEARCH_DONE=LDAP_RES_SEARCH_RESULT;
29         static const int SEARCH_REFERENCE=LDAP_RES_SEARCH_REFERENCE;
30         static const int MODIFY_RESPONSE=LDAP_RES_MODIFY;
31         static const int ADD_RESPONSE=LDAP_RES_ADD;
32         static const int DEL_RESPONSE=LDAP_RES_DELETE;
33         static const int MODDN_RESPONSE=LDAP_RES_MODDN;
34         static const int COMPARE_RESPONSE=LDAP_RES_COMPARE;
35         static const int EXTENDED_RESPONSE=LDAP_RES_EXTENDED;
36         //public Constants defining the request message types
37         static const int BIND_REQUEST=LDAP_REQ_BIND;
38         static const int UNBIND_REQUEST=LDAP_REQ_UNBIND;
39         static const int SEARCH_REQUEST=LDAP_REQ_SEARCH;
40         static const int MODIFY_REQUEST=LDAP_REQ_MODIFY;
41         static const int ADD_REQUEST=LDAP_REQ_ADD;
42         static const int DELETE_REQUEST=LDAP_REQ_DELETE;
43         static const int MODRDN_REQUEST=LDAP_REQ_MODRDN;
44         static const int COMPARE_REQUEST=LDAP_REQ_COMPARE;
45         static const int ABANDON_REQUEST=LDAP_REQ_ABANDON;
46         static const int EXTENDED_REQUEST=LDAP_REQ_EXTENDED;
47        
48         /**
49          * The destructor has no implementation, because this is an abstract
50          * class.
51          */
52         virtual ~LDAPMsg() {}
53
54         /**
55          * This method is used by the library to parse the results returned
56          * by the C-API.
57          *
58          * Based on msgtype-Value of the *msg-Parameter this method creates
59          * an Object of one of the subtypes of LDAPMsg (e.g. LDAPSearchResult
60          * or LDAPResult) that represents the same Message as the
61          * *msg-Parameter. *msg is e.g. a Message returned by the C-API's
62          * ldap_result call.
63          * @param req   The LDAPRequest-object this result message is
64          *          associated with.
65          * @param msg   The LDAPMessage-structure from the C-API that
66          *          contains the LDAP-message to parse.
67          * @return An Object of one of the subtypes of this class. It
68          *          contains the parsed LDAP-message.
69          */
70         static LDAPMsg* create(const LDAPRequest *req, LDAPMessage *msg);   
71         
72         /**
73          * @returns The Type of message that this object contains. Possible
74          *          values are: <BR>
75          *          BIND_RESPONSE <BR>
76          *          SEARCH_ENTRY  <BR>       
77          *          SEARCH_DONE   <BR>      
78          *          SEARCH_REFERENCE   <BR>      
79          *          MODIFY_RESPONSE     <BR>    
80          *          ADD_RESPONSE       <BR>  
81          *          DEL_RESPONSE       <BR>  
82          *          MODDN_RESPONSE     <BR>    
83          *          COMPARE_RESPONSE   <BR>
84          *          EXTENDED_RESPONSE   <BR>
85          */
86         int getMessageType();
87         
88         /**
89          * @returns The message-ID that the C-API return for the
90          *      Result-message. 
91          */
92         int getMsgID();
93
94         /**
95          * @returns If any Control was sent back by the server this method
96          *       returns true. Otherwise false is returned.
97          */
98         bool hasControls() const;
99
100         /**
101          * @returns Server controls that were sent back by the server.
102          * @note This feature is not test well yet.
103          */
104         const LDAPControlSet& getSrvControls() const;
105     
106     protected:
107         /**
108          * This constructor make a copy of a LDAPMsg-pointer. The object
109          * itself (no the pointer) is copied.
110          * Only for internal use.
111          */
112         LDAPMsg(LDAPMessage *msg);
113         LDAPMsg(int msgType, int msgID);
114        
115         /**
116          * This attribute stores Server-Control that were returned with the
117          * message.
118          */
119         LDAPControlSet m_srvControls;
120         
121         bool m_hasControls;
122
123     private:
124         int msgType;
125         int msgID;
126 };
127 #endif //ifndef LDAP_MSG_H