Commit 3bca295b authored by Joseph Noir's avatar Joseph Noir

Add constructors and assign operators

parent ffb044f1
......@@ -32,16 +32,12 @@
namespace caf {
namespace io {
namespace detail {
class uri_private;
void intrusive_ptr_add_ref(uri_private* p);
void intrusive_ptr_release(uri_private* p);
} // namespace detail
namespace {
using str_bounds = std::pair<std::string::iterator, std::string::iterator>;
......@@ -73,7 +69,6 @@ public:
return (what) ? str().compare(what) : str().compare("");
}
///
/// @brief Create an empty URI.
///
......@@ -85,7 +80,29 @@ public:
/// @note {@link caf::io::uri uri} is implicit shared, thus copy
/// operations are very fast and lightweight.
///
uri(const uri& other);
uri(const uri& other) = default;
///
/// @brief Create this object from @p other.
/// @param other The original {@link caf::io::uri uri} object.
/// @note {@link caf::io::uri uri} is implicit shared, thus copy
/// operations are very fast and lightweight.
///
uri(uri&& other) = default;
///
/// @brief Copy assigment from @p other.
/// @param other Original {@link caf::io::uri uri} object.
/// @returns <code>*this</code>.
///
uri& operator=(const uri& other) = default;
///
/// @brief Move assignment from @p other;
/// @param other Original {@link caf::io::uri uri} object.
/// @return <code>*this</code>.
///
uri& operator=(uri&& other) = default;
///
/// @brief Create an URI from @p uri_str.
......@@ -251,13 +268,6 @@ public:
///
void swap(uri& other);
///
/// @brief Equivalent to <code>uri(other).swap(*this)</code>.
/// @param other Original {@link caf::io::uri uri} object.
/// @returns <code>*this</code>.
///
uri& operator=(const uri& other);
/// @cond private
template <class Inspector>
......@@ -268,9 +278,9 @@ public:
/// @endcond
private:
uri(detail::uri_private* d);
uri(uri_private* d);
intrusive_ptr<detail::uri_private> d_;
intrusive_ptr<uri_private> d_;
};
} // namespace io
......
......@@ -44,7 +44,6 @@ using str_bounds = std::pair<std::string::iterator, std::string::iterator>;
namespace caf {
namespace io {
namespace detail {
class uri_private : public ref_counted {
friend optional<uri> uri::make(const string& uri_str);
......@@ -234,7 +233,6 @@ intrusive_ptr<uri_private> m_default_uri_private(new uri_private);
} // namespace <anonymous>
} // namespace detail
} // namespace io
} // namespace caf
......@@ -242,7 +240,7 @@ namespace caf {
namespace io {
optional<uri> uri::make(const string& uri_str) {
detail::uri_private* result = new detail::uri_private;
uri_private* result = new uri_private;
if (result->parse_uri(uri_str))
return uri{result};
else {
......@@ -256,22 +254,14 @@ optional<uri> uri::make(const char* cstr) {
return make(tmp);
}
uri::uri() : d_(detail::m_default_uri_private) {
uri::uri() : d_(m_default_uri_private) {
// nop
}
uri::uri(detail::uri_private* d) : d_(d) {
uri::uri(uri_private* d) : d_(d) {
// nop
}
uri::uri(const uri& other) : d_(other.d_) {
// nop
}
uri& uri::operator=(const uri& other) {
d_ = other.d_;
return *this;
}
const string& uri::str() const {
return d_->as_string();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment