npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nv-cli-creat-cstruct

v1.0.4

Published

nv-cli-creat-cstruct ==========

Downloads

4

Readme

nv-cli-creat-cstruct

install

  • npm install nv-cli-creat-cstruct -g

usage

simple

	Usage: nv_cli_creat_cstruct_simple [options] 
	Options:
	    -n, --name                    struct name, default SimpleData
	    -a, --using_flat_array        using flat array as input 
	    -i, --input                   input dict if mode is nest-dict(without using -a) ,default stdin
	    -o, --output                  output string,default stdout
	    -h, --help                    usage

detail

    TODO

example

simple mode : no padding

            #nv_cli_creat_cstruct_simple -n SimpleData

	{
	   a:'int64_t',
	   three_booleans: "bool[3]",
	   bbb:'bool',
	   cc: {
	       x:"double",
		   u16a:"uint16_t[2]",
		   yy:"double",
		   nest: {
		      u32a:"uint32_t[5]",
		      flag:"bool",
		   },
		   lst:"char[10]"
	   },
	   dd:"int",
	   ee:"uint32_t"
	}

            //press ctrl+D

	struct SimpleData {
	    
	    static constexpr auto LeafToStrLmbd=[](auto v,int64_t cnt_if_cary_ptr)->std::string { 
		using T=std::remove_cvref_t<decltype(v)>; 
		if constexpr(std::is_same_v<T,char*>)     { std::string s{"\""};s+=std::string(v);s+="\"";return(s);} 
		else if constexpr(std::is_same_v<T,bool>) { return(v?(std::string{"true"}):(std::string{"false"}));} 
		else if constexpr(std::is_pointer_v<T>)   {
		     using ET = std::remove_cvref_t<std::remove_pointer_t<T>>; 
		     std::string s{"["};
		     if(cnt_if_cary_ptr == 0) {
	    
		     } else {
			if constexpr(std::is_same_v<ET,bool>) {
			    for(int64_t i=0;i<cnt_if_cary_ptr-1;++i) {s+=(v[i]?(std::string{"true"}):(std::string{"false"}));s+=",";}
			    s+=(v[cnt_if_cary_ptr-1]?(std::string{"true"}):(std::string{"false"}));
			} else {
			    for(int64_t i=0;i<cnt_if_cary_ptr-1;++i) {s+=std::to_string(v[i]);s+=",";}
			    s+=std::to_string(v[cnt_if_cary_ptr-1]);                    
			}
		     }
		     s+="]";
		     return(s);
		} 
		else {return(std::to_string(v));}
	    };
	    
	    ////<data>
	    int64_t  a                ;
	    bool     three_booleans[3];
	    bool     bbb              ;
	    struct  {
		////<----data---->
		double   x      ;
		uint16_t u16a[2];
		double   yy     ;
		struct  {
		    ////<--------data-------->
		    uint32_t u32a[5];
		    bool     flag   ;
		    ////</--------data-------->
		    ////<--------show-------->
		    void show(bool endl=true, std::string_view indent= "        ") noexcept {
			std::cout << indent << "{" << std::endl;
			std::cout << indent << "    "  << "\"u32a\"" <<  " : " << LeafToStrLmbd(u32a,5 ) << " , " << std::endl;
			std::cout << indent << "    "  << "\"flag\"" <<  " : " << LeafToStrLmbd(flag,-0) << "   " << std::endl;
			std::cout << indent << "}";
			if(endl) {std::cout << std::endl;} else {}
		    }
		    ////</--------show-------->
		}        nest   ;
		char     lst[10];
		////</----data---->
		////<----show---->
		void show(bool endl=true, std::string_view indent= "    ") noexcept {
		    std::cout << indent << "{" << std::endl;
		    std::cout << indent << "    "  << "\"x\"   " <<  " : " << LeafToStrLmbd(x   ,-0) << " , " << std::endl;
		    std::cout << indent << "    "  << "\"u16a\"" <<  " : " << LeafToStrLmbd(u16a,2 ) << " , " << std::endl;
		    std::cout << indent << "    "  << "\"yy\"  " <<  " : " << LeafToStrLmbd(yy  ,-0) << " , " << std::endl;
		    std::cout << indent << "    "  << "\"nest\"" <<  " : "; nest.show(false,"        "); std::cout << " , " << std::endl;
		    std::cout << indent << "    "  << "\"lst\" " <<  " : " << LeafToStrLmbd(lst ,10) << "   " << std::endl;
		    std::cout << indent << "}";
		    if(endl) {std::cout << std::endl;} else {}
		}
		////</----show---->
	    }        cc               ;
	    int      dd               ;
	    uint32_t ee               ;
	    ////</data>
	    ////<show>
	    void show(bool endl=true, std::string_view indent= "") noexcept {
		std::cout << indent << "{" << std::endl;
		std::cout << indent << "    "  << "\"a\"             " <<  " : " << LeafToStrLmbd(a             ,-0) << " , " << std::endl;
		std::cout << indent << "    "  << "\"three_booleans\"" <<  " : " << LeafToStrLmbd(three_booleans,3 ) << " , " << std::endl;
		std::cout << indent << "    "  << "\"bbb\"           " <<  " : " << LeafToStrLmbd(bbb           ,-0) << " , " << std::endl;
		std::cout << indent << "    "  << "\"cc\"            " <<  " : "; cc.show(false,"    "); std::cout << " , " << std::endl;
		std::cout << indent << "    "  << "\"dd\"            " <<  " : " << LeafToStrLmbd(dd            ,-0) << " , " << std::endl;
		std::cout << indent << "    "  << "\"ee\"            " <<  " : " << LeafToStrLmbd(ee            ,-0) << "   " << std::endl;
		std::cout << indent << "}";
		if(endl) {std::cout << std::endl;} else {}
	    }
	    ////</show>
	};


      #nv_cli_creat_cstruct_simple -n SimpleData -a  [a:int64_t three_booleans:bool[3] bbb:bool cc:[ x:double u16:uint16_t[2] yy:double nest[u32a:uint32_t[5] flag:bool] lst:char[10]] dd:int ee:uint32_t ]

detail mode

    TODO

LICENSE

  • ISC