[Tizen] Add support for FontClientFontPreLoad API
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / file-loader.h
1 #ifndef DALI_FILE_LOADER_H
2 #define DALI_FILE_LOADER_H
3
4 /*
5  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  */
19
20 // EXTERNAL INCLUDES
21 #include <dali/public-api/object/base-handle.h>
22 #include <string>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/dali-adaptor-common.h>
26
27 namespace Dali
28 {
29 namespace FileLoader
30 {
31 /**
32  * @brief File type formats
33  * The default format is binary
34  */
35 enum FileType ///< FileType format
36 {
37   BINARY, ///< File will be loaded as a binary
38   TEXT    ///< File will be loaded as text
39 };
40
41 /**
42  * @brief Load the file. It will load it either as a binary or as a text
43  *
44  * @param[in] filename  Filename of the file to load.
45  * @param[in] memblock  Dali::Vector containing the buffer loaded
46  * @param[in] fileType  How we want to load the file. Binary or Text. Binary default
47  * @return error code. 0 - Error, 1 - Ok
48  *
49  *
50  */
51 DALI_ADAPTOR_API int ReadFile(const std::string& filename, Dali::Vector<char>& memblock, FileLoader::FileType fileType = BINARY);
52
53 /**
54  * @brief Load the file. It will load it either as a binary or as a text
55  *
56  * @param[in] filename  Filename of the file to load.
57  * @param[in] memblock  Dali::Vector containing the buffer loaded
58  * @param[in] fileType  How we want to load the file. Binary or Text. Binary default
59  * @return error code. 0 - Error, 1 - Ok
60  *
61  *
62  */
63 DALI_ADAPTOR_API int ReadFile(const std::string& filename, Dali::Vector<uint8_t>& memblock, FileLoader::FileType fileType = BINARY);
64
65 /**
66  * @brief Load the file. It will load it either as a binary or as a text
67  *
68  * @param[in] filename  Filename of the file to load.
69  * @param[in] fileSize  Size of the loaded file
70  * @param[in] memblock  Dali::Vector containing the buffer loaded
71  * @param[in] fileType  How we want to load the file. Binary or Text. Binary default
72  * @return error code. 0 - Error, 1 - Ok
73  *
74  */
75 DALI_ADAPTOR_API int ReadFile(const std::string& filename, std::streampos& fileSize, Dali::Vector<char>& memblock, FileLoader::FileType fileType = BINARY);
76
77 /**
78  * @brief Load the file. It will load it either as a binary or as a text
79  *
80  * @param[in] filename  Filename of the file to load.
81  * @param[in] fileSize  Size of the loaded file
82  * @param[in] memblock  Dali::Vector containing the buffer loaded
83  * @param[in] fileType  How we want to load the file. Binary or Text. Binary default
84  * @return error code. 0 - Error, 1 - Ok
85  *
86  */
87 DALI_ADAPTOR_API int ReadFile(const std::string& filename, std::streampos& fileSize, Dali::Vector<uint8_t>& memblock, FileLoader::FileType fileType = BINARY);
88
89 /**
90  * @brief Get the file size of a file
91  *
92  * @param[in] filename  Filename of the file to load.
93  * @return the size of the file or 0 if file not found
94  */
95 DALI_ADAPTOR_API std::streampos GetFileSize(const std::string& filename);
96
97 /**
98  * @brief Download a requested file into a memory buffer.
99  *
100  * @param[in] filename  Filename of the file to download.
101  * @param[out] dataBuffer  A memory buffer object to be written with downloaded file data.
102  * @return error code. false - Error, true - Ok
103  */
104 DALI_ADAPTOR_API bool DownloadFileSynchronously(const std::string& filename, Dali::Vector<uint8_t>& dataBuffer);
105
106 }; // namespace FileLoader
107
108 } // namespace Dali
109 #endif // DALI_FILE_LOADER_H