Schema
Schema Definition¶
Schem is used to define CrossDB table and it's defined based on C struct with some CrossDB macro.
Basic Types¶
CrossDB Type and C Type Map
CrossDB Type | Description | C Type |
---|---|---|
INT | integer | char , short , int , long long , int8_t , int16_t , int32_t , int64_t |
UINT | unsinged integer | unsigned char , unsigned short , unsigned int , unsigned long long , uint8_t uint16_t , uint32_t , uint64_t |
FLOAT | floating-point | float , double |
CHAR | charater string | char [] |
BYTE | byte array | unsiged char [] , uint8_t [] , struct |
CrossDB Format
CrossDB Type | CrossDB Formt | Description |
---|---|---|
INT/UINT | DFT | default decimal |
FLOAT | DFT | default floating-point |
CHAR | DFT | default charater string |
BYTE | DFT | default hexadecimal string |
INT/UINT | BOOL | boolean |
UINT | HEX | hexadecimal |
INT/UINT | TIMESTAMP/TS | Timestamp: time_t , uin32_t , uint64_t |
BTYE | MAC | MAC addrss: uint8_t [6] , struct ether_addr |
UINT | IPv4 | Host endian IPv4 address: uint32_t |
BYTE | IPv4 | Network endian IPv4 address: struct in_addr , uint32_t |
BYTE | IPv6 | Network endian IPv4 address: uint8_t [16] , struct in_addr6 |
Example
Set CROSS_STRUCT_NAME
to the struct name basic_types_t
for CROSS_FIELD
to define the schema entry. CROSS_END
is used to mark the end of schema definition.
To keep struct and schema in header file, you can define them together like following way.
Define macro ROUTE_SCHEMA()
in header file
Define schema in source file. CROSS_END
can be define in route_schema
also then you can reuse the macro ROUTE_SCHEMA()
or combine them.