00001
00002
00003
00004
00005
00006
00007 #ifndef LDAP_URL_H
00008 #define LDAP_URL_H
00009
00010 #include <StringList.h>
00011
00012 class LDAPUrlException;
00021 class LDAPUrl{
00022
00023 public :
00028 LDAPUrl(const std::string &url="");
00029
00033 ~LDAPUrl();
00034
00039 int getPort() const;
00040
00045 void setPort(int port);
00046
00050 int getScope() const;
00051
00056 void setScope(const std::string& scope);
00057
00061 const std::string& getURLString() const;
00062
00067 void setURLString(const std::string &url);
00068
00072 const std::string& getHost() const;
00073
00078 void setHost( const std::string &host);
00079
00083 const std::string& getScheme() const;
00084
00090 void setScheme( const std::string &scheme );
00091
00095 const std::string& getDN() const;
00096
00101 void setDN( const std::string &dn);
00102
00103
00107 const std::string& getFilter() const;
00108
00113 void setFilter( const std::string &filter);
00114
00118 const StringList& getAttrs() const;
00119
00124 void setAttrs( const StringList &attrs);
00125 void setExtensions( const StringList &ext);
00126 const StringList& getExtensions() const;
00127
00133 void percentDecode( const std::string& src, std::string& dest );
00134
00141 void percentEncode( const std::string& src,
00142 std::string& dest,
00143 int flags=0 ) const;
00144
00145 protected :
00153 void parseUrl();
00154
00161 void components2Url() const;
00162
00163 void string2list(const std::string &src, StringList& sl,
00164 bool percentDecode=false);
00165
00166 protected :
00167 mutable bool regenerate;
00168 int m_Port;
00169 int m_Scope;
00170 std::string m_Host;
00171 std::string m_DN;
00172 std::string m_Filter;
00173 StringList m_Attrs;
00174 StringList m_Extensions;
00175 mutable std::string m_urlString;
00176 std::string m_Scheme;
00177 enum mode { base, attrs, scope, filter, extensions };
00178 };
00179
00180 struct code2string_s {
00181 int code;
00182 const char* string;
00183 };
00184
00185 class LDAPUrlException {
00186 public :
00187 LDAPUrlException(int code, const std::string &msg="" );
00188
00189 int getCode() const;
00190 const std::string getErrorMessage() const;
00191 const std::string getAdditionalInfo() const;
00192
00193 static const int INVALID_SCHEME = 1;
00194 static const int INVALID_PORT = 2;
00195 static const int INVALID_SCOPE = 3;
00196 static const int INVALID_URL = 4;
00197 static const int URL_DECODING_ERROR = 5;
00198 static const code2string_s code2string[];
00199
00200 private:
00201 int m_code;
00202 std::string m_addMsg;
00203 };
00204 #endif //LDAP_URL_H