-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #151 from BishrutSubedi/biss/Uuid_builder
This PR adds UUID builder for uprotocol uuidv8
- Loading branch information
Showing
4 changed files
with
392 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// SPDX-FileCopyrightText: 2024 Contributors to the Eclipse Foundation | ||
// | ||
// See the NOTICE file(s) distributed with this work for additional | ||
// information regarding copyright ownership. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Apache License Version 2.0 which is available at | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#ifndef UP_CPP_DATAMODEL_UUID_CONSTANTS_H | ||
#define UP_CPP_DATAMODEL_UUID_CONSTANTS_H | ||
|
||
namespace uprotocol::datamodel { | ||
|
||
// Masks and shifts for various UUID fields | ||
constexpr uint64_t UUID_TIMESTAMP_MASK = 0xFFFFFFFFFFFF; | ||
constexpr uint64_t UUID_TIMESTAMP_SHIFT = 16; | ||
constexpr uint64_t UUID_VERSION_MASK = 0xF; | ||
constexpr uint64_t UUID_VERSION_SHIFT = 12; | ||
constexpr uint64_t UUID_VARIANT_MASK = 0x3; | ||
constexpr uint64_t UUID_VARIANT_SHIFT = 62; | ||
constexpr uint64_t UUID_COUNTER_MASK = 0xFFF; | ||
constexpr uint64_t UUID_RANDOM_MASK = 0x3FFFFFFFFFFFFFFF; | ||
|
||
// Constants for UUID version and variant | ||
constexpr uint8_t UUID_VERSION_8 = 8; | ||
constexpr uint8_t UUID_VARIANT_RFC4122 = 2; | ||
|
||
// Other constants | ||
constexpr uint32_t UUID_BYTE_SIZE = 16; | ||
constexpr uint32_t UUID_PART_SIZE = 4; | ||
constexpr uint32_t HEX_BASE = 16; | ||
constexpr uint64_t MASK_32_BITS = 0xFFFFFFFF; | ||
constexpr uint64_t MASK_16_BITS = 0xFFFF; | ||
constexpr uint64_t MASK_14_BITS = 0x3FFF; | ||
|
||
} // namespace uprotocol::datamodel | ||
|
||
#endif // UP_CPP_DATAMODEL_UUID_CONSTANTS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.