Skip to content

Commit 923baf9

Browse files
committed
uri_builder is constructible from strings
1 parent efc54d4 commit 923baf9

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

Release/include/cpprest/uri_builder.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ namespace web
5252
/// <param name="uri_str">Encoded string containing the URI.</param>
5353
uri_builder(const uri &uri_str): m_uri(uri_str.m_components) {}
5454

55+
/// <summary>
56+
/// Creates a builder with a existing URI string.
57+
/// </summary>
58+
/// <param name="str">String containing the URI.</param>
59+
uri_builder(const utility::string_t& str) : uri_builder(uri(str)) {}
60+
61+
/// <summary>
62+
/// Creates a builder with a existing URI string.
63+
/// </summary>
64+
/// <param name="str">String containing the URI.</param>
65+
uri_builder(const utility::char_t* str) : uri_builder(uri(str)) {}
66+
5567
/// <summary>
5668
/// Get the scheme component of the URI as an encoded string.
5769
/// </summary>
@@ -273,13 +285,13 @@ namespace web
273285
/// Combine and validate the URI components into a encoded string. An exception will be thrown if the URI is invalid.
274286
/// </summary>
275287
/// <returns>The created URI as a string.</returns>
276-
_ASYNCRTIMP utility::string_t to_string();
288+
_ASYNCRTIMP utility::string_t to_string() const;
277289

278290
/// <summary>
279291
/// Combine and validate the URI components into a URI class instance. An exception will be thrown if the URI is invalid.
280292
/// </summary>
281293
/// <returns>The create URI as a URI class instance.</returns>
282-
_ASYNCRTIMP uri to_uri();
294+
_ASYNCRTIMP uri to_uri() const;
283295

284296
/// <summary>
285297
/// Validate the generated URI from all existing components of this uri_builder.

Release/src/uri/uri_builder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ uri_builder &uri_builder::append(const http::uri &relative_uri)
103103
return *this;
104104
}
105105

106-
utility::string_t uri_builder::to_string()
106+
utility::string_t uri_builder::to_string() const
107107
{
108108
return to_uri().to_string();
109109
}
110110

111-
uri uri_builder::to_uri()
111+
uri uri_builder::to_uri() const
112112
{
113113
return uri(m_uri);
114114
}

0 commit comments

Comments
 (0)