FireBreath  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
public std::string FB::URI::toString ( bool  include_domain_part = true) const

converts the FB::URI object to a string

FB::URI uri;
uri.protocol = "http";
uri.host = "www.firebreath.org";
uri.path = "/applications";
uri.query_data["user"] = "taxilian";
uri.fragment = "bleh";
std::string struri = uri.toString();
// struri == "http://taxilian@www.firebreath.org/applications?user=taxilian#bleh"
Parameters
include_domain_partbool if false, only the path and later will be returned (no domain or http://, etc)
Returns
std::string
Since
1.4b1

Definition at line 66 of file URI.cpp.

66  {
67  std::stringstream res;
68  if (include_host_part) {
69  res << protocol << string("://");
70  if (!login.empty()) res << login << "@";
71  res << domain;
72  if (port) res << ":" << boost::lexical_cast<string>(port);
73  }
74  res << url_encode(path);
75  if (!query_data.empty()) {
76  char separator = '?';
77  for (std::map<std::string, std::string>::const_iterator it = query_data.begin(); it != query_data.end(); ++it) {
78  res << separator;
79  separator = '&';
80  res << url_encode(it->first);
81  res << '=';
82  res << url_encode(it->second);
83  }
84  }
85  if (!fragment.empty())
86  res << "#" << fragment;
87  return res.str();
88 }
static std::string url_encode(const std::string &in)
Encodes the given URL for transmission.
Definition: URI.cpp:37