[dali_2.3.31] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / devel-api / common / hash.h
1 #ifndef DALI_HASH
2 #define DALI_HASH
3
4 /*
5  * Copyright (c) 2022 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 <string>
23 #include <vector>
24
25 //INTERNAL INCLUDES
26 #include <dali/public-api/common/dali-common.h>
27 #include <dali/public-api/common/dali-vector.h>
28
29 namespace Dali
30 {
31 enum
32 {
33   INITIAL_HASH_VALUE = 5381
34 };
35
36 /**
37  * @brief Create a hash code for a string
38  * @param toHash string to hash
39  * @return hash code
40  */
41 DALI_CORE_API std::size_t CalculateHash(const std::string& toHash);
42
43 /**
44  * @brief Create a hash code for 2 strings combined.
45  * Allows a hash to be calculated without concatenating the strings and allocating any memory.
46  * @param string1 first string
47  * @param string2 second string
48  * @return hash code
49  */
50 DALI_CORE_API std::size_t CalculateHash(const std::string& string1, const std::string& string2);
51
52 /**
53  * @brief Create a hash code for a string
54  * @param toHash string to hash
55  * @param terminator character terminating the hashing
56  * @return hash code
57  */
58 DALI_CORE_API std::size_t CalculateHash(const std::string& toHash, char terminator);
59
60 /**
61  * @brief Create a hash code for a std::vector<std::uint8_t>
62  * @param toHash list of std::uint8_t to hash
63  * @return hash code
64  */
65 DALI_CORE_API std::size_t CalculateHash(const std::vector<std::uint8_t>& toHash);
66
67 /**
68  * @brief Create a hash code for a Dali::Vector<std::uint8_t>
69  * @param toHash list of std::uint8_t to hash
70  * @return hash code
71  */
72 DALI_CORE_API std::size_t CalculateHash(const Dali::Vector<std::uint8_t>& toHash);
73
74 } // namespace Dali
75
76 #endif // DALI_HASH