X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=folly%2FUri.cpp;h=d1bdfae73b736c1d59bc0bb5e8f357a71c1f7281;hp=9bff152b1c45f518830fdb4b600492c845aad4fd;hb=bda67fde120837b77ddab74f23abcb22ae5b3029;hpb=5b39efc2656ebcd74b46775ad276c1ab06c3c54b diff --git a/folly/Uri.cpp b/folly/Uri.cpp index 9bff152b..d1bdfae7 100644 --- a/folly/Uri.cpp +++ b/folly/Uri.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 Facebook, Inc. + * Copyright 2017 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,26 +16,27 @@ #include -#include +#include + #include namespace folly { namespace { -fbstring submatch(const boost::cmatch& m, size_t 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 void toLower(String& s) { for (auto& c : s) { - c = tolower(c); + c = char(tolower(c)); } } -} // namespace +} // namespace Uri::Uri(StringPiece str) : hasAuthority_(false), port_(0) { static const boost::regex uriRegex( @@ -61,7 +62,7 @@ Uri::Uri(StringPiece str) : hasAuthority_(false), port_(0) { 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 @@ -96,8 +97,8 @@ Uri::Uri(StringPiece str) : hasAuthority_(false), port_(0) { 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); @@ -123,7 +124,7 @@ fbstring Uri::authority() const { 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 @@ -132,7 +133,7 @@ fbstring Uri::hostname() const { return host_; } -const std::vector>& Uri::getQueryParams() { +const std::vector>& Uri::getQueryParams() { if (!query_.empty() && queryParams_.empty()) { // Parse query string static const boost::regex queryParamRegex( @@ -150,12 +151,12 @@ const std::vector>& Uri::getQueryParams() { 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 ); } } return queryParams_; } -} // namespace folly +} // namespace folly