Skip to end of metadata
Go to start of metadata

URI::URI ( const std::string &  str_uri  ) 

Initializes a FB::URI object by decoding the input URL.

Definition at line 94 of file URI.cpp.

References parse_query_data(), and url_decode().

00094                                 : port(0) {
00095     string w = in_str;
00096 
00097     size_t l = w.find("://");
00098     if (l != std::string::npos) {
00099         protocol = w.substr(0, l);
00100         std::transform(protocol.begin(), protocol.end(), protocol.begin(), ::tolower);
00101         w = w.substr(l + 3);
00102     }
00103     // validate protocol -- should only contain [a-z0-9]
00104     for (l = 0; l < protocol.size(); ++l) {
00105         if (!isalnum(protocol[l])) throw std::runtime_error("URI: invalid characters in protocol part");
00106     }
00107 
00108     if (protocol != "file") { // file has neither a domain nor a port
00109         l = w.find_first_of("/\\");
00110         // chomp at the '/' (if it exists) so parsing the login/domain/port is easier
00111         string domain_str;
00112         if (l == std::string::npos) {
00113             domain_str = w;
00114             w = "/";
00115         } else {
00116             domain_str = w.substr(0, l);
00117             w = w.substr(l);
00118         }
00119 
00120         // check for login info
00121         l = domain_str.find("@");
00122         if (l != std::string::npos) {
00123             login = domain_str.substr(0, l);
00124             domain_str = domain_str.substr(l + 1);
00125         }
00126 
00127         // split port, if it exists
00128         size_t p = domain_str.find(":");
00129         if (p != std::string::npos && p < l) {
00130             domain = domain_str.substr(0, p);
00131             string port_str = domain_str.substr(p + 1);
00132             port = boost::lexical_cast<int>(port_str);
00133         } else {
00134             domain = domain_str;
00135         }
00136         // domains are case insensitive; transform to lower case for convenience.
00137         std::transform(domain.begin(), domain.end(), domain.begin(), ::tolower);
00138     }
00139 
00140     l = w.find('#');
00141     if (l != std::string::npos) {
00142         fragment = w.substr(l + 1);
00143         w = w.substr(0, l);
00144     }
00145     l = w.find('?');
00146     if (l != std::string::npos) {
00147         parse_query_data(w.substr(l + 1));
00148         w = w.substr(0, l);
00149     }
00150     path = url_decode(w);
00151 }

Here is the call graph for this function:


Generated on 24 May 2013 for FireBreath by  doxygen 1.6.1
Labels
  • None