proxygen
Uri.h
Go to the documentation of this file.
1 /*
2  * Copyright 2013-present Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 #define FOLLY_URI_H_
19 
20 #include <string>
21 #include <vector>
22 
23 #include <folly/String.h>
24 
25 namespace folly {
26 
43 class Uri {
44  public:
48  explicit Uri(StringPiece str);
49 
50  const std::string& scheme() const {
51  return scheme_;
52  }
53  const std::string& username() const {
54  return username_;
55  }
56  const std::string& password() const {
57  return password_;
58  }
63  const std::string& host() const {
64  return host_;
65  }
75  std::string hostname() const;
76  uint16_t port() const {
77  return port_;
78  }
79  const std::string& path() const {
80  return path_;
81  }
82  const std::string& query() const {
83  return query_;
84  }
85  const std::string& fragment() const {
86  return fragment_;
87  }
88 
89  std::string authority() const;
90 
91  template <class String>
92  String toString() const;
93 
94  std::string str() const {
95  return toString<std::string>();
96  }
97  fbstring fbstr() const {
98  return toString<fbstring>();
99  }
100 
102  hasAuthority_ = true;
103  port_ = port;
104  }
105 
126  const std::vector<std::pair<std::string, std::string>>& getQueryParams();
127 
128  private:
138  std::vector<std::pair<std::string, std::string>> queryParams_;
139 };
140 
141 } // namespace folly
142 
143 #include <folly/Uri-inl.h>
std::string path_
Definition: Uri.h:135
std::string username_
Definition: Uri.h:130
uint16_t port_
Definition: Uri.h:134
const std::string & password() const
Definition: Uri.h:56
std::string query_
Definition: Uri.h:136
Definition: Uri.h:43
const std::string & username() const
Definition: Uri.h:53
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
uint16_t port() const
Definition: Uri.h:76
const std::string & host() const
Definition: Uri.h:63
String toString() const
Definition: Uri-inl.h:56
std::string str() const
Definition: Uri.h:94
bool hasAuthority_
Definition: Uri.h:133
std::string host_
Definition: Uri.h:132
fbstring fbstr() const
Definition: Uri.h:97
const std::string & fragment() const
Definition: Uri.h:85
const std::string & query() const
Definition: Uri.h:82
void setPort(uint16_t port)
Definition: Uri.h:101
Uri(StringPiece str)
Definition: Uri.cpp:35
const std::string & path() const
Definition: Uri.h:79
std::string authority() const
Definition: Uri.cpp:96
const char * string
Definition: Conv.cpp:212
const std::string & scheme() const
Definition: Uri.h:50
std::vector< std::pair< std::string, std::string > > queryParams_
Definition: Uri.h:138
std::string fragment_
Definition: Uri.h:137
const std::vector< std::pair< std::string, std::string > > & getQueryParams()
Definition: Uri.cpp:132
std::string password_
Definition: Uri.h:131
std::string scheme_
Definition: Uri.h:129
std::string hostname() const
Definition: Uri.cpp:123