Implement AsyncTaskManager for toolkit UTC
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / visual-url.cpp
index c43af6d..93c1e78 100644 (file)
@@ -233,9 +233,9 @@ VisualUrl::VisualUrl(const std::string& url)
   if(!url.empty())
   {
     mLocation = ResolveLocation(url);
-    if(VisualUrl::TEXTURE != mLocation && VisualUrl::BUFFER != mLocation)
+    if(VisualUrl::TEXTURE != mLocation)
     {
-      // TEXTURE and BUFFER location url doesn't need type resolving, REGULAR_IMAGE is fine
+      // TEXTURE location url doesn't need type resolving, REGULAR_IMAGE is fine
       mType = ResolveType(url);
     }
   }
@@ -249,6 +249,15 @@ VisualUrl::VisualUrl(const VisualUrl& url)
 {
 }
 
+VisualUrl::VisualUrl(VisualUrl&& url) noexcept
+: mUrl(std::move(url.mUrl)),
+  mType(std::move(url.mType)),
+  mLocation(std::move(url.mLocation)),
+  mUrlHash(std::move(url.mUrlHash))
+{
+  url.mUrlHash = 0ull;
+}
+
 VisualUrl::~VisualUrl()
 {
 }
@@ -265,12 +274,26 @@ VisualUrl& VisualUrl::operator=(const VisualUrl& url)
   return *this;
 }
 
+VisualUrl& VisualUrl::operator=(VisualUrl&& url) noexcept
+{
+  if(&url != this)
+  {
+    mUrl      = std::move(url.mUrl);
+    mType     = std::move(url.mType);
+    mLocation = std::move(url.mLocation);
+    mUrlHash  = std::move(url.mUrlHash);
+
+    url.mUrlHash = 0ull;
+  }
+  return *this;
+}
+
 const std::string& VisualUrl::GetUrl() const
 {
   return mUrl;
 }
 
-const std::uint64_t& VisualUrl::GetUrlHash() const
+std::uint64_t VisualUrl::GetUrlHash() const
 {
   return DALI_UNLIKELY(mUrlHash == 0) ? (mUrlHash = Dali::CalculateHash(mUrl)) : mUrlHash;
 }
@@ -305,14 +328,19 @@ std::string VisualUrl::GetLocation() const
   return GetLocation(mUrl);
 }
 
+std::string VisualUrl::GetLocationWithoutExtension() const
+{
+  return GetLocationWithoutExtension(mUrl);
+}
+
 std::string VisualUrl::CreateTextureUrl(const std::string& location)
 {
   return "dali://" + location;
 }
 
-std::string VisualUrl::CreateBufferUrl(const std::string& location)
+std::string VisualUrl::CreateBufferUrl(const std::string& location, const std::string_view& extension)
 {
-  return "enbuf://" + location;
+  return "enbuf://" + location + std::string(extension);
 }
 
 VisualUrl::ProtocolType VisualUrl::GetProtocolType(const std::string& url)
@@ -330,6 +358,18 @@ std::string VisualUrl::GetLocation(const std::string& url)
   return url;
 }
 
+std::string VisualUrl::GetLocationWithoutExtension(const std::string& url)
+{
+  const auto location = url.find("://");
+  if(std::string::npos != location)
+  {
+    const auto extension = url.find_last_of("."); // Find last position of '.' keyword.
+    const auto locationLength = extension != std::string::npos ? extension - (location + 3u) : std::string::npos;
+    return url.substr(location + 3u, locationLength); // 3 characters forwards from the start of ://, and end of last '.' keyword.
+  }
+  return url;
+}
+
 } // namespace Internal
 
 } // namespace Toolkit