constants.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_CBOR_CONSTANTS_H_
  5. #define COMPONENTS_CBOR_CONSTANTS_H_
  6. #include <stdint.h>
  7. namespace cbor {
  8. namespace constants {
  9. // Mask selecting the low-order 5 bits of the "initial byte", which is where
  10. // the additional information is encoded.
  11. static constexpr uint8_t kAdditionalInformationMask = 0x1F;
  12. // Mask selecting the high-order 3 bits of the "initial byte", which indicates
  13. // the major type of the encoded value.
  14. static constexpr uint8_t kMajorTypeMask = 0xE0;
  15. // Indicates the number of bits the "initial byte" needs to be shifted to the
  16. // right after applying |kMajorTypeMask| to produce the major type in the
  17. // lowermost bits.
  18. static constexpr uint8_t kMajorTypeBitShift = 5u;
  19. // Indicates the integer is in the following byte.
  20. static constexpr uint8_t kAdditionalInformation1Byte = 24u;
  21. // Indicates the integer is in the next 2 bytes.
  22. static constexpr uint8_t kAdditionalInformation2Bytes = 25u;
  23. // Indicates the integer is in the next 4 bytes.
  24. static constexpr uint8_t kAdditionalInformation4Bytes = 26u;
  25. // Indicates the integer is in the next 8 bytes.
  26. static constexpr uint8_t kAdditionalInformation8Bytes = 27u;
  27. extern const char kUnsupportedMajorType[];
  28. } // namespace constants
  29. } // namespace cbor
  30. #endif // COMPONENTS_CBOR_CONSTANTS_H_