github.com/GeniusesGroup/libgo@v0.0.0-20220929090155-5ff932cb408e/protocol/field.go (about) 1 /* For license and copyright information please see the LEGAL file in the code repository */ 2 3 package protocol 4 5 type Structure interface { 6 Fields() []Field 7 } 8 9 // Field can use for any data like CLA flags or json fields or any other data structures 10 // even in compilers or runtime packages 11 type Field interface { 12 Name() string 13 Abbreviation() string 14 Type() FieldType 15 Size() int // len in byte 16 Optional() bool 17 Immutable() bool 18 Atomic() bool 19 // TODO::: add more 20 Validate() Error 21 22 SetDefault() // default value 23 24 Details 25 Stringer 26 } 27 28 type FieldType uint8 29 30 const ( 31 FieldType_Unset FieldType = iota 32 FieldType_Type // other type 33 FieldType_Pointer 34 FieldType_Boolean 35 FieldType_Function 36 FieldType_Structure 37 FieldType_Array 38 FieldType_Natural // Any number > 0 - https://en.wikipedia.org/wiki/Natural_number 39 FieldType_Whole // Any number >= 0 - 40 FieldType_Integer // also know as signed number is any number <>= 0 - https://en.wikipedia.org/wiki/Integer 41 FieldType_Rational // also knows as decimal, float, ... - https://en.wikipedia.org/wiki/Rational_number 42 FieldType_Real // also know as Irrational, Fractional - https://en.wikipedia.org/wiki/Real_number 43 FieldType_Complex // - https://en.wikipedia.org/wiki/Complex_number 44 )