13 #define RC_DEFAULT_PORT 389 14 #define HTTP_DEFAULT_PORT 80 15 #define HTTPS_DEFAULT_PORT 443 16 #define HTTPG_DEFAULT_PORT 8443 17 #define LDAP_DEFAULT_PORT 389 18 #define FTP_DEFAULT_PORT 21 19 #define GSIFTP_DEFAULT_PORT 2811 20 #define LFC_DEFAULT_PORT 5010 21 #define XROOTD_DEFAULT_PORT 1094 22 #define S3_DEFAULT_PORT 80 23 #define S3_HTTPS_DEFAULT_PORT 443 102 URL(
const std::string& url,
bool encoded =
false,
int defaultPort = -1,
const std::string& defaultPath =
"");
109 base, onelevel, subtree
119 const std::string&
Protocol()
const;
125 const std::string&
Username()
const;
128 const std::string&
Passwd()
const;
131 const std::string&
Host()
const;
143 const std::string&
Path()
const;
157 void ChangeFullPath(
const std::string& newpath,
bool encoded =
false);
160 void ChangeURL(
const std::string& newurl,
bool encoded =
false);
163 const std::map<std::string, std::string>&
HTTPOptions()
const;
170 const std::string&
HTTPOption(
const std::string& option,
171 const std::string& undefined =
"")
const;
176 bool AddHTTPOption(
const std::string& option,
const std::string& value,
177 bool overwrite =
true);
202 const std::map<std::string, std::string>&
Options()
const;
209 const std::string&
Option(
const std::string& option,
210 const std::string& undefined =
"")
const;
221 const std::string& undefined =
"")
const;
230 bool AddOption(
const std::string& option,
const std::string& value,
231 bool overwrite =
true);
237 bool AddOption(
const std::string& option,
bool overwrite =
true);
241 bool overwrite =
true);
247 const std::list<URLLocation>&
Locations()
const;
259 undefined =
"")
const;
270 virtual std::string
str(
bool encode =
false)
const;
273 virtual std::string
plainstr(
bool encode =
false)
const;
276 virtual std::string
fullstr(
bool encode =
false)
const;
288 operator bool()
const;
297 std::map<std::string, std::string>
ParseOptions(
const std::string& optstring,
298 char separator,
bool encoded =
false);
304 static std::string
OptionString(
const std::map<std::string,
305 std::string>& options,
char separator,
bool encode =
false);
365 static std::string
BaseDN2Path(
const std::string&);
368 static std::string
Path2BaseDN(
const std::string&);
371 friend std::ostream&
operator<<(std::ostream& out,
const URL& u);
399 URLLocation(
const std::map<std::string, std::string>& options,
400 const std::string&
name);
406 const std::string&
Name()
const;
409 virtual std::string
str(
bool encode =
false)
const;
412 virtual std::string
fullstr(
bool encode =
false)
const;
428 PathIterator(
const std::string& path,
bool end =
false);
438 operator bool()
const;
444 std::string
Rest()
const;
447 const std::string& path;
448 std::string::size_type pos;
459 #endif // __ARC_URL_H__ const std::map< std::string, std::string > & Options() const
Returns URL options if any.
Arc namespace contains all core ARC classes.
Definition: ArcConfig.h:11
bool operator!() const
Check if instance does not hold valid URL.
std::string ldapfilter
LDAP filter of the url.
Definition: URL.h:350
virtual ~URL()
Empty destructor.
static std::string Path2BaseDN(const std::string &)
a private method that converts an ldap path to a basedn.
std::list< std::string > ldapattributes
LDAP attributes of the url.
Definition: URL.h:344
std::map< std::string, std::string > urloptions
options of the url.
Definition: URL.h:353
std::string host
hostname of the url.
Definition: URL.h:326
const std::map< std::string, std::string > & MetaDataOptions() const
Returns metadata options if any.
std::string Rest() const
Returns part of initial path from one after current till end.
std::string username
username of the url.
Definition: URL.h:320
const std::string & CommonLocOption(const std::string &option, const std::string &undefined="") const
Returns the value of a common location option.
Class to hold a resolved URL location.
Definition: URL.h:382
virtual ~URLLocation()
URLLocation destructor.
std::list< URL > ReadURLList(const URL &urllist)
Reads a list of URLs from a file.
int Port() const
Returns the port of the URL.
URL()
Empty constructor. URL object is invalid.
void AddLocation(const URLLocation &location)
Adds a Location.
std::map< std::string, std::string > metadataoptions
Meta data options.
Definition: URL.h:341
const std::string & Host() const
Returns the hostname of the URL.
void AddLDAPAttribute(const std::string &attribute)
Adds an LDAP attribute.
Class to iterate through elements of a path.
Definition: URL.h:423
void ChangeLDAPFilter(const std::string &newfilter)
Changes the LDAP filter.
void URIDecode(void)
Perform decoding of stored URL parts according to RFC 3986.
PathIterator(const std::string &path, bool end=false)
Constructor accepts path and stores it internally.
std::map< std::string, std::string > httpoptions
HTTP options of the url.
Definition: URL.h:338
virtual std::string str(bool encode=false) const
Returns a string representation of the URL including meta-options.
const std::string & HTTPOption(const std::string &option, const std::string &undefined="") const
Returns the value of an HTTP option.
std::string path
the url path.
Definition: URL.h:335
virtual std::string str(bool encode=false) const
Returns a string representation of the URLLocation.
void ParsePath(bool encoded=false)
Convenience method for splitting schema specific part into path and options.
void RemoveMetaDataOption(const std::string &option)
Remove a metadata option if exits.
void ChangePath(const std::string &newpath)
Changes the path of the URL.
PathIterator & operator++()
Advances iterator to point at next path element.
std::string protocol
the url protocol.
Definition: URL.h:317
std::map< std::string, std::string > ParseOptions(const std::string &optstring, char separator, bool encoded=false)
Parse a string of options separated by separator into an attribute->value map.
const std::string & MetaDataOption(const std::string &option, const std::string &undefined="") const
Returns the value of a metadata option.
const std::map< std::string, std::string > & CommonLocOptions() const
Returns the common location options if any.
Scope
Scope for LDAP URLs.
Definition: URL.h:108
Scope ldapscope
LDAP scope of the url.
Definition: URL.h:347
const std::string & Protocol() const
Returns the protocol of the URL.
bool ip6addr
if host is IPv6 numerical address notation.
Definition: URL.h:329
void AddMetaDataOption(const std::string &option, const std::string &value, bool overwrite=true)
Adds a metadata option.
bool AddOption(const std::string &option, const std::string &value, bool overwrite=true)
Adds a URL option with the given value.
const std::map< std::string, std::string > & HTTPOptions() const
Returns HTTP options if any.
void RemoveOption(const std::string &option)
Removes a URL option if exists.
void ChangeFullPath(const std::string &newpath, bool encoded=false)
Changes the path of the URL and all options attached.
const std::string & Name() const
Returns the URLLocation name.
bool operator<(const URL &url) const
Compares one URL to another.
const std::string & LDAPFilter() const
Returns the LDAP filter.
virtual std::string ConnectionURL() const
Returns a string representation with protocol, host and port only.
int port
portnumber of the url.
Definition: URL.h:332
std::string operator*() const
Returns part of initial path from first till and including current.
bool StringMatches(const std::string &str) const
Returns true if string matches url.
PathIterator & operator--()
Moves iterator to element before current.
const std::list< URLLocation > & Locations() const
Returns the locations if any.
std::list< URLLocation > locations
locations for index server URLs.
Definition: URL.h:356
Class to represent general URLs.
Definition: URL.h:88
std::string passwd
password of the url.
Definition: URL.h:323
void ChangeURL(const std::string &newurl, bool encoded=false)
Changes whole URL possibly taking into account current one if new URL is relative.
void ChangeLDAPScope(const Scope newscope)
Changes the LDAP scope.
void RemoveHTTPOption(const std::string &option)
Removes a HTTP option if exists.
bool AddHTTPOption(const std::string &option, const std::string &value, bool overwrite=true)
Adds a HTP option with the given value.
bool valid
flag to describe validity of URL
Definition: URL.h:362
static std::string URIEncode(const std::string &str)
Perform encoding according to RFC 3986.
URLLocation(const std::string &url="")
Creates a URLLocation from a string representation.
static std::string OptionString(const std::map< std::string, std::string > &options, char separator, bool encode=false)
Returns a string representation of the options given in the options map.
void ChangePort(int newport)
Changes the port of the URL.
friend std::ostream & operator<<(std::ostream &out, const URL &u)
Overloaded operator << to print a URL.
void ChangeHost(const std::string &newhost)
Changes the hostname of the URL.
virtual std::string fullstr(bool encode=false) const
Returns a string representation including options and locations.
const std::string & Passwd() const
Returns the password of the URL.
static std::string BaseDN2Path(const std::string &)
a private method that converts an ldap basedn to a path.
void ChangeProtocol(const std::string &newprot)
Changes the protocol of the URL.
bool operator==(const URL &url) const
Is one URL equal to another?
std::string name
the URLLocation name as registered in the indexing service.
Definition: URL.h:416
const std::string & Username() const
Returns the username of the URL.
std::string FullPathURIEncoded() const
Returns the path and all options, URI-encoded according to RFC 3986.
Scope LDAPScope() const
Returns the LDAP scope.
std::string FullPath() const
Returns the path of the URL with all options attached.
std::map< std::string, std::string > commonlocoptions
common location options for index server URLs.
Definition: URL.h:359
virtual std::string fullstr(bool encode=false) const
Returns a string representation including options and locations.
virtual std::string plainstr(bool encode=false) const
Returns a string representation of the URL without any options.
const std::string & Option(const std::string &option, const std::string &undefined="") const
Returns the value of a URL option.
const std::list< std::string > & LDAPAttributes() const
Returns the LDAP attributes if any.
const std::string & Path() const
Returns the path of the URL.