Function NullTerminatedString

  • @NullTerminatedString decorator reads a string from a binary stream until the null-terminator (\0) character is encountered and exclude that character from the final value.

    Type Parameters

    • This

      The type of the class the decorator is applied to.

    • Value

      The type of the decorated property.

    Parameters

    Returns DecoratorType<This, Value>

    The property decorator function.

    In the following example, the @NullTerminatedString decorator is used in conjunction of the @Until decorator to read Null terminated strings until the end of the file.

    class Protocol {
    @Until(EOF)
    @NullTerminatedString()
    @Relation(PrimitiveSymbol.char)
    data: string[]
    }

    This decorator is similar to @Until('\0', { targetType: String }). The key difference is that @NullTerminatedString always drop the null-terminator, whereas @Until includes the \0 character as part of the string.

MMNEPVFCICPMFPCPTTAAATR