Merge "Replace std::string global variables with C-style string." into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / builder / base64-encoding.h
1 #ifndef DALI_TOOLKIT_BASE64_ENCODING_H
2 #define DALI_TOOLKIT_BASE64_ENCODING_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
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/vector-wrapper.h>
23 #include <dali/public-api/object/property.h>
24 #include <string_view>
25
26 // INTERNAL INCLUDES
27 #include <dali-toolkit/public-api/dali-toolkit-common.h>
28
29 namespace Dali
30 {
31 namespace Toolkit
32 {
33 /**
34  * @brief Parses a Property::STRING or Property::ARRAY of STRINGS to
35  * retrieve a block of uint32_t data.
36  *
37  * Data can be encoded using the base64 encoding scheme to allow it to be used
38  * in JSON (The property system maps to JSON types).
39  *
40  * @param[in] value The property value to decode
41  * @param[out] outputData The output data block
42  * @return True if a data block was decoded successfully.
43  */
44 DALI_TOOLKIT_API bool DecodeBase64PropertyData(const Property::Value& value, std::vector<uint32_t>& outputData);
45
46 /**
47  * @brief Parses a Property::STRING or Property::ARRAY of STRINGS to
48  * retrieve an array of uint8_t data.
49  *
50  * Data can be encoded using the base64 encoding scheme to allow it to be used
51  * in JSON (The property system maps to JSON types).
52  *
53  * @param[in] value The property value to decode
54  * @param[out] outputData The output data block
55  * @return True if a data block was decoded successfully.
56  */
57 DALI_TOOLKIT_API bool DecodeBase64PropertyData(const Property::Value& value, std::vector<uint8_t>& outputData);
58
59 /**
60  * @brief Parses a std::string_view to retrieve an array of uint8_t data.
61  *
62  * Data can be encoded using the base64 encoding scheme to allow it to be used
63  * in JSON (The property system maps to JSON types).
64  *
65  * @param[in] encodedString The input string to decode
66  * @param[out] outputData The output data block
67  * @return True if a data block was decoded successfully.
68  */
69 DALI_TOOLKIT_API bool DecodeBase64FromString(const std::string_view& encodedString, std::vector<uint8_t>& outputData);
70
71 /**
72  * @brief Convert a block of uint32_t data into a Property::STRING or ARRAY of STRINGs
73  * encoded using base64. This allows the data to be mapped to JSON easily.
74  *
75  * @param[out] value The value to write data into (to avoid copying).
76  * @param[in] inputData The input
77  */
78 DALI_TOOLKIT_API void EncodeBase64PropertyData(Property::Value& value, const std::vector<uint32_t>& inputData);
79
80 /**
81  * @brief Convert a block of uint8_t data into a Property::STRING or ARRAY of STRINGs
82  * encoded using base64. This allows the data to be mapped to JSON easily.
83  *
84  * @param[out] value The value to write data into (to avoid copying).
85  * @param[in] inputData The input
86  */
87 DALI_TOOLKIT_API void EncodeBase64PropertyData(Property::Value& value, const std::vector<uint8_t>& inputData);
88
89 } // namespace Toolkit
90
91 } // namespace Dali
92
93 #endif // DALI_TOOLKIT_BASE64_ENCODING_H