namespace {
-fbstring submatch(const boost::cmatch& m, int idx) {
+std::string submatch(const boost::cmatch& m, int idx) {
auto& sub = m[idx];
- return fbstring(sub.first, sub.second);
+ return std::string(sub.first, sub.second);
}
template <class String>
authorityAndPathRegex)) {
// Does not start with //, doesn't have authority
hasAuthority_ = false;
- path_ = authorityAndPath.fbstr();
+ path_ = authorityAndPath.str();
} else {
static const boost::regex authorityRegex(
"(?:([^@:]*)(?::([^@]*))?@)?" // username, password
fragment_ = submatch(match, 4);
}
-fbstring Uri::authority() const {
- fbstring result;
+std::string Uri::authority() const {
+ std::string result;
// Port is 5 characters max and we have up to 3 delimiters.
result.reserve(host().size() + username().size() + password().size() + 8);
return result;
}
-fbstring Uri::hostname() const {
+std::string Uri::hostname() const {
if (host_.size() > 0 && host_[0] == '[') {
// If it starts with '[', then it should end with ']', this is ensured by
// regex
return host_;
}
-const std::vector<std::pair<fbstring, fbstring>>& Uri::getQueryParams() {
+const std::vector<std::pair<std::string, std::string>>& Uri::getQueryParams() {
if (!query_.empty() && queryParams_.empty()) {
// Parse query string
static const boost::regex queryParamRegex(
continue;
}
queryParams_.emplace_back(
- fbstring((*itr)[2].first, (*itr)[2].second), // parameter name
- fbstring((*itr)[3].first, (*itr)[3].second) // parameter value
+ std::string((*itr)[2].first, (*itr)[2].second), // parameter name
+ std::string((*itr)[3].first, (*itr)[3].second) // parameter value
);
}
}
#pragma once
#define FOLLY_URI_H_
-#include <folly/String.h>
+#include <string>
#include <vector>
+#include <folly/String.h>
+
namespace folly {
/**
*/
explicit Uri(StringPiece str);
- const fbstring& scheme() const { return scheme_; }
- const fbstring& username() const { return username_; }
- const fbstring& password() const { return password_; }
+ const std::string& scheme() const { return scheme_; }
+ const std::string& username() const { return username_; }
+ const std::string& password() const { return password_; }
/**
* Get host part of URI. If host is an IPv6 address, square brackets will be
* returned, for example: "[::1]".
*/
- const fbstring& host() const { return host_; }
+ const std::string& host() const { return host_; }
/**
* Get host part of URI. If host is an IPv6 address, square brackets will not
* be returned, for exmaple "::1"; otherwise it returns the same thing as
* or API that connects to that host/port; e.g. getaddrinfo() only understands
* IPv6 host without square brackets
*/
- fbstring hostname() const;
+ std::string hostname() const;
uint16_t port() const { return port_; }
- const fbstring& path() const { return path_; }
- const fbstring& query() const { return query_; }
- const fbstring& fragment() const { return fragment_; }
+ const std::string& path() const { return path_; }
+ const std::string& query() const { return query_; }
+ const std::string& fragment() const { return fragment_; }
- fbstring authority() const;
+ std::string authority() const;
template <class String>
String toString() const;
* pair of which the first element is parameter name and the second
* one is parameter value
*/
- const std::vector<std::pair<fbstring, fbstring>>& getQueryParams();
+ const std::vector<std::pair<std::string, std::string>>& getQueryParams();
private:
- fbstring scheme_;
- fbstring username_;
- fbstring password_;
- fbstring host_;
+ std::string scheme_;
+ std::string username_;
+ std::string password_;
+ std::string host_;
bool hasAuthority_;
uint16_t port_;
- fbstring path_;
- fbstring query_;
- fbstring fragment_;
- std::vector<std::pair<fbstring, fbstring>> queryParams_;
+ std::string path_;
+ std::string query_;
+ std::string fragment_;
+ std::vector<std::pair<std::string, std::string>> queryParams_;
};
} // namespace folly