nostrdb

an unfairly fast embedded nostr database backed by lmdb
git clone git://jb55.com/nostrdb
Log | Files | Refs | Submodules | README | LICENSE

reflection.fbs (2857B)


      1 // This schema defines objects that represent a parsed schema, like
      2 // the binary version of a .fbs file.
      3 // This could be used to operate on unknown FlatBuffers at runtime.
      4 // It can even ... represent itself (!)
      5 
      6 namespace reflection;
      7 
      8 // These must correspond to the enum in idl.h.
      9 enum BaseType : byte {
     10     None,
     11     UType,
     12     Bool,
     13     Byte,
     14     UByte,
     15     Short,
     16     UShort,
     17     Int,
     18     UInt,
     19     Long,
     20     ULong,
     21     Float,
     22     Double,
     23     String,
     24     Vector,
     25     Obj,     // Used for tables & structs.
     26     Union,
     27     Array,
     28 
     29     // Add any new type above this value.
     30     MaxBaseType
     31 }
     32 
     33 table Type {
     34     base_type:BaseType;
     35     element:BaseType = None;  // Only if base_type == Vector
     36                               // or base_type == Array.
     37     index:int = -1;  // If base_type == Object, index into "objects" below.
     38                      // If base_type == Union, UnionType, or integral derived
     39                      // from an enum, index into "enums" below.
     40     fixed_length:uint16 = 0;  // Only if base_type == Array.
     41 }
     42 
     43 table KeyValue {
     44     key:string (required, key);
     45     value:string;
     46 }
     47 
     48 table EnumVal {
     49     name:string (required);
     50     value:long (key);
     51     object:Object;  // Will be deprecated in favor of union_type in the future.
     52     union_type:Type;
     53     documentation:[string];
     54 }
     55 
     56 table Enum {
     57     name:string (required, key);
     58     values:[EnumVal] (required);  // In order of their values.
     59     is_union:bool = false;
     60     underlying_type:Type (required);
     61     attributes:[KeyValue];
     62     documentation:[string];
     63 }
     64 
     65 table Field {
     66     name:string (required, key);
     67     type:Type (required);
     68     id:ushort;
     69     offset:ushort;  // Offset into the vtable for tables, or into the struct.
     70     default_integer:long = 0;
     71     default_real:double = 0.0;
     72     deprecated:bool = false;
     73     required:bool = false;
     74     key:bool = false;
     75     attributes:[KeyValue];
     76     documentation:[string];
     77     optional:bool = false;
     78 }
     79 
     80 table Object {  // Used for both tables and structs.
     81     name:string (required, key);
     82     fields:[Field] (required);  // Sorted.
     83     is_struct:bool = false;
     84     minalign:int;
     85     bytesize:int;  // For structs.
     86     attributes:[KeyValue];
     87     documentation:[string];
     88 }
     89 
     90 table RPCCall {
     91     name:string (required, key);
     92     request:Object (required);      // must be a table (not a struct)
     93     response:Object (required);     // must be a table (not a struct)
     94     attributes:[KeyValue];
     95     documentation:[string];
     96 }
     97 
     98 table Service {
     99     name:string (required, key);
    100     calls:[RPCCall];
    101     attributes:[KeyValue];
    102     documentation:[string];
    103 }
    104 
    105 table Schema {
    106     objects:[Object] (required);    // Sorted.
    107     enums:[Enum] (required);        // Sorted.
    108     file_ident:string;
    109     file_ext:string;
    110     root_table:Object;
    111     services:[Service];             // Sorted.
    112 }
    113 
    114 root_type Schema;
    115 
    116 file_identifier "BFBS";
    117 file_extension "bfbs";