Feature #188

Mandatory/Optional flag for UBF unmarshal

Added by Madars over 6 years ago. Updated over 6 years ago.

Status:NewStart date:08/24/2017
Priority:Normal (Code 4)Due date:
Assignee:-% Done:

0%

Category:-
Target version:-

Description

We could extend Unmarshal function for UBF to process the mandatory tag. If mandatory is set, and field is not present, then operation shall terminate with field not present error with message indicating exactly which field is not present.


//Struct to marshal
type TestStruct struct {
    CharTest      byte   `ubf:"T_CHAR_FLD" uflag:"M"`
    CharArrayTest []byte `ubf:"T_CHAR_FLD" uflag:"O"`

    ShortTest      int16   `ubf:"T_SHORT_FLD" uflag:"M"`
    ShortArrayTest []int16 `ubf:"T_SHORT_FLD" uflag:"O"`

    LongTest      int64   `ubf:"T_LONG_FLD"`
    LongArrayTest []int64 `ubf:"T_LONG_FLD"" uflag:"M"`

    Float32Test      float32   `ubf:"T_FLOAT_FLD"`
    Float32ArrayTest []float32 `ubf:"T_FLOAT_FLD"`

    Float64Test      float64   `ubf:"T_DOUBLE_FLD"`
    Float64ArrayTest []float64 `ubf:"T_DOUBLE_FLD"uflag:"M" `

    StringTest      string   `ubf:"T_STRING_FLD"`
    StringArrayTest []string `ubf:"T_STRING_FLD"`

    //By default this goes as array
    CarrayTest [][]byte `ubf:"T_CARRAY_FLD"`
}

History

#1 Updated by Madars over 6 years ago

  • Description updated (diff)

Also available in: Atom PDF