Back to index

openldap  2.4.31
LDAPUrl.h
Go to the documentation of this file.
00001 // $OpenLDAP$
00002 /*
00003  * Copyright 2000-2012 The OpenLDAP Foundation, All Rights Reserved.
00004  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
00005  */
00006 
00007 
00008 #ifndef LDAP_URL_H
00009 #define LDAP_URL_H
00010 
00011 #include <StringList.h>
00012 
00013 class LDAPUrlException;
00022 class LDAPUrl{
00023 
00024     public : 
00029         LDAPUrl(const std::string &url="");
00030 
00034         ~LDAPUrl();
00035 
00040         int getPort() const;
00041         
00046         void setPort(int port);
00047 
00051         int getScope() const;
00052 
00057         void setScope(const std::string& scope);
00058 
00062         const std::string& getURLString() const;
00063 
00068         void setURLString(const std::string &url);
00069 
00073         const std::string& getHost() const;
00074 
00079         void setHost( const std::string &host);
00080 
00084         const std::string& getScheme() const;
00085 
00091         void setScheme( const std::string &scheme );
00092 
00096         const std::string& getDN() const;
00097         
00102         void setDN( const std::string &dn);
00103 
00104         
00108         const std::string& getFilter() const;
00109         
00114         void setFilter( const std::string &filter);
00115 
00119         const StringList& getAttrs() const;
00120         
00125         void setAttrs( const StringList &attrs);
00126         void setExtensions( const StringList &ext);
00127         const StringList& getExtensions() const;
00128 
00134         void percentDecode( const std::string& src, std::string& dest );
00135         
00142         std::string& percentEncode( const std::string& src, 
00143                     std::string& dest, 
00144                     int flags=0 ) const;
00145    
00146     protected : 
00154         void parseUrl();
00155         
00162         void components2Url() const;
00163         
00164         void string2list(const std::string &src, StringList& sl,
00165                 bool percentDecode=false);
00166 
00167     protected :
00168         mutable bool regenerate;
00169         int m_Port;
00170         int m_Scope;
00171         std::string m_Host;
00172         std::string m_DN;
00173         std::string m_Filter;
00174         StringList m_Attrs;
00175         StringList m_Extensions;
00176         mutable std::string m_urlString;
00177         std::string m_Scheme;
00178         enum mode { base, attrs, scope, filter, extensions };
00179 };
00180 
00182 struct code2string_s {
00183     int code;
00184     const char* string;
00185 };
00187 
00188 class LDAPUrlException {
00189     public :
00190         LDAPUrlException(int code, const std::string &msg="" );
00191 
00192         int getCode() const;
00193         const std::string getErrorMessage() const;
00194         const std::string getAdditionalInfo() const;
00195 
00196         static const int INVALID_SCHEME      = 1;
00197         static const int INVALID_PORT        = 2;
00198         static const int INVALID_SCOPE       = 3;
00199         static const int INVALID_URL         = 4;
00200         static const int URL_DECODING_ERROR  = 5; 
00201         static const code2string_s code2string[]; 
00202 
00203     private:
00204         int m_code;
00205         std::string m_addMsg;
00206 };
00207 #endif //LDAP_URL_H