ldapsdk  0.0.1
LDAPUrl.h
Go to the documentation of this file.
1 // $OpenLDAP$
2 /*
3  * Copyright 2000-2011 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6 
7 
8 #ifndef LDAP_URL_H
9 #define LDAP_URL_H
10 
11 #include <StringList.h>
12 
13 class LDAPUrlException;
22 class LDAPUrl{
23 
24  public :
29  LDAPUrl(const std::string &url="");
30 
34  ~LDAPUrl();
35 
40  int getPort() const;
41 
46  void setPort(int port);
47 
51  int getScope() const;
52 
57  void setScope(const std::string& scope);
58 
62  const std::string& getURLString() const;
63 
68  void setURLString(const std::string &url);
69 
73  const std::string& getHost() const;
74 
79  void setHost( const std::string &host);
80 
84  const std::string& getScheme() const;
85 
91  void setScheme( const std::string &scheme );
92 
96  const std::string& getDN() const;
97 
102  void setDN( const std::string &dn);
103 
104 
108  const std::string& getFilter() const;
109 
114  void setFilter( const std::string &filter);
115 
119  const StringList& getAttrs() const;
120 
125  void setAttrs( const StringList &attrs);
126  void setExtensions( const StringList &ext);
127  const StringList& getExtensions() const;
128 
134  void percentDecode( const std::string& src, std::string& dest );
135 
142  std::string& percentEncode( const std::string& src,
143  std::string& dest,
144  int flags=0 ) const;
145 
146  protected :
154  void parseUrl();
155 
162  void components2Url() const;
163 
164  void string2list(const std::string &src, StringList& sl,
165  bool percentDecode=false);
166 
167  protected :
168  mutable bool regenerate;
169  int m_Port;
170  int m_Scope;
171  std::string m_Host;
172  std::string m_DN;
173  std::string m_Filter;
176  mutable std::string m_urlString;
177  std::string m_Scheme;
179 };
180 
182 struct code2string_s {
183  int code;
184  const char* string;
185 };
187 
189  public :
190  LDAPUrlException(int code, const std::string &msg="" );
191 
192  int getCode() const;
193  const std::string getErrorMessage() const;
194  const std::string getAdditionalInfo() const;
195 
196  static const int INVALID_SCHEME = 1;
197  static const int INVALID_PORT = 2;
198  static const int INVALID_SCOPE = 3;
199  static const int INVALID_URL = 4;
200  static const int URL_DECODING_ERROR = 5;
201  static const code2string_s code2string[];
202 
203  private:
204  int m_code;
205  std::string m_addMsg;
206 };
207 #endif //LDAP_URL_H