Feature #188

Updated by Madars over 6 years ago

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.
<pre>

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

ShortTest int16 `ubf:"T_SHORT_FLD" uflag:"M"` ubfflag:&quot;M&quot;`
ShortArrayTest []int16 `ubf:"T_SHORT_FLD" uflag:"O"` ubfflag:&quot;O&quot;`

LongTest int64 `ubf:"T_LONG_FLD"`
LongArrayTest []int64 `ubf:"T_LONG_FLD"" uflag:"M"` ubfflag:&quot;M&quot;`

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" `ubf:&quot;T_DOUBLE_FLD&quot;ubfflag:&quot;M&quot; `

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

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

Back