clang-format: copy latest and re-format
clang-format-17 has some backwards incompatible changes that require
additional settings for best compatibility and re-running the formatter.
Copy the latest .clang-format from the docs repository and reformat the
repository.
Change-Id: If45530480fdd7acb46a6a1b116187bcfcd90ac83
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/.clang-format b/.clang-format
index d92a3f1..d43e884 100644
--- a/.clang-format
+++ b/.clang-format
@@ -14,26 +14,30 @@
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
-AllowShortIfStatementsOnASingleLine: false
+AllowShortIfStatementsOnASingleLine: Never
+AllowShortLambdasOnASingleLine: true
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
+BitFieldColonSpacing: None
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
+ AfterExternBlock: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
- AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
+ BeforeLambdaBody: false
+ BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
@@ -48,17 +52,16 @@
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
-ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
-DeriveLineEnding: false
DerivePointerAlignment: false
-PointerAlignment: Left
DisableFormat: false
-ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
-ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
+ForEachMacros:
+ - foreach
+ - Q_FOREACH
+ - BOOST_FOREACH
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^[<"](gtest|gmock)'
@@ -78,6 +81,7 @@
- Regex: '.*'
Priority: 6
IndentCaseLabels: true
+IndentExternBlock: NoIndent
IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: true
@@ -92,6 +96,7 @@
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
+PackConstructorInitializers: BinPack
PenaltyBreakAssignment: 25
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
@@ -100,12 +105,13 @@
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PenaltyIndentedWhitespace: 0
+PointerAlignment: Left
QualifierAlignment: Left
ReferenceAlignment: Left
ReflowComments: true
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: Keyword
-SortIncludes: true
+SortIncludes: CaseSensitive
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
@@ -117,7 +123,7 @@
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
-SpacesInAngles: false
+SpacesInAngles: Never
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
diff --git a/include/libbej/bej_common.h b/include/libbej/bej_common.h
index 6db5fd1..66003f7 100644
--- a/include/libbej/bej_common.h
+++ b/include/libbej/bej_common.h
@@ -43,235 +43,235 @@
} \
} while (0)
+/**
+ * @brief RDE BEJ decoding errors.
+ */
+enum BejError
+{
+ bejErrorNoError = 0,
+ bejErrorUnknown,
+ bejErrorInvalidSize,
+ bejErrorNotSuppoted,
+ bejErrorUnknownProperty,
+ bejErrorInvalidSchemaType,
+ bejErrorInvalidPropertyOffset,
+ bejErrorNullParameter,
+};
+
+/**
+ * @brief BEJ schema classes.
+ */
+enum BejSchemaClass
+{
+ bejMajorSchemaClass = 0,
+ bejEventSchemaClass = 1,
+ bejAnnotationSchemaClass = 2,
+ bejCollectionMemberTypeSchemaClass = 3,
+ bejErrorSchemaClass = 4,
+};
+
+/**
+ * @brief BEJ data types supported in BEJ version 0xF1F0F000.
+ */
+enum BejPrincipalDataType
+{
+ bejSet = 0,
+ bejArray = 1,
+ bejNull = 2,
+ bejInteger = 3,
+ bejEnum = 4,
+ bejString = 5,
+ bejReal = 6,
+ bejBoolean = 7,
+ bejBytestring = 8,
+ bejChoice = 9,
+ bejPropertyAnnotation = 10,
+ bejPrincipalDataReserved1 = 11,
+ bejPrincipalDataReserved2 = 12,
+ bejPrincipalDataReserved3 = 13,
+ bejResourceLink = 14,
+ bejResourceLinkExpansion = 15,
+};
+
+/**
+ * @brief Format BEJ tuple.
+ */
+struct BejTupleF
+{
+ uint8_t deferredBinding:1;
+ uint8_t readOnlyProperty:1;
+ uint8_t nullableProperty:1;
+ uint8_t reserved:1;
+ enum BejPrincipalDataType principalDataType:4;
+} __attribute__((__packed__));
+
+/**
+ * @brief Sequence Number BEJ tuple.
+ */
+struct BejTupleS
+{
+ uint8_t schema;
+ // Dictionaries contain 16bit sequence numbers. So allocating 16bits for
+ // the sequence number here.
+ uint16_t sequenceNumber;
+};
+
+/**
+ * @brief Represent offsets of Format, Value Length and Value of a SFLV
+ * tuple.
+ */
+struct BejSFLVOffset
+{
+ uint32_t formatOffset;
+ uint32_t valueLenNnintOffset;
+ uint32_t valueOffset;
+};
+
+/**
+ * @brief Fields in Bej Real data type.
+ */
+struct BejReal
+{
+ // Number bytes in exp.
+ uint8_t expLen;
+ int64_t whole;
+ uint64_t zeroCount;
+ uint64_t fract;
+ int64_t exp;
+};
+
+/**
+ * @brief SFLV BEJ tuple infomation.
+ */
+struct BejSFLV
+{
+ struct BejTupleS tupleS;
+ struct BejTupleF format;
+ // Value portion size in bytes.
+ uint32_t valueLength;
+ // Value end-offset with respect to the begining of the encoded stream.
+ uint32_t valueEndOffset;
+ // Pointer to the value.
+ const uint8_t* value;
+};
+
+/**
+ * @brief bejEncoding PLDM data type header.
+ */
+struct BejPldmBlockHeader
+{
+ uint32_t bejVersion;
+ uint16_t reserved;
+ uint8_t schemaClass;
+} __attribute__((__packed__));
+
+/**
+ * @brief Points to dictionaries used for encoding and decoding.
+ */
+struct BejDictionaries
+{
+ const uint8_t* schemaDictionary;
+ const uint8_t* annotationDictionary;
+ const uint8_t* errorDictionary;
+};
+
+/**
+ * @brief Callbacks to a stack that can store pointers.
+ */
+struct BejPointerStackCallback
+{
/**
- * @brief RDE BEJ decoding errors.
+ * @brief A context for the stack.
*/
- enum BejError
- {
- bejErrorNoError = 0,
- bejErrorUnknown,
- bejErrorInvalidSize,
- bejErrorNotSuppoted,
- bejErrorUnknownProperty,
- bejErrorInvalidSchemaType,
- bejErrorInvalidPropertyOffset,
- bejErrorNullParameter,
- };
+ void* stackContext;
/**
- * @brief BEJ schema classes.
+ * @brief Return true if the stack is empty.
*/
- enum BejSchemaClass
- {
- bejMajorSchemaClass = 0,
- bejEventSchemaClass = 1,
- bejAnnotationSchemaClass = 2,
- bejCollectionMemberTypeSchemaClass = 3,
- bejErrorSchemaClass = 4,
- };
+ bool (*stackEmpty)(void* stackContext);
/**
- * @brief BEJ data types supported in BEJ version 0xF1F0F000.
+ * @brief View the pointer at the top of the stack. If the stack is
+ * empty, this will return NULL.
*/
- enum BejPrincipalDataType
- {
- bejSet = 0,
- bejArray = 1,
- bejNull = 2,
- bejInteger = 3,
- bejEnum = 4,
- bejString = 5,
- bejReal = 6,
- bejBoolean = 7,
- bejBytestring = 8,
- bejChoice = 9,
- bejPropertyAnnotation = 10,
- bejPrincipalDataReserved1 = 11,
- bejPrincipalDataReserved2 = 12,
- bejPrincipalDataReserved3 = 13,
- bejResourceLink = 14,
- bejResourceLinkExpansion = 15,
- };
+ void* (*stackPeek)(void* stackContext);
/**
- * @brief Format BEJ tuple.
+ * @brief Returns and removes the top most pointer from the stack. The
+ * Client of the libbej is responsible for destroying the memory used
+ * for storing the removed pointer (not the memory pointed by the
+ * pointer).
*/
- struct BejTupleF
- {
- uint8_t deferredBinding : 1;
- uint8_t readOnlyProperty : 1;
- uint8_t nullableProperty : 1;
- uint8_t reserved : 1;
- enum BejPrincipalDataType principalDataType : 4;
- } __attribute__((__packed__));
+ void* (*stackPop)(void* stackContext);
/**
- * @brief Sequence Number BEJ tuple.
+ * @brief Push a pointer into the stack. Returns 0 if the operation is
+ * successful. Client of this API is responsible for allocating memory
+ * for storing the new pointer.
*/
- struct BejTupleS
- {
- uint8_t schema;
- // Dictionaries contain 16bit sequence numbers. So allocating 16bits for
- // the sequence number here.
- uint16_t sequenceNumber;
- };
+ int (*stackPush)(void* p, void* stackContext);
/**
- * @brief Represent offsets of Format, Value Length and Value of a SFLV
- * tuple.
+ * @brief Delete the stack.
*/
- struct BejSFLVOffset
- {
- uint32_t formatOffset;
- uint32_t valueLenNnintOffset;
- uint32_t valueOffset;
- };
+ void (*deleteStack)(void* stackContext);
+};
- /**
- * @brief Fields in Bej Real data type.
- */
- struct BejReal
- {
- // Number bytes in exp.
- uint8_t expLen;
- int64_t whole;
- uint64_t zeroCount;
- uint64_t fract;
- int64_t exp;
- };
+/**
+ * @brief Get the unsigned integer value from provided bytes.
+ *
+ * @param[in] bytes - valid pointer to a byte stream in little-endian
+ * format.
+ * @param[in] numOfBytes - number of bytes belongs to the value. Maximum
+ * number of bytes supported is 8. If numOfBytes > 8, the result is
+ * undefined.
+ * @return unsigend 64bit representation of the value.
+ */
+uint64_t bejGetUnsignedInteger(const uint8_t* bytes, uint8_t numOfBytes);
- /**
- * @brief SFLV BEJ tuple infomation.
- */
- struct BejSFLV
- {
- struct BejTupleS tupleS;
- struct BejTupleF format;
- // Value portion size in bytes.
- uint32_t valueLength;
- // Value end-offset with respect to the begining of the encoded stream.
- uint32_t valueEndOffset;
- // Pointer to the value.
- const uint8_t* value;
- };
+/**
+ * @brief Get the value from nnint type.
+ *
+ * @param[in] nnint - nnint should be pointing to a valid nnint.
+ * @return unsigend 64bit representation of the value.
+ */
+uint64_t bejGetNnint(const uint8_t* nnint);
- /**
- * @brief bejEncoding PLDM data type header.
- */
- struct BejPldmBlockHeader
- {
- uint32_t bejVersion;
- uint16_t reserved;
- uint8_t schemaClass;
- } __attribute__((__packed__));
+/**
+ * @brief Get the size of the complete nnint.
+ *
+ * @param[in] nnint - pointer to a valid nnint.
+ * @return size of the complete nnint.
+ */
+uint8_t bejGetNnintSize(const uint8_t* nnint);
- /**
- * @brief Points to dictionaries used for encoding and decoding.
- */
- struct BejDictionaries
- {
- const uint8_t* schemaDictionary;
- const uint8_t* annotationDictionary;
- const uint8_t* errorDictionary;
- };
+/**
+ * @brief Get the bytes needed represent the value as a bejInteger.
+ *
+ * This will return the number of bytes needed to encode the signed value
+ * into a bejInteger type.
+ *
+ * @param val - signed value needed to encode.
+ * @return size of the bejInteger.
+ */
+uint8_t bejIntLengthOfValue(int64_t val);
- /**
- * @brief Callbacks to a stack that can store pointers.
- */
- struct BejPointerStackCallback
- {
- /**
- * @brief A context for the stack.
- */
- void* stackContext;
+/**
+ * @brief Get the total bytes needed to encode an unsigned value using nnint
+ * format.
+ *
+ * @param[in] val - unsigned value needed to encode.
+ * @return size of the nnint value.
+ */
+uint8_t bejNnintEncodingSizeOfUInt(uint64_t val);
- /**
- * @brief Return true if the stack is empty.
- */
- bool (*stackEmpty)(void* stackContext);
-
- /**
- * @brief View the pointer at the top of the stack. If the stack is
- * empty, this will return NULL.
- */
- void* (*stackPeek)(void* stackContext);
-
- /**
- * @brief Returns and removes the top most pointer from the stack. The
- * Client of the libbej is responsible for destroying the memory used
- * for storing the removed pointer (not the memory pointed by the
- * pointer).
- */
- void* (*stackPop)(void* stackContext);
-
- /**
- * @brief Push a pointer into the stack. Returns 0 if the operation is
- * successful. Client of this API is responsible for allocating memory
- * for storing the new pointer.
- */
- int (*stackPush)(void* p, void* stackContext);
-
- /**
- * @brief Delete the stack.
- */
- void (*deleteStack)(void* stackContext);
- };
-
- /**
- * @brief Get the unsigned integer value from provided bytes.
- *
- * @param[in] bytes - valid pointer to a byte stream in little-endian
- * format.
- * @param[in] numOfBytes - number of bytes belongs to the value. Maximum
- * number of bytes supported is 8. If numOfBytes > 8, the result is
- * undefined.
- * @return unsigend 64bit representation of the value.
- */
- uint64_t bejGetUnsignedInteger(const uint8_t* bytes, uint8_t numOfBytes);
-
- /**
- * @brief Get the value from nnint type.
- *
- * @param[in] nnint - nnint should be pointing to a valid nnint.
- * @return unsigend 64bit representation of the value.
- */
- uint64_t bejGetNnint(const uint8_t* nnint);
-
- /**
- * @brief Get the size of the complete nnint.
- *
- * @param[in] nnint - pointer to a valid nnint.
- * @return size of the complete nnint.
- */
- uint8_t bejGetNnintSize(const uint8_t* nnint);
-
- /**
- * @brief Get the bytes needed represent the value as a bejInteger.
- *
- * This will return the number of bytes needed to encode the signed value
- * into a bejInteger type.
- *
- * @param val - signed value needed to encode.
- * @return size of the bejInteger.
- */
- uint8_t bejIntLengthOfValue(int64_t val);
-
- /**
- * @brief Get the total bytes needed to encode an unsigned value using nnint
- * format.
- *
- * @param[in] val - unsigned value needed to encode.
- * @return size of the nnint value.
- */
- uint8_t bejNnintEncodingSizeOfUInt(uint64_t val);
-
- /**
- * @brief Get the length field value of the unsigned value nnint encoding.
- *
- * @param val - unsigned value needed to encode.
- * @return value of the length field in the encoded nnint.
- */
- uint8_t bejNnintLengthFieldOfUInt(uint64_t val);
+/**
+ * @brief Get the length field value of the unsigned value nnint encoding.
+ *
+ * @param val - unsigned value needed to encode.
+ * @return value of the length field in the encoded nnint.
+ */
+uint8_t bejNnintLengthFieldOfUInt(uint64_t val);
#ifdef __cplusplus
}
diff --git a/include/libbej/bej_decoder_core.h b/include/libbej/bej_decoder_core.h
index 5e226c1..919c396 100644
--- a/include/libbej/bej_decoder_core.h
+++ b/include/libbej/bej_decoder_core.h
@@ -11,205 +11,203 @@
{
#endif
+/**
+ * @brief Indicates whether a new BEJ section falls inside a BEJ array or a
+ * BEJ set or none of those.
+ */
+enum BejSectionType
+{
+ bejSectionNoType,
+ bejSectionSet,
+ bejSectionArray,
+};
+
+/**
+ * @brief These stack entries are needed to implement the decoding
+ * non-recursively.
+ */
+struct BejStackProperty
+{
+ // Indicates whether we are inside an array or a set or an annotation.
+ enum BejSectionType sectionType;
+ // Indicate whether we have property names for properties.
+ bool addPropertyName;
+ // Offset to the parent property in schema dictionary.
+ uint16_t mainDictPropOffset;
+ // Offset to the parent property in annotation dictionary.
+ uint16_t annoDictPropOffset;
+ // Offset to the end of the array or set or annotation.
+ uint32_t streamEndOffset;
+};
+
+/**
+ * @brief Holds the information related to the current bejTuple being
+ * decoded.
+ */
+struct BejDecoderStates
+{
+ bool addPropertyName;
+ uint16_t mainDictPropOffset;
+ uint16_t annoDictPropOffset;
+ uint32_t encodedStreamOffset;
+ const uint8_t* encodedSubStream;
+};
+
+/**
+ * @brief Callbacks for decoded data.
+ *
+ * dataPtr in the callback functions can be used for extra arguments.
+ */
+struct BejDecodedCallback
+{
/**
- * @brief Indicates whether a new BEJ section falls inside a BEJ array or a
- * BEJ set or none of those.
+ * @brief Calls when a Set is detected.
*/
- enum BejSectionType
- {
- bejSectionNoType,
- bejSectionSet,
- bejSectionArray,
- };
+ int (*callbackSetStart)(const char* propertyName, void* dataPtr);
/**
- * @brief These stack entries are needed to implement the decoding
- * non-recursively.
+ * @brief Calls when an end of a Set is found.
*/
- struct BejStackProperty
- {
- // Indicates whether we are inside an array or a set or an annotation.
- enum BejSectionType sectionType;
- // Indicate whether we have property names for properties.
- bool addPropertyName;
- // Offset to the parent property in schema dictionary.
- uint16_t mainDictPropOffset;
- // Offset to the parent property in annotation dictionary.
- uint16_t annoDictPropOffset;
- // Offset to the end of the array or set or annotation.
- uint32_t streamEndOffset;
- };
+ int (*callbackSetEnd)(void* dataPtr);
/**
- * @brief Holds the information related to the current bejTuple being
- * decoded.
+ * @brief Calls when an array is detected.
*/
- struct BejDecoderStates
- {
- bool addPropertyName;
- uint16_t mainDictPropOffset;
- uint16_t annoDictPropOffset;
- uint32_t encodedStreamOffset;
- const uint8_t* encodedSubStream;
- };
+ int (*callbackArrayStart)(const char* propertyName, void* dataPtr);
/**
- * @brief Callbacks for decoded data.
- *
- * dataPtr in the callback functions can be used for extra arguments.
+ * @brief Calls when an end of an array is found.
*/
- struct BejDecodedCallback
- {
- /**
- * @brief Calls when a Set is detected.
- */
- int (*callbackSetStart)(const char* propertyName, void* dataPtr);
-
- /**
- * @brief Calls when an end of a Set is found.
- */
- int (*callbackSetEnd)(void* dataPtr);
-
- /**
- * @brief Calls when an array is detected.
- */
- int (*callbackArrayStart)(const char* propertyName, void* dataPtr);
-
- /**
- * @brief Calls when an end of an array is found.
- */
- int (*callbackArrayEnd)(void* dataPtr);
-
- /**
- * @brief Calls after a property is finished unless this is the last
- * property in a Set or an array. In that case appropriate
- * callbackSetEnd or callbackArrayEnd will be called.
- */
- int (*callbackPropertyEnd)(void* dataPtr);
-
- /**
- * @brief Calls when a Null property is found or the property length is
- * 0.
- */
- int (*callbackNull)(const char* propertyName, void* dataPtr);
-
- /**
- * @brief Calls when an Integer property is found.
- */
- int (*callbackInteger)(const char* propertyName, int64_t value,
- void* dataPtr);
-
- /**
- * @brief Calls when an Enum property is found.
- */
- int (*callbackEnum)(const char* propertyName, const char* value,
- void* dataPtr);
-
- /**
- * @brief Calls when a String property is found.
- */
- int (*callbackString)(const char* propertyName, const char* value,
- void* dataPtr);
-
- /**
- * @brief Calls when a Real value property is found.
- */
- int (*callbackReal)(const char* propertyName,
- const struct BejReal* value, void* dataPtr);
-
- /**
- * @brief Calls when a Bool property is found.
- */
- int (*callbackBool)(const char* propertyName, bool value,
- void* dataPtr);
-
- /**
- * @brief Calls when an Annotated property is found.
- */
- int (*callbackAnnotation)(const char* propertyName, void* dataPtr);
-
- /**
- * @brief Calls when a read only property is found.
- */
- int (*callbackReadonlyProperty)(uint32_t sequenceNumber, void* dataPtr);
- };
+ int (*callbackArrayEnd)(void* dataPtr);
/**
- * @brief Stack for holding BejStackProperty types. Decoder core is not
- * responsible for creating or deleting stack memory. User of the decoder
- * core is responsible for creating and deleting stack memory.
- *
- * dataPtr in the callback functions can be used for extra arguments.
+ * @brief Calls after a property is finished unless this is the last
+ * property in a Set or an array. In that case appropriate
+ * callbackSetEnd or callbackArrayEnd will be called.
*/
- struct BejStackCallback
- {
- /**
- * @brief Return true if the stack is empty.
- */
- bool (*stackEmpty)(void* dataPtr);
-
- /**
- * @brief View the object at the top of the stack. If the stack is
- * empty, this will return NULL.
- */
- const struct BejStackProperty* (*stackPeek)(void* dataPtr);
-
- /**
- * @brief Removes the top most object from the stack. Client of the
- * decoder core is responsible for destroying the memory for the removed
- * object.
- */
- void (*stackPop)(void* dataPtr);
-
- /**
- * @brief Push an object into the stack. Returns 0 if the operation is
- * successfull. Client of the decoder core is responsible for allocating
- * memory for the new object.
- */
- int (*stackPush)(const struct BejStackProperty* const property,
- void* dataPtr);
- };
+ int (*callbackPropertyEnd)(void* dataPtr);
/**
- * @brief Used to pass parameters to BEJ decoding local functions.
+ * @brief Calls when a Null property is found or the property length is
+ * 0.
*/
- struct BejHandleTypeFuncParam
- {
- struct BejDecoderStates state;
- struct BejSFLV sflv;
- const uint8_t* mainDictionary;
- const uint8_t* annotDictionary;
- const struct BejDecodedCallback* decodedCallback;
- const struct BejStackCallback* stackCallback;
- void* callbacksDataPtr;
- void* stackDataPtr;
- };
+ int (*callbackNull)(const char* propertyName, void* dataPtr);
/**
- * @brief Decodes a PLDM block. Maximum encoded stream size the decoder
- * supports is 32bits.
- *
- * @param[in] dictionaries - dictionaries needed for decoding.
- * @param[in] encodedPldmBlock - encoded PLDM block.
- * @param[in] blockLength - length of the PLDM block.
- * @param[in] stackCallback - callbacks for stack handlers. callbacks in
- * stackCallback struct should be set to valid functions.
- * @param[in] decodedCallback - callbacks for extracting decoded
- * properties. callbacks in decodedCallback struct should be set to
- * NULL or valid functions.
- * @param[in] callbacksDataPtr - data pointer to pass to decoded callbacks.
- * This can be used pass additional data.
- * @param[in] stackDataPtr - data pointer to pass to stack callbacks. This
- * can be used pass additional data.
- *
- * @return 0 if successful.
+ * @brief Calls when an Integer property is found.
*/
- int bejDecodePldmBlock(const struct BejDictionaries* dictionaries,
- const uint8_t* encodedPldmBlock,
- uint32_t blockLength,
- const struct BejStackCallback* stackCallback,
- const struct BejDecodedCallback* decodedCallback,
- void* callbacksDataPtr, void* stackDataPtr);
+ int (*callbackInteger)(const char* propertyName, int64_t value,
+ void* dataPtr);
+
+ /**
+ * @brief Calls when an Enum property is found.
+ */
+ int (*callbackEnum)(const char* propertyName, const char* value,
+ void* dataPtr);
+
+ /**
+ * @brief Calls when a String property is found.
+ */
+ int (*callbackString)(const char* propertyName, const char* value,
+ void* dataPtr);
+
+ /**
+ * @brief Calls when a Real value property is found.
+ */
+ int (*callbackReal)(const char* propertyName, const struct BejReal* value,
+ void* dataPtr);
+
+ /**
+ * @brief Calls when a Bool property is found.
+ */
+ int (*callbackBool)(const char* propertyName, bool value, void* dataPtr);
+
+ /**
+ * @brief Calls when an Annotated property is found.
+ */
+ int (*callbackAnnotation)(const char* propertyName, void* dataPtr);
+
+ /**
+ * @brief Calls when a read only property is found.
+ */
+ int (*callbackReadonlyProperty)(uint32_t sequenceNumber, void* dataPtr);
+};
+
+/**
+ * @brief Stack for holding BejStackProperty types. Decoder core is not
+ * responsible for creating or deleting stack memory. User of the decoder
+ * core is responsible for creating and deleting stack memory.
+ *
+ * dataPtr in the callback functions can be used for extra arguments.
+ */
+struct BejStackCallback
+{
+ /**
+ * @brief Return true if the stack is empty.
+ */
+ bool (*stackEmpty)(void* dataPtr);
+
+ /**
+ * @brief View the object at the top of the stack. If the stack is
+ * empty, this will return NULL.
+ */
+ const struct BejStackProperty* (*stackPeek)(void* dataPtr);
+
+ /**
+ * @brief Removes the top most object from the stack. Client of the
+ * decoder core is responsible for destroying the memory for the removed
+ * object.
+ */
+ void (*stackPop)(void* dataPtr);
+
+ /**
+ * @brief Push an object into the stack. Returns 0 if the operation is
+ * successfull. Client of the decoder core is responsible for allocating
+ * memory for the new object.
+ */
+ int (*stackPush)(const struct BejStackProperty* const property,
+ void* dataPtr);
+};
+
+/**
+ * @brief Used to pass parameters to BEJ decoding local functions.
+ */
+struct BejHandleTypeFuncParam
+{
+ struct BejDecoderStates state;
+ struct BejSFLV sflv;
+ const uint8_t* mainDictionary;
+ const uint8_t* annotDictionary;
+ const struct BejDecodedCallback* decodedCallback;
+ const struct BejStackCallback* stackCallback;
+ void* callbacksDataPtr;
+ void* stackDataPtr;
+};
+
+/**
+ * @brief Decodes a PLDM block. Maximum encoded stream size the decoder
+ * supports is 32bits.
+ *
+ * @param[in] dictionaries - dictionaries needed for decoding.
+ * @param[in] encodedPldmBlock - encoded PLDM block.
+ * @param[in] blockLength - length of the PLDM block.
+ * @param[in] stackCallback - callbacks for stack handlers. callbacks in
+ * stackCallback struct should be set to valid functions.
+ * @param[in] decodedCallback - callbacks for extracting decoded
+ * properties. callbacks in decodedCallback struct should be set to
+ * NULL or valid functions.
+ * @param[in] callbacksDataPtr - data pointer to pass to decoded callbacks.
+ * This can be used pass additional data.
+ * @param[in] stackDataPtr - data pointer to pass to stack callbacks. This
+ * can be used pass additional data.
+ *
+ * @return 0 if successful.
+ */
+int bejDecodePldmBlock(const struct BejDictionaries* dictionaries,
+ const uint8_t* encodedPldmBlock, uint32_t blockLength,
+ const struct BejStackCallback* stackCallback,
+ const struct BejDecodedCallback* decodedCallback,
+ void* callbacksDataPtr, void* stackDataPtr);
#ifdef __cplusplus
}
diff --git a/include/libbej/bej_dictionary.h b/include/libbej/bej_dictionary.h
index ddfaa81..b22404d 100644
--- a/include/libbej/bej_dictionary.h
+++ b/include/libbej/bej_dictionary.h
@@ -20,101 +20,100 @@
*/
#define DICTIONARY_SEQ_NUM_SHIFT 1
- /**
- * @brief BEJ dictionary type.
- */
- enum BejDictionaryType
- {
- bejPrimary = 0,
- bejAnnotation = 1,
- };
+/**
+ * @brief BEJ dictionary type.
+ */
+enum BejDictionaryType
+{
+ bejPrimary = 0,
+ bejAnnotation = 1,
+};
- /**
- * @brief Dictionary property header.
- */
- struct BejDictionaryProperty
- {
- struct BejTupleF format;
- uint16_t sequenceNumber;
- uint16_t childPointerOffset;
- uint16_t childCount;
- uint8_t nameLength;
- uint16_t nameOffset;
- } __attribute__((__packed__));
+/**
+ * @brief Dictionary property header.
+ */
+struct BejDictionaryProperty
+{
+ struct BejTupleF format;
+ uint16_t sequenceNumber;
+ uint16_t childPointerOffset;
+ uint16_t childCount;
+ uint8_t nameLength;
+ uint16_t nameOffset;
+} __attribute__((__packed__));
- struct BejDictionaryHeader
- {
- uint8_t versionTag;
- uint8_t truncationFlag : 1;
- uint8_t reservedFlags : 7;
- uint16_t entryCount;
- uint32_t schemaVersion;
- uint32_t dictionarySize;
- } __attribute__((__packed__));
+struct BejDictionaryHeader
+{
+ uint8_t versionTag;
+ uint8_t truncationFlag:1;
+ uint8_t reservedFlags:7;
+ uint16_t entryCount;
+ uint32_t schemaVersion;
+ uint32_t dictionarySize;
+} __attribute__((__packed__));
- /**
- * @brief Get the offset of the first property in a dictionary.
- *
- * @return the offset to the first property.
- */
- uint16_t bejDictGetPropertyHeadOffset();
+/**
+ * @brief Get the offset of the first property in a dictionary.
+ *
+ * @return the offset to the first property.
+ */
+uint16_t bejDictGetPropertyHeadOffset();
- /**
- * @brief Get the offset of the first annotated property in an annoation
- * dictionary.
- *
- * @return the offset to the first annotated property in an annoation
- * dictionary.
- */
- uint16_t bejDictGetFirstAnnotatedPropertyOffset();
+/**
+ * @brief Get the offset of the first annotated property in an annoation
+ * dictionary.
+ *
+ * @return the offset to the first annotated property in an annoation
+ * dictionary.
+ */
+uint16_t bejDictGetFirstAnnotatedPropertyOffset();
- /**
- * @brief Get the property related to the given sequence number.
- *
- * @param[in] dictionary - dictionary containing the sequence number.
- * @param[in] startingPropertyOffset - offset of the starting property for
- * the search.
- * @param[in] sequenceNumber - sequence number of the property.
- * @param[out] property - if the search is successful, this will point to a
- * valid property.
- * @return 0 if successful.
- */
- int bejDictGetProperty(const uint8_t* dictionary,
- uint16_t startingPropertyOffset,
- uint16_t sequenceNumber,
- const struct BejDictionaryProperty** property);
+/**
+ * @brief Get the property related to the given sequence number.
+ *
+ * @param[in] dictionary - dictionary containing the sequence number.
+ * @param[in] startingPropertyOffset - offset of the starting property for
+ * the search.
+ * @param[in] sequenceNumber - sequence number of the property.
+ * @param[out] property - if the search is successful, this will point to a
+ * valid property.
+ * @return 0 if successful.
+ */
+int bejDictGetProperty(const uint8_t* dictionary,
+ uint16_t startingPropertyOffset, uint16_t sequenceNumber,
+ const struct BejDictionaryProperty** property);
- /**
- * @brief Get the name of a property.
- *
- * @param[in] dictionary - dictionary containing the property.
- * @param[in] nameOffset - dictionary offset of the name.
- * @param[in] nameLength - length of the name.
- * @return a NULL terminated string. If the nameLength is 0, this will
- * return an empty string.
- */
- const char* bejDictGetPropertyName(const uint8_t* dictionary,
- uint16_t nameOffset, uint8_t nameLength);
+/**
+ * @brief Get the name of a property.
+ *
+ * @param[in] dictionary - dictionary containing the property.
+ * @param[in] nameOffset - dictionary offset of the name.
+ * @param[in] nameLength - length of the name.
+ * @return a NULL terminated string. If the nameLength is 0, this will
+ * return an empty string.
+ */
+const char* bejDictGetPropertyName(const uint8_t* dictionary,
+ uint16_t nameOffset, uint8_t nameLength);
- /**
- * @brief Get the property related to the given property name.
- *
- * @param[in] dictionary - dictionary containing the property.
- * @param[in] startingPropertyOffset - offset of the starting property for
- * the search.
- * @param[in] propertyName - name of the searched property.
- * @param[out] property - if the search is successful, this will point to a
- * valid property.
- * @param[out] propertyOffset - if the search is successful, this will point
- * to the offset of the property within the dictionary. Can provide a NULL
- * pointer if this is not needed.
- * @return 0 if successful.
- */
- int bejDictGetPropertyByName(const uint8_t* dictionary,
- uint16_t startingPropertyOffset,
- const char* propertyName,
- const struct BejDictionaryProperty** property,
- uint16_t* propertyOffset);
+/**
+ * @brief Get the property related to the given property name.
+ *
+ * @param[in] dictionary - dictionary containing the property.
+ * @param[in] startingPropertyOffset - offset of the starting property for
+ * the search.
+ * @param[in] propertyName - name of the searched property.
+ * @param[out] property - if the search is successful, this will point to a
+ * valid property.
+ * @param[out] propertyOffset - if the search is successful, this will point
+ * to the offset of the property within the dictionary. Can provide a NULL
+ * pointer if this is not needed.
+ * @return 0 if successful.
+ */
+int bejDictGetPropertyByName(const uint8_t* dictionary,
+ uint16_t startingPropertyOffset,
+ const char* propertyName,
+ const struct BejDictionaryProperty** property,
+ uint16_t* propertyOffset);
#ifdef __cplusplus
}
diff --git a/include/libbej/bej_encoder_core.h b/include/libbej/bej_encoder_core.h
index 6088eef..22b363d 100644
--- a/include/libbej/bej_encoder_core.h
+++ b/include/libbej/bej_encoder_core.h
@@ -11,40 +11,39 @@
#define BEJ_VERSION 0xF1F0F000
- /**
- * @brief A struct for storing output information for the encoder.
- */
- struct BejEncoderOutputHandler
- {
- // A user provided context to be passed to the recvOutput() callback.
- void* handlerContext;
- // A callback function that will be invoked by the encoder whenever it
- // has output data.
- int (*recvOutput)(const void* data, size_t data_size,
- void* handlerContext);
- };
+/**
+ * @brief A struct for storing output information for the encoder.
+ */
+struct BejEncoderOutputHandler
+{
+ // A user provided context to be passed to the recvOutput() callback.
+ void* handlerContext;
+ // A callback function that will be invoked by the encoder whenever it
+ // has output data.
+ int (*recvOutput)(const void* data, size_t data_size, void* handlerContext);
+};
- /**
- * @brief Perform BEJ encoding.
- *
- * @param dictionaries - dictionaries used for encoding.
- * @param majorSchemaStartingOffset - starting dictionary offset for
- * endcoding. Use BEJ_DICTIONARY_START_AT_HEAD to encode a complete
- * resource. Use the correct offset when encoding a subsection of a redfish
- * resource.
- * @param schemaClass - schema class for the resource.
- * @param root - root node of the resource to be encoded. Root node has to
- * be a bejSet.
- * @param output - An intialized BejEncoderOutputHandler struct.
- * @param stack - An initialized BejPointerStackCallback struct.
- * @return 0 if successful.
- */
- int bejEncode(const struct BejDictionaries* dictionaries,
- uint16_t majorSchemaStartingOffset,
- enum BejSchemaClass schemaClass,
- struct RedfishPropertyParent* root,
- struct BejEncoderOutputHandler* output,
- struct BejPointerStackCallback* stack);
+/**
+ * @brief Perform BEJ encoding.
+ *
+ * @param dictionaries - dictionaries used for encoding.
+ * @param majorSchemaStartingOffset - starting dictionary offset for
+ * endcoding. Use BEJ_DICTIONARY_START_AT_HEAD to encode a complete
+ * resource. Use the correct offset when encoding a subsection of a redfish
+ * resource.
+ * @param schemaClass - schema class for the resource.
+ * @param root - root node of the resource to be encoded. Root node has to
+ * be a bejSet.
+ * @param output - An intialized BejEncoderOutputHandler struct.
+ * @param stack - An initialized BejPointerStackCallback struct.
+ * @return 0 if successful.
+ */
+int bejEncode(const struct BejDictionaries* dictionaries,
+ uint16_t majorSchemaStartingOffset,
+ enum BejSchemaClass schemaClass,
+ struct RedfishPropertyParent* root,
+ struct BejEncoderOutputHandler* output,
+ struct BejPointerStackCallback* stack);
#ifdef __cplusplus
}
diff --git a/include/libbej/bej_encoder_metadata.h b/include/libbej/bej_encoder_metadata.h
index 55b6f10..d07fb02 100644
--- a/include/libbej/bej_encoder_metadata.h
+++ b/include/libbej/bej_encoder_metadata.h
@@ -8,26 +8,26 @@
{
#endif
- /**
- * @brief Update the node metadata used during encoding process.
- *
- * This function will visit the entire JSON tree and update metdata
- * properties of each node.
- *
- * @param dictionaries - dictionaries used for encoding.
- * @param majorSchemaStartingOffset - starting dictionary offset for
- * endcoding. Use BEJ_DICTIONARY_START_AT_HEAD to encode a complete
- * resource. Use the correct offset when encoding a subsection of a redfish
- * resource.
- * @param root - root node of the resource to be encoded. Root node has to
- * be a bejSet.
- * @param stack - An intialized BejEncoderOutputHandler struct.
- * @return 0 if successful.
- */
- int bejUpdateNodeMetadata(const struct BejDictionaries* dictionaries,
- uint16_t majorSchemaStartingOffset,
- struct RedfishPropertyParent* root,
- struct BejPointerStackCallback* stack);
+/**
+ * @brief Update the node metadata used during encoding process.
+ *
+ * This function will visit the entire JSON tree and update metdata
+ * properties of each node.
+ *
+ * @param dictionaries - dictionaries used for encoding.
+ * @param majorSchemaStartingOffset - starting dictionary offset for
+ * endcoding. Use BEJ_DICTIONARY_START_AT_HEAD to encode a complete
+ * resource. Use the correct offset when encoding a subsection of a redfish
+ * resource.
+ * @param root - root node of the resource to be encoded. Root node has to
+ * be a bejSet.
+ * @param stack - An intialized BejEncoderOutputHandler struct.
+ * @return 0 if successful.
+ */
+int bejUpdateNodeMetadata(const struct BejDictionaries* dictionaries,
+ uint16_t majorSchemaStartingOffset,
+ struct RedfishPropertyParent* root,
+ struct BejPointerStackCallback* stack);
#ifdef __cplusplus
}
diff --git a/include/libbej/bej_tree.h b/include/libbej/bej_tree.h
index 32bf82c..5a9ff89 100644
--- a/include/libbej/bej_tree.h
+++ b/include/libbej/bej_tree.h
@@ -11,305 +11,303 @@
{
#endif
- /**
- * @brief Holds info needed to encode a parent in the JSON tree.
- */
- struct BejEncoderParentMetaData
- {
- // Starting dictionary index of the children properties.
- uint16_t childrenDictPropOffset;
- // Index of the child pointed by nextChild. Used to store the array
- // indexes of bejArray elements.
- uint16_t nextChildIndex;
- // BEJ sequence number of the property.
- uint32_t sequenceNumber;
- // Size needed to encode Sequence number, Format and Length of the
- // value.
- size_t sflSize;
- // Size of the value.
- size_t vSize;
- // Dictionary used for this parent.
- const uint8_t* dictionary;
- // Points to the next node which is need to process.
- void* nextChild;
- };
+/**
+ * @brief Holds info needed to encode a parent in the JSON tree.
+ */
+struct BejEncoderParentMetaData
+{
+ // Starting dictionary index of the children properties.
+ uint16_t childrenDictPropOffset;
+ // Index of the child pointed by nextChild. Used to store the array
+ // indexes of bejArray elements.
+ uint16_t nextChildIndex;
+ // BEJ sequence number of the property.
+ uint32_t sequenceNumber;
+ // Size needed to encode Sequence number, Format and Length of the
+ // value.
+ size_t sflSize;
+ // Size of the value.
+ size_t vSize;
+ // Dictionary used for this parent.
+ const uint8_t* dictionary;
+ // Points to the next node which is need to process.
+ void* nextChild;
+};
- /**
- * @brief Holds info needed to encode a leaf type in the JSON tree.
- */
- struct BejEncoderLeafMetaData
- {
- // BEJ sequence number of the property.
- uint32_t sequenceNumber;
- // Size needed to encode Sequence number, Format and Length of the
- // value.
- size_t sflSize;
- // Size of the value.
- size_t vSize;
- };
+/**
+ * @brief Holds info needed to encode a leaf type in the JSON tree.
+ */
+struct BejEncoderLeafMetaData
+{
+ // BEJ sequence number of the property.
+ uint32_t sequenceNumber;
+ // Size needed to encode Sequence number, Format and Length of the
+ // value.
+ size_t sflSize;
+ // Size of the value.
+ size_t vSize;
+};
- /**
- * @brief Common attributes of a JSON property.
- */
- struct RedfishPropertyNode
- {
- const char* name;
- struct BejTupleF format;
- // Properties belonging to the same set or
- // array and has the same depth.
- void* sibling;
- };
+/**
+ * @brief Common attributes of a JSON property.
+ */
+struct RedfishPropertyNode
+{
+ const char* name;
+ struct BejTupleF format;
+ // Properties belonging to the same set or
+ // array and has the same depth.
+ void* sibling;
+};
- /**
- * @brief Used to store parent type property info.
- *
- * bejArray, bejSet and bejPropertyAnnotation are the parent type nodes.
- */
- struct RedfishPropertyParent
- {
- // Common property attributes.
- struct RedfishPropertyNode nodeAttr;
- // Number of children in the case of bejSet
- // or bejArray.
- size_t nChildren;
- // Points to the first child.
- void* firstChild;
- // Points to the last child. Technically we only need the firstChild
- // pointer to add a new element to the list. But to support bejArray
- // type, we need to traverse the linked list in the same order as the
- // elements in the array. So we need a pointer to the first child and
- // keep adding new nodes using the lastChild.
- void* lastChild;
- // Metadata used during encoding.
- struct BejEncoderParentMetaData metaData;
- };
+/**
+ * @brief Used to store parent type property info.
+ *
+ * bejArray, bejSet and bejPropertyAnnotation are the parent type nodes.
+ */
+struct RedfishPropertyParent
+{
+ // Common property attributes.
+ struct RedfishPropertyNode nodeAttr;
+ // Number of children in the case of bejSet
+ // or bejArray.
+ size_t nChildren;
+ // Points to the first child.
+ void* firstChild;
+ // Points to the last child. Technically we only need the firstChild
+ // pointer to add a new element to the list. But to support bejArray
+ // type, we need to traverse the linked list in the same order as the
+ // elements in the array. So we need a pointer to the first child and
+ // keep adding new nodes using the lastChild.
+ void* lastChild;
+ // Metadata used during encoding.
+ struct BejEncoderParentMetaData metaData;
+};
- /**
- * @brief Used to store leaf type property info.
- *
- * Every type that doesn't belong to parent type are considered as a leaf
- * property within a JSON tree. Each specific leaf type has its own struct.
- * They should include this struct as the first member of their struct.
- */
- struct RedfishPropertyLeaf
- {
- struct RedfishPropertyNode nodeAttr;
- struct BejEncoderLeafMetaData metaData;
- };
+/**
+ * @brief Used to store leaf type property info.
+ *
+ * Every type that doesn't belong to parent type are considered as a leaf
+ * property within a JSON tree. Each specific leaf type has its own struct.
+ * They should include this struct as the first member of their struct.
+ */
+struct RedfishPropertyLeaf
+{
+ struct RedfishPropertyNode nodeAttr;
+ struct BejEncoderLeafMetaData metaData;
+};
- /**
- * @brief bejNull type property node.
- */
- struct RedfishPropertyLeafNull
- {
- struct RedfishPropertyLeaf leaf;
- };
+/**
+ * @brief bejNull type property node.
+ */
+struct RedfishPropertyLeafNull
+{
+ struct RedfishPropertyLeaf leaf;
+};
- /**
- * @brief bejInteger type property node.
- */
- struct RedfishPropertyLeafInt
- {
- struct RedfishPropertyLeaf leaf;
- int64_t value;
- };
+/**
+ * @brief bejInteger type property node.
+ */
+struct RedfishPropertyLeafInt
+{
+ struct RedfishPropertyLeaf leaf;
+ int64_t value;
+};
- /**
- * @brief bejEnum type property node.
- */
- struct RedfishPropertyLeafEnum
- {
- struct RedfishPropertyLeaf leaf;
- // A string representation of the enum value.
- const char* value;
- // Sequence number of the enum value. Populated during bej encoding.
- uint16_t enumValueSeq;
- };
+/**
+ * @brief bejEnum type property node.
+ */
+struct RedfishPropertyLeafEnum
+{
+ struct RedfishPropertyLeaf leaf;
+ // A string representation of the enum value.
+ const char* value;
+ // Sequence number of the enum value. Populated during bej encoding.
+ uint16_t enumValueSeq;
+};
- /**
- * @brief bejString type property node.
- */
- struct RedfishPropertyLeafString
- {
- struct RedfishPropertyLeaf leaf;
- const char* value;
- };
+/**
+ * @brief bejString type property node.
+ */
+struct RedfishPropertyLeafString
+{
+ struct RedfishPropertyLeaf leaf;
+ const char* value;
+};
- /**
- * @brief bejReal type property node.
- */
- struct RedfishPropertyLeafReal
- {
- struct RedfishPropertyLeaf leaf;
- double value;
- // bejReal representation of the value. Populated during bej encoding.
- struct BejReal bejReal;
- };
+/**
+ * @brief bejReal type property node.
+ */
+struct RedfishPropertyLeafReal
+{
+ struct RedfishPropertyLeaf leaf;
+ double value;
+ // bejReal representation of the value. Populated during bej encoding.
+ struct BejReal bejReal;
+};
- /**
- * @brief bejBoolean type property node.
- */
- struct RedfishPropertyLeafBool
- {
- struct RedfishPropertyLeaf leaf;
- bool value;
- };
+/**
+ * @brief bejBoolean type property node.
+ */
+struct RedfishPropertyLeafBool
+{
+ struct RedfishPropertyLeaf leaf;
+ bool value;
+};
- /**
- * @brief Initialize a bejSet type node.
- *
- * @param[in] node - pointer to a RedfishPropertyParent struct.
- * @param[in] name - name of the node.
- */
- void bejTreeInitSet(struct RedfishPropertyParent* node, const char* name);
+/**
+ * @brief Initialize a bejSet type node.
+ *
+ * @param[in] node - pointer to a RedfishPropertyParent struct.
+ * @param[in] name - name of the node.
+ */
+void bejTreeInitSet(struct RedfishPropertyParent* node, const char* name);
- /**
- * @brief Initialize a bejArray type node.
- *
- * @param[in] node - pointer to a RedfishPropertyParent struct.
- * @param[in] name - name of the node.
- */
- void bejTreeInitArray(struct RedfishPropertyParent* node, const char* name);
+/**
+ * @brief Initialize a bejArray type node.
+ *
+ * @param[in] node - pointer to a RedfishPropertyParent struct.
+ * @param[in] name - name of the node.
+ */
+void bejTreeInitArray(struct RedfishPropertyParent* node, const char* name);
- /**
- * @brief Initialize a bejPropertyAnnotation type node.
- *
- * @param[in] node - pointer to a RedfishPropertyParent struct.
- * @param[in] name - name of the node.
- */
- void bejTreeInitPropertyAnnotated(struct RedfishPropertyParent* node,
- const char* name);
+/**
+ * @brief Initialize a bejPropertyAnnotation type node.
+ *
+ * @param[in] node - pointer to a RedfishPropertyParent struct.
+ * @param[in] name - name of the node.
+ */
+void bejTreeInitPropertyAnnotated(struct RedfishPropertyParent* node,
+ const char* name);
- /**
- * @brief Check if a node is a parent type node.
- *
- * @param node - node to be checked.
- * @return true if the node is a parent type node.
- */
- bool bejTreeIsParentType(struct RedfishPropertyNode* node);
+/**
+ * @brief Check if a node is a parent type node.
+ *
+ * @param node - node to be checked.
+ * @return true if the node is a parent type node.
+ */
+bool bejTreeIsParentType(struct RedfishPropertyNode* node);
- /**
- * @brief Initialize a bejNull type node.
- *
- * @param parent - a pointer to an initialized parent struct.
- * @param child - a pointer to an uninitialized bejNull type node.
- * @param name - name of the bejNull type property.
- */
- void bejTreeAddNull(struct RedfishPropertyParent* parent,
- struct RedfishPropertyLeafNull* child,
- const char* name);
+/**
+ * @brief Initialize a bejNull type node.
+ *
+ * @param parent - a pointer to an initialized parent struct.
+ * @param child - a pointer to an uninitialized bejNull type node.
+ * @param name - name of the bejNull type property.
+ */
+void bejTreeAddNull(struct RedfishPropertyParent* parent,
+ struct RedfishPropertyLeafNull* child, const char* name);
- /**
- * @brief Add a bejInteger type node to a parent node.
- *
- * @param[in] parent - a pointer to an initialized parent struct.
- * @param[in] child - a pointer to an uninitialized bejInteger type node.
- * @param[in] name - name of the bejInteger type property.
- * @param[in] value - value of the bejInteger type property.
- */
- void bejTreeAddInteger(struct RedfishPropertyParent* parent,
- struct RedfishPropertyLeafInt* child,
- const char* name, int64_t value);
+/**
+ * @brief Add a bejInteger type node to a parent node.
+ *
+ * @param[in] parent - a pointer to an initialized parent struct.
+ * @param[in] child - a pointer to an uninitialized bejInteger type node.
+ * @param[in] name - name of the bejInteger type property.
+ * @param[in] value - value of the bejInteger type property.
+ */
+void bejTreeAddInteger(struct RedfishPropertyParent* parent,
+ struct RedfishPropertyLeafInt* child, const char* name,
+ int64_t value);
- /**
- * @brief Set a new value in bejInteger type node.
- *
- * @param[in] node - initialized bejInteger type node.
- * @param[in] newValue - new integer value.
- */
- void bejTreeSetInteger(struct RedfishPropertyLeafInt* node,
- int64_t newValue);
+/**
+ * @brief Set a new value in bejInteger type node.
+ *
+ * @param[in] node - initialized bejInteger type node.
+ * @param[in] newValue - new integer value.
+ */
+void bejTreeSetInteger(struct RedfishPropertyLeafInt* node, int64_t newValue);
- /**
- * @brief Add a bejEnum type node to a parent node.
- *
- * @param[in] parent - a pointer to an initialized parent struct.
- * @param[in] child - a pointer to an uninitialized bejEnum type node.
- * @param[in] name - name of the bejEnum type property.
- * @param[in] value - value of the bejEnum type property.
- */
- void bejTreeAddEnum(struct RedfishPropertyParent* parent,
- struct RedfishPropertyLeafEnum* child, const char* name,
- const char* value);
+/**
+ * @brief Add a bejEnum type node to a parent node.
+ *
+ * @param[in] parent - a pointer to an initialized parent struct.
+ * @param[in] child - a pointer to an uninitialized bejEnum type node.
+ * @param[in] name - name of the bejEnum type property.
+ * @param[in] value - value of the bejEnum type property.
+ */
+void bejTreeAddEnum(struct RedfishPropertyParent* parent,
+ struct RedfishPropertyLeafEnum* child, const char* name,
+ const char* value);
- /**
- * @brief Add a bejString type node to a parent node.
- *
- * @param[in] parent - a pointer to an initialized parent struct.
- * @param[in] child - a pointer to an uninitialized bejString type node.
- * @param[in] name - name of the bejString type property.
- * @param[in] value - value of the bejString type property.
- */
- void bejTreeAddString(struct RedfishPropertyParent* parent,
- struct RedfishPropertyLeafString* child,
- const char* name, const char* value);
+/**
+ * @brief Add a bejString type node to a parent node.
+ *
+ * @param[in] parent - a pointer to an initialized parent struct.
+ * @param[in] child - a pointer to an uninitialized bejString type node.
+ * @param[in] name - name of the bejString type property.
+ * @param[in] value - value of the bejString type property.
+ */
+void bejTreeAddString(struct RedfishPropertyParent* parent,
+ struct RedfishPropertyLeafString* child, const char* name,
+ const char* value);
- /**
- * @brief Add a bejReal type node to a parent node.
- *
- * @param[in] parent - a pointer to an initialized parent struct.
- * @param[in] child - a pointer to an uninitialized bejReal type node.
- * @param[in] name - name of the bejReal type property.
- * @param[in] value - value of the bejReal type property.
- */
- void bejTreeAddReal(struct RedfishPropertyParent* parent,
- struct RedfishPropertyLeafReal* child, const char* name,
- double value);
+/**
+ * @brief Add a bejReal type node to a parent node.
+ *
+ * @param[in] parent - a pointer to an initialized parent struct.
+ * @param[in] child - a pointer to an uninitialized bejReal type node.
+ * @param[in] name - name of the bejReal type property.
+ * @param[in] value - value of the bejReal type property.
+ */
+void bejTreeAddReal(struct RedfishPropertyParent* parent,
+ struct RedfishPropertyLeafReal* child, const char* name,
+ double value);
- /**
- * @brief Set a new value in bejReal type node.
- *
- * @param[in] node - initialized bejReal type node.
- * @param[in] newValue - new double value.
- */
- void bejTreeSetReal(struct RedfishPropertyLeafReal* node, double newValue);
+/**
+ * @brief Set a new value in bejReal type node.
+ *
+ * @param[in] node - initialized bejReal type node.
+ * @param[in] newValue - new double value.
+ */
+void bejTreeSetReal(struct RedfishPropertyLeafReal* node, double newValue);
- /**
- * @brief Add a bejBoolean type node to a parent node.
- *
- * @param[in] parent - a pointer to an initialized parent struct.
- * @param[in] child - a pointer to an uninitialized bejBoolean type node.
- * @param[in] name - name of the bejBoolean type property.
- * @param[in] value - value of the bejBoolean type property.
- */
- void bejTreeAddBool(struct RedfishPropertyParent* parent,
- struct RedfishPropertyLeafBool* child, const char* name,
- bool value);
+/**
+ * @brief Add a bejBoolean type node to a parent node.
+ *
+ * @param[in] parent - a pointer to an initialized parent struct.
+ * @param[in] child - a pointer to an uninitialized bejBoolean type node.
+ * @param[in] name - name of the bejBoolean type property.
+ * @param[in] value - value of the bejBoolean type property.
+ */
+void bejTreeAddBool(struct RedfishPropertyParent* parent,
+ struct RedfishPropertyLeafBool* child, const char* name,
+ bool value);
- /**
- * @brief Link a node to its parent.
- *
- * @param[in] parent - a pointer to an initialized parent struct.
- * @param[in] child - a pointer to an initialized child struct.
- */
- void bejTreeLinkChildToParent(struct RedfishPropertyParent* parent,
- void* child);
+/**
+ * @brief Link a node to its parent.
+ *
+ * @param[in] parent - a pointer to an initialized parent struct.
+ * @param[in] child - a pointer to an initialized child struct.
+ */
+void bejTreeLinkChildToParent(struct RedfishPropertyParent* parent,
+ void* child);
- /**
- * @brief Set Bej format flags of a node.
- *
- * @param node - an initialized node.
- * @param deferredBinding - set deferred binding flag.
- * @param readOnlyProperty - set read only property flag.
- * @param nullableProperty - set nullable property flag.
- */
- void bejTreeUpdateNodeFlags(struct RedfishPropertyNode* node,
- bool deferredBinding, bool readOnlyProperty,
- bool nullableProperty);
+/**
+ * @brief Set Bej format flags of a node.
+ *
+ * @param node - an initialized node.
+ * @param deferredBinding - set deferred binding flag.
+ * @param readOnlyProperty - set read only property flag.
+ * @param nullableProperty - set nullable property flag.
+ */
+void bejTreeUpdateNodeFlags(struct RedfishPropertyNode* node,
+ bool deferredBinding, bool readOnlyProperty,
+ bool nullableProperty);
- /**
- * @brief Get the next child node to be processed.
- *
- * This function returns the next child node of the parent node. This also
- * updates the parent node's next child properties.
- *
- * @param parent - parent node.
- * @param currentChild - current child node being processed.
- * @return pointer to the next child node to be processed. NULL if there is
- * no next child or one of the params are NULL.
- */
- void* bejParentGoToNextChild(struct RedfishPropertyParent* parent,
- struct RedfishPropertyNode* currentChild);
+/**
+ * @brief Get the next child node to be processed.
+ *
+ * This function returns the next child node of the parent node. This also
+ * updates the parent node's next child properties.
+ *
+ * @param parent - parent node.
+ * @param currentChild - current child node being processed.
+ * @return pointer to the next child node to be processed. NULL if there is
+ * no next child or one of the params are NULL.
+ */
+void* bejParentGoToNextChild(struct RedfishPropertyParent* parent,
+ struct RedfishPropertyNode* currentChild);
#ifdef __cplusplus
}
diff --git a/test/bej_decoder_test.cpp b/test/bej_decoder_test.cpp
index 185b69c..b390017 100644
--- a/test/bej_decoder_test.cpp
+++ b/test/bej_decoder_test.cpp
@@ -190,6 +190,6 @@
}),
[](const testing::TestParamInfo<BejDecoderTest::ParamType>& info) {
return info.param.testName;
- });
+});
} // namespace libbej