1 /* 2 * \copyright Copyright 2013 Google Inc. All Rights Reserved. 3 * \license @{ 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 * @} 18 */ 19 20 #ifndef NET_THIRD_PARTY_URI_TEMPLATE_URI_TEMPLATE_H_ 21 #define NET_THIRD_PARTY_URI_TEMPLATE_URI_TEMPLATE_H_ 22 23 #include <set> 24 #include <string> 25 #include <unordered_map> 26 27 #include "base/component_export.h" 28 29 using std::string; 30 31 namespace uri_template { 32 33 /* 34 * Produce concrete URLs from templated ones. Collect the names of any expanded 35 * variables. Supports templates up to level 3 as specified in RFC 6570 with 36 * some limitations: it does not check for disallowed characters in variable 37 * names, and it does not do any encoding during literal expansion. 38 * 39 * @param[in] uri The templated uri to expand. 40 * @param[in] parameters A map containing variables and corresponding values. 41 * @param[out] target The string to resolve the templated uri into. 42 * @param[out] vars_found Populated with the list of variables names 43 * that were resolved while expanding the uri. NULL is permitted 44 * if the caller does not wish to collect these. 45 * 46 * @return true if the template was parseable. false if it was malformed. 47 */ 48 COMPONENT_EXPORT(URI_TEMPLATE) 49 bool Expand(const string& template_uri, 50 const std::unordered_map<string, string>& parameters, 51 string* target, 52 std::set<string>* vars_found = nullptr); 53 54 } // namespace uri_template 55 56 #endif // NET_THIRD_PARTY_URI_TEMPLATE_URI_TEMPLATE_H_ 57