npm.io
1.0.8 β€’ Published 6 months agoCLI

nv-cli-json-to-csize-struct

Licence
ISC
Version
1.0.8
Deps
2
Size
7 kB
Vulns
0
Weekly
0

nv-cli-json-to-csize-struct

install

  • npm install nv-cli-json-to-csize-struct -g

usage

        Usage: nv_cli_json_to_csize_struct [options] 
        Options:
            -n, --name          top struct name, default JRecord
            -i, --input         input string ,default stdin
            -o, --output        output string,default stdout
            -h, --help          usage

example

        nv_cli_json_to_csize_struct -i 

        {                 // 1           0
            empty_s: "",         //  2           0
            a: [                 //  3           8                                  
                true,            //  4           8 
                1.1,             //  5           16 
                "str",           //  6           24
                {                //  7           32
                    a:[],        //  8           32 
                    t:true,      //  9           32
                    f:false,     // 10           40 
                    nu:null,     // 11           48
                    n:1.1,       // 12           56
                    d: {}        // 13           64
                },               // 
                false,           // 14           64
                null             // 15           72
            ],
            s: "a\xffζˆ‘π‘’",       // 16           80
            d: {                 // 17           96
                k0: "v0",        // 18           96 
                k1: "ζˆ‘"         // 19           104
            }
        }

        //----press ctrl+D

        { compile_cost: 0.143 }
        #include <cstdint>


        #ifndef ATAG
        #define ATAG  static constexpr uint8_t ___ary___  = 0;
        #endif


        #ifndef DTAG
        #define DTAG  static constexpr uint8_t ___dict___ = 0;
        #endif


        struct EmptyAry  { static constexpr uint8_t ___ary___  = 0; uint8_t ___empty___[0];};
        struct EmptyDict { static constexpr uint8_t ___dict___ = 0; uint8_t ___empty___[0];};


        constexpr char JCFG[] = R"({
          "empty_s": "",
          "a": [
            true,
            1.1,
            "str",
            {
              "a": [],
              "t": true,
              "f": false,
              "nu": null,
              "n": 1.1,
              "d": {}
            },
            false,
            null
          ],
          "s": "aΓΏζˆ‘π‘’",
          "d": {
            "k0": "v0",
            "k1": "ζˆ‘"
          }
        })";


        struct JRecord$1 { DTAG
            char      empty_s[8] = "";
            struct A$3 { ATAG
                uint64_t  _0         = 0x7ff8'0000'0000'0003ULL;
                double    _1         = 1.1 ;
                char      _2[8]      = "str";
                struct D$7 { DTAG
                    EmptyAry  a         ;
                    uint64_t  t          = 0x7ff8'0000'0000'0003ULL;
                    uint64_t  f          = 0x7ff8'0000'0000'0004ULL;
                    int64_t   nu         = 0x7ffd'0000'0000'0000LL;
                    double    n          = 1.1 ;
                    EmptyDict d         ;
                } _3;
                uint64_t  _4         = 0x7ff8'0000'0000'0004ULL;
                int64_t   _5         = 0x7ffd'0000'0000'0000LL;
            } a;
            char      s[16]      = "aΓΏζˆ‘π‘’";
            struct D$17 { DTAG
                char      k0[8]      = "v0";
                char      k1[8]      = "ζˆ‘";
            } d;
        };

        int main() {
            JRecord$1  jrecord;
            return(0);
        };

LICENSE

  • ISC