2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "dali-scene3d/internal/loader/hash.h"
25 Hash::Hash(uint64_t initial)
30 Hash& Hash::Add(bool b)
32 mValue = Concatenate(b ? 0 : 1);
36 Hash& Hash::Add(int32_t i)
38 mValue = Concatenate(i);
42 Hash& Hash::Add(uint32_t i)
44 mValue = Concatenate(i);
48 Hash& Hash::Add(uint64_t i)
50 mValue = Concatenate(i);
54 Hash& Hash::Add(float f)
56 return AddObjectBytes(f);
59 Hash& Hash::Add(const char* cStr)
61 return Add(cStr, strlen(cStr));
64 Hash& Hash::Add(const char* cStr, size_t len)
66 auto i0 = reinterpret_cast<const uint8_t*>(cStr);
67 return AddBytes(i0, i0 + len);
70 Hash& Hash::Add(const std::string& str)
72 auto i0 = reinterpret_cast<const uint8_t*>(str.c_str());
73 return AddBytes(i0, i0 + str.size());
76 Hash& Hash::AddBytes(const uint8_t* i0, const uint8_t* i1)
80 mValue = Concatenate(*i0);
86 Hash::operator uint64_t() const
91 uint64_t Hash::Concatenate(uint64_t value)
93 return mValue * 31 + value;
97 } // namespace Scene3D