1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 20 #ifndef CBORCONSTANTS_P_H 21 #define CBORCONSTANTS_P_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* 28 * CBOR Major types 29 * Encoded in the high 3 bits of the descriptor byte 30 * See http://tools.ietf.org/html/rfc7049#section-2.1 31 */ 32 typedef enum CborMajorTypes { 33 UnsignedIntegerType = 0U, 34 NegativeIntegerType = 1U, 35 ByteStringType = 2U, 36 TextStringType = 3U, 37 ArrayType = 4U, 38 MapType = 5U, /* a.k.a. object */ 39 TagType = 6U, 40 SimpleTypesType = 7U 41 } CborMajorTypes; 42 43 /* 44 * CBOR simple and floating point types 45 * Encoded in the low 8 bits of the descriptor byte when the 46 * Major Type is 7. 47 */ 48 typedef enum CborSimpleTypes { 49 FalseValue = 20, 50 TrueValue = 21, 51 NullValue = 22, 52 UndefinedValue = 23, 53 SimpleTypeInNextByte = 24, /* not really a simple type */ 54 HalfPrecisionFloat = 25, /* ditto */ 55 SinglePrecisionFloat = 26, /* ditto */ 56 DoublePrecisionFloat = 27, /* ditto */ 57 Break = 31 58 } CborSimpleTypes; 59 60 enum { 61 SmallValueBitLength = 5U, 62 SmallValueMask = (1U << SmallValueBitLength) - 1, /* 31 */ 63 Value8Bit = 24U, 64 Value16Bit = 25U, 65 Value32Bit = 26U, 66 Value64Bit = 27U, 67 IndefiniteLength = 31U, 68 69 MajorTypeShift = SmallValueBitLength, 70 MajorTypeMask = ~0U << MajorTypeShift, 71 72 BreakByte = (unsigned)Break | (SimpleTypesType << MajorTypeShift) 73 }; 74 75 #ifdef __cplusplus 76 } 77 #endif 78 79 #endif /* CBORCONSTANTS_P_H */ 80