Git Product home page Git Product logo

base-components-tool's Introduction

base-components-tool

目前支持线程池 定时器(支持多任务) log日志 cmdline 命令行解析 等功能

build

./build.sh

cmdline

normal usage

#include "cmdline/cmdline.h"
#include "util/single.hpp"
#include "log/log.h"

int main(int argv, char *argv)
{
    CmdLine *cmd = TypeSingle<CmdLine>::getInstance();
    // add specified type of variable.
    // 1st argument is short name
    // 2nd argument is long name
    // 3rd argument is description
    // 4th argument is depends option
    // 5th argument is paramter ranage
    cmd->add<std::unordered_multiset<int>>("-unmint", "--unorderdmsetint", 
                                        "get unordered_multiset int", 
                                        {"-dix"}, {44, 99});
    // add specified type of variable.
    // 1st argument is long name
    // 2nd argument is short name (no short name if '\0' specified)
    // 3rd argument is description
    // 4th argument is depends option
    cmd->add("-n", "--none", "get none", {"-s", "-us", "-i"});
    // add specified type of variable.
    // 1st argument is long name
    // 2nd argument is short name (no short name if '\0' specified)
    // 3rd argument is description
    // 4th argument is depends option
    // 5th argument is paramter ranage
    cmd->add<std::string>("-sns", "--singlestring", "get single string", 
                        {"-s", "-us", "-i"}, 
                        {"aaa", "vvv", "bbb", "rrr", "ttt"});
    //parse paramter argv
    cmd->parse(false, argc, argv);
    //get value
    std::string singleStr;
    bool ret = cmd->get("--singlestring", singleStr);
    ...
    ...
    ...
}

cmdline execution results

./build/install/demo/cmdline/cmdline 
usage: ./build/install/demo/cmdline/cmdline [options] ...
options:
-s        , --short                  get short
                                        parameter range is [33 , 55]
-us       , --us                     get unsigned short
-i        , --int                    get int
-ui       , --ui                     get unsigned int
                                        option depends [ -s -us -i ]
-f        , --float                  get float
                                        parameter range is [23 , 100]
-d        , --double                 get double
-l        , --long                   get long
-ul       , --ul                     get unsigned long
-string   , --string                 get string
                                        parameter range is [ aaa vvv bbb rrr ttt ]
-ls       , --lstring                get list string
                                        parameter range is [ aaa vvv bbb rrr ttt ]
-ss       , --sstring                get set string
                                        parameter range is [ aaa bbb rrr ttt vvv ]
-si       , --sint                   get set int
                                        option depends [ -ss -us ]
                                        parameter range is [44 , 99]
-ds       , --dstring                get deque string
                                        parameter range is [ aaa vvv bbb rrr ttt ]
-di       , --dint                   get deque int
                                        parameter range is [44 , 99]
-dsss     , --queuestring            get queue string
                                        parameter range is [ aaa vvv bbb rrr ttt ]
-diss     , --queueint               get queue int
                                        parameter range is [44 , 99]
-dsa      , --stackstring            get stack string
                                        parameter range is [ ttt rrr bbb vvv aaa ]
-dix      , --stackint               get stack int
                                        parameter range is [44 , 99]
-flstring , --forwardliststring      get forward_list string
                                        parameter range is [ aaa vvv bbb rrr ttt ]
-flint    , --forwardlistint         get forward_list int
                                        parameter range is [44 , 99]
-mmstr    , --multisetstring         get multiset string
                                        parameter range is [ aaa bbb rrr ttt vvv ]
-mmint    , --multisetint            get multiset int
                                        parameter range is [44 , 99]
-unstr    , --unorderedsetstring     get unordered_set string
                                        parameter range is [ bbb rrr vvv ttt aaa ]
-unint    , --unorderdsetint         get unordered_set int
                                        parameter range is [44 , 99]
-unmstr   , --unorderedmsetstring    get unordered_multiset string
                                        parameter range is [ bbb rrr vvv aaa ]
-unmint   , --unorderdmsetint        get unordered_multiset int
                                        parameter range is [44 , 99]
-n        , --none                   get none
                                        option depends [ -s -us -i ]
-sns      , --singlestring           get single string
                                        option depends [ -s -us -i ]
                                        parameter range is [ aaa vvv bbb rrr ttt ]
-sni1     , --singleint1             get single int1
                                        option depends [ -s -us -i ]
                                        parameter range is [12 , 33]
-sni2     , --singleint2             get single int2
                                        option depends [ -s -us -i ]
                                        parameter range is [12 , 33]
-v        , --version                get version
-h        , --help                   print help message

timer

./build/install/demo/timer/timer 
usage: ./build/install/demo/timer/timer [options] ...
options:
	-a        , --add                    add timer
	-c        , --clear                  delay sometime clear all timer
	-d        , --default                default mode
	-h        , --help                   print help message

base-components-tool's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.