Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
CompactBinaryValidation.h File Reference
#include "CoreTypes.h"
#include "Memory/MemoryFwd.h"
#include "Memory/MemoryView.h"
#include "Misc/EnumClassFlags.h"
#include "Serialization/CompactBinary.h"
+ Include dependency graph for CompactBinaryValidation.h:

Go to the source code of this file.

Enumerations

enum class  ECbValidateMode : uint32 {
  None = 0x0 , Default = 0x1 , Names = 0x2 , Format = 0x4 ,
  Padding = 0x8 , Package = 0x10 , PackageHash = 0x20 , All = 0x3F ,
  None = 0 , Default = 1 << 0 , Names = 1 << 1 , Format = 1 << 2 ,
  Padding = 1 << 3 , Package = 1 << 4 , PackageHash = 1 << 5 , All = Default | Names | Format | Padding | Package | PackageHash
}
 
enum class  ECbValidateError : uint32 {
  None = 0x0 , OutOfBounds = 0x1 , InvalidType = 0x2 , DuplicateName = 0x4 ,
  MissingName = 0x8 , ArrayName = 0x10 , InvalidString = 0x20 , InvalidInteger = 0x40 ,
  InvalidFloat = 0x80 , NonUniformObject = 0x100 , NonUniformArray = 0x200 , Padding = 0x400 ,
  InvalidPackageFormat = 0x800 , InvalidPackageHash = 0x1000 , DuplicateAttachments = 0x2000 , MultiplePackageObjects = 0x4000 ,
  NullPackageObject = 0xFFFF8000 , NullPackageAttachment = 0x10000 , None = 0 , OutOfBounds = 1 << 0 ,
  InvalidType = 1 << 1 , DuplicateName = 1 << 2 , MissingName = 1 << 3 , ArrayName = 1 << 4 ,
  InvalidString = 1 << 5 , InvalidInteger = 1 << 6 , InvalidFloat = 1 << 7 , NonUniformObject = 1 << 8 ,
  NonUniformArray = 1 << 9 , Padding = 1 << 10 , InvalidPackageFormat = 1 << 11 , InvalidPackageHash = 1 << 12 ,
  DuplicateAttachments = 1 << 13 , MultiplePackageObjects = 1 << 14 , NullPackageObject = 1 << 15 , NullPackageAttachment = 1 << 16
}
 

Functions

 ENUM_CLASS_FLAGS (ECbValidateMode)
 
 ENUM_CLASS_FLAGS (ECbValidateError)
 
ECbValidateError ValidateCompactBinary (FMemoryView View, ECbValidateMode Mode, ECbFieldType Type=ECbFieldType::HasFieldType)
 
ECbValidateError ValidateCompactBinaryRange (FMemoryView View, ECbValidateMode Mode)
 
ECbValidateError ValidateCompactBinaryAttachment (FMemoryView View, ECbValidateMode Mode)
 
ECbValidateError ValidateCompactBinaryPackage (FMemoryView View, ECbValidateMode Mode)
 
ECbValidateError ValidateCompactBinary (const FCbField &Value, ECbValidateMode Mode)
 
ECbValidateError ValidateCompactBinary (const FCbArray &Value, ECbValidateMode Mode)
 
ECbValidateError ValidateCompactBinary (const FCbObject &Value, ECbValidateMode Mode)
 
ECbValidateError ValidateCompactBinary (const FCbPackage &Value, ECbValidateMode Mode)
 
ECbValidateError ValidateCompactBinary (const FCbAttachment &Value, ECbValidateMode Mode)
 

Enumeration Type Documentation

◆ ECbValidateError

Flags for compact binary validation errors. Multiple flags may be combined.

Enumerator
None 
OutOfBounds 
InvalidType 
DuplicateName 
MissingName 
ArrayName 
InvalidString 
InvalidInteger 
InvalidFloat 
NonUniformObject 
NonUniformArray 
Padding 
InvalidPackageFormat 
InvalidPackageHash 
DuplicateAttachments 
MultiplePackageObjects 
NullPackageObject 
NullPackageAttachment 
None 

The input had no validation errors.

OutOfBounds 

The input cannot be read without reading out of bounds.

InvalidType 

The input has a field with an unrecognized or invalid type.

DuplicateName 

An object had more than one field with the same name.

MissingName 

An object had a field with no name.

ArrayName 

An array field had a name.

InvalidString 

A name or string value is not valid UTF-8.

InvalidInteger 

A size or integer value can be encoded in fewer bytes.

InvalidFloat 

A float64 value can be encoded as a float32 without loss of precision.

NonUniformObject 

An object has the same type for every field but is not uniform.

NonUniformArray 

An array has the same type for every field and non-empty values but is not uniform.

Padding 

A value did not use the entire memory view given for validation.

InvalidPackageFormat 

The package or attachment had missing fields or fields out of order.

InvalidPackageHash 

The object or an attachment did not match the hash stored for it.

DuplicateAttachments 

The package contained more than one copy of the same attachment.

MultiplePackageObjects 

The package contained more than one object.

NullPackageObject 

The package contained an object with no fields.

NullPackageAttachment 

The package contained a null attachment.

Definition at line 77 of file CompactBinaryValidation.h.

◆ ECbValidateMode

Flags for validating compact binary data.

Enumerator
None 
Default 
Names 
Format 
Padding 
Package 
PackageHash 
All 
None 

Skip validation if no other validation modes are enabled.

Default 

Validate that the value can be read and stays inside the bounds of the memory view.

This is the minimum level of validation required to be able to safely read a field, array, or object without the risk of crashing or reading out of bounds.

Names 

Validate that object fields have unique non-empty names and array fields have no names.

Name validation failures typically do not inhibit reading the input, but duplicated fields cannot be looked up by name other than the first, and converting to other data formats can fail in the presence of naming issues.

Format 

Validate that fields are serialized in the canonical format.

Format validation failures typically do not inhibit reading the input. Values that fail in this mode require more memory than in the canonical format, and comparisons of such values for equality are not reliable. Examples of failures include uniform arrays or objects that were not encoded uniformly, variable-length integers that could be encoded in fewer bytes, or 64-bit floats that could be encoded in 32 bits without loss of precision.

Padding 

Validate that there is no padding after the value before the end of the memory view.

Padding validation failures have no impact on the ability to read the input, but are using more memory than necessary.

Package 

Validate that a package or attachment has the expected fields.

PackageHash 

Validate that a package or attachment matches its saved hashes.

All 

Perform all validation described above.

Definition at line 17 of file CompactBinaryValidation.h.

Function Documentation

◆ ENUM_CLASS_FLAGS() [1/2]

ENUM_CLASS_FLAGS ( ECbValidateError )

◆ ENUM_CLASS_FLAGS() [2/2]

ENUM_CLASS_FLAGS ( ECbValidateMode )

◆ ValidateCompactBinary() [1/6]

ECbValidateError ValidateCompactBinary ( const FCbArray & Value,
ECbValidateMode Mode )

◆ ValidateCompactBinary() [2/6]

ECbValidateError ValidateCompactBinary ( const FCbAttachment & Value,
ECbValidateMode Mode )

◆ ValidateCompactBinary() [3/6]

ECbValidateError ValidateCompactBinary ( const FCbField & Value,
ECbValidateMode Mode )

Validate the compact binary data for one value as specified by the mode flags.

Validation recurses into attachments, objects, arrays, and fields within the top-level value.

Returns
None on success, otherwise the flags for the types of errors that were detected.

◆ ValidateCompactBinary() [4/6]

ECbValidateError ValidateCompactBinary ( const FCbObject & Value,
ECbValidateMode Mode )

◆ ValidateCompactBinary() [5/6]

ECbValidateError ValidateCompactBinary ( const FCbPackage & Value,
ECbValidateMode Mode )

◆ ValidateCompactBinary() [6/6]

Validate the compact binary data for one field in the view as specified by the mode flags.

Only one top-level field is processed from the view, and validation recurses into any array or object within that field. To validate multiple consecutive top-level fields, call the function once for each top-level field. If the given view might contain multiple top-level fields, then either exclude the Padding flag from the Mode or use MeasureCompactBinary to break up the view into its constituent fields before validating.

Parameters
ViewA memory view containing at least one top-level field.
ModeA combination of the flags for the types of validation to perform.
TypeHasFieldType means that View contains the type. Otherwise, use the given type.
Returns
None on success, otherwise the flags for the types of errors that were detected.

◆ ValidateCompactBinaryAttachment()

ECbValidateError ValidateCompactBinaryAttachment ( FMemoryView View,
ECbValidateMode Mode )

Validate the compact binary attachment pointed to by the view as specified by the mode flags.

The attachment is validated with ValidateCompactBinary by using the validation mode specified. Include ECbValidateMode::Package to validate the attachment format and hash.

See also
ValidateCompactBinary
Parameters
ViewA memory view containing a package.
ModeA combination of the flags for the types of validation to perform.
Returns
None on success, otherwise the flags for the types of errors that were detected.

◆ ValidateCompactBinaryPackage()

ECbValidateError ValidateCompactBinaryPackage ( FMemoryView View,
ECbValidateMode Mode )

Validate the compact binary package pointed to by the view as specified by the mode flags.

The package, and attachments, are validated with ValidateCompactBinary by using the validation mode specified. Include ECbValidateMode::Package to validate the package format and hashes.

See also
ValidateCompactBinary
Parameters
ViewA memory view containing a package.
ModeA combination of the flags for the types of validation to perform.
Returns
None on success, otherwise the flags for the types of errors that were detected.

◆ ValidateCompactBinaryRange()

ECbValidateError ValidateCompactBinaryRange ( FMemoryView View,
ECbValidateMode Mode )

Validate the compact binary data for every field in the view as specified by the mode flags.

This function expects the entire view to contain fields. Any trailing region of the view which does not contain a valid field will produce an OutOfBounds or InvalidType error instead of the Padding error that would be produced by the single field validation function.

See also
ValidateCompactBinary