2 * Copyright (c) 2021 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-scene-loader/internal/hash.h"
23 Hash::Hash(uint64_t initial)
28 Hash& Hash::Add(bool b)
30 mValue = Concatenate(b ? 0 : 1);
34 Hash& Hash::Add(int32_t i)
36 mValue = Concatenate(i);
40 Hash& Hash::Add(uint32_t i)
42 mValue = Concatenate(i);
46 Hash& Hash::Add(uint64_t i)
48 mValue = Concatenate(i);
52 Hash& Hash::Add(float f)
54 return AddObjectBytes(f);
57 Hash& Hash::Add(const char* cStr)
59 return Add(cStr, strlen(cStr));
62 Hash& Hash::Add(const char* cStr, size_t len)
64 auto i0 = reinterpret_cast<const uint8_t*>(cStr);
65 return AddBytes(i0, i0 + len);
68 Hash& Hash::Add(const std::string& str)
70 auto i0 = reinterpret_cast<const uint8_t*>(str.c_str());
71 return AddBytes(i0, i0 + str.size());
74 Hash& Hash::AddBytes(const uint8_t* i0, const uint8_t* i1)
78 mValue = Concatenate(*i0);
84 Hash::operator uint64_t() const
89 uint64_t Hash::Concatenate(uint64_t value)
91 return mValue * 31 + value;
94 } // namespace SceneLoader