1 #ifndef DALI_TOOLKIT_INTERNAL_VISUAL_URL_H
2 #define DALI_TOOLKIT_INTERNAL_VISUAL_URL_H
5 * Copyright (c) 2024 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
23 #include <string_view>
35 * The type of the URL based on the string contents
50 LOCAL, ///< file in local file system
51 TEXTURE, ///< texture uploaded to texture manager
52 REMOTE, ///< remote image
53 BUFFER ///< encoded image buffer
57 * Default Constructor.
58 * Resulting URL is not valid
64 * Delete an external texture if if protocolType is TEXTURE.
70 * Determines type of visual and whether the url is local or remote
71 * Notify that it is using an external texture if if protocolType is TEXTURE.
73 * @param[in] url The URL to store and resolve
75 VisualUrl(const std::string& url);
79 * @param[in] url The VisualUrl to copy
81 VisualUrl(const VisualUrl& url);
85 * @param[in] url The VisualUrl to copy
87 VisualUrl& operator=(const VisualUrl& url);
91 * @param[in] url The VisualUrl to move
93 VisualUrl(VisualUrl&& url) noexcept;
96 * Move assignment operator
97 * @param[in] url The VisualUrl to move
99 VisualUrl& operator=(VisualUrl&& url) noexcept;
105 const std::string& GetUrl() const;
108 * Get the ellipsed URL.
109 * @return The ellipsed url
111 std::string GetEllipsedUrl() const;
114 * Get the hash value of full URL
115 * @return The hash value of url
117 std::uint64_t GetUrlHash() const;
120 * Get the visual type of the URL
121 * @return The visual type of the URL
123 Type GetType() const;
126 * Is the URL is local to the device, or remote?
127 * @return the location of the resource
129 ProtocolType GetProtocolType() const;
133 * @return true if the URL has length
135 bool IsValid() const;
138 * @return true if the location is LOCAL, i.e. is loadable from local file system
140 bool IsLocalResource() const;
143 * @return true if the location is BUFFER, i.e. may contain EncodedImageBuffer
145 bool IsBufferResource() const;
148 * @return the location part of the url
150 std::string GetLocation() const;
153 * @return the location part of the url without extension
155 std::string GetLocationWithoutExtension() const;
158 * Helper to create a URL of type TEXTURE
159 * @param location the location of the texture
162 static std::string CreateTextureUrl(const std::string& location);
165 * Helper to create a URL of type BUFFER
166 * @param[in] location the location of the texture
167 * @param[in] extension the extension of url
170 static std::string CreateBufferUrl(const std::string& location, const std::string_view& extension);
173 * Helper to get a ProtocolType from url
174 * @param url the url of the texture
175 * @return the protocol type
177 static VisualUrl::ProtocolType GetProtocolType(const std::string& url);
180 * Helper to get a location from url
181 * @param url the location of the texture
182 * @return the location
184 static std::string GetLocation(const std::string& url);
187 * Helper to get a location from url without extension
188 * @param[in] url the location of the texture
189 * @return the location without extension
191 static std::string GetLocationWithoutExtension(const std::string& url);
196 ProtocolType mLocation;
198 mutable std::uint64_t mUrlHash;
201 } // namespace Internal
203 } // namespace Toolkit
207 #endif /* DALI_TOOLKIT_INTERNAL_VISUAL_URL_H */