{"id":19778771,"url":"https://github.com/acl-dev/cowboy","last_synced_at":"2025-10-31T08:50:45.700Z","repository":{"id":149129272,"uuid":"96443227","full_name":"acl-dev/cowboy","owner":"acl-dev","description":"c++ data access object generator.it base on acl.","archived":false,"fork":false,"pushed_at":"2017-07-17T08:06:04.000Z","size":222,"stargazers_count":8,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-30T21:39:05.879Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/acl-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-06T15:08:43.000Z","updated_at":"2024-07-18T09:03:26.000Z","dependencies_parsed_at":"2023-09-02T23:22:28.817Z","dependency_job_id":null,"html_url":"https://github.com/acl-dev/cowboy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/acl-dev/cowboy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acl-dev%2Fcowboy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acl-dev%2Fcowboy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acl-dev%2Fcowboy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acl-dev%2Fcowboy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/acl-dev","download_url":"https://codeload.github.com/acl-dev/cowboy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acl-dev%2Fcowboy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281960762,"owners_count":26590416,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-31T02:00:07.401Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T05:31:30.728Z","updated_at":"2025-10-31T08:50:45.695Z","avatar_url":"https://github.com/acl-dev.png","language":"C++","readme":"## what is cowboy ?\ncowboy is c++ orm working boy :)\nit parse models and mappers and then generate dao files.\nit like myBatis. but without verbose xml config files\n\n### how to build?\nbuild acl first\n```\ngit clone https://github.com/acl-dev/acl.git\ncd acl\nmake build_one\n\n```\nbuild cowboy.it depend on acl. run \"cmake . -DACL_ROOT=acl_path\" to generate CMakeFile. and acl_path is acl's path.eg:\n/home/akzi/code/acl/\n```\ngit clone https://github.com/acl-dev/cowboy.git\ncd cowboy\nmkdir cmake_build\ncd cmake_build \ncmake .. -DACL_ROOT=acl_path\n```\n## how it work?\ncowboy parse model files and mappers,and generate c++ code.\n\n## how to use\n```\nakzi:~/code/dao_generator/cmake_build$ ./cowboy -h\nusage: \n    -h                        'help'\n    -o                        'parse mapper + model generate dao'\n    -u                        'parse sql files generate model + mapper file'\n    -m                        'generate multifile,file per table,default generate single'\n    -x                        'generate dao to 'dao',\n                              'generate mapper to 'mapper',\n                              'generate model to 'model',\n                              'generate create_tables.hpp to create_tables '\n    -s scan_path              'path to scan,default current dir'\n    -d dao_path               'generate dao path,default current dir'\n    -c mapper_path            'generate mapper file path,default current dir'\n    -k model_path             'generate model file path,default current dir'\n    -j create_tables_path     'generate create_tables.hpp file path,default current dir'\n\n\nabout:\n     scan_path:the path cowboy to scan.it will scan files with *.sql when with -u\n               and scan *.h files with -o \n\neg:\n./cow_boy -u -o\n./cow_boy -u -o -x\n./cow_boy -u -o -x -m\n./cow_boy -u -o -d daos -c mappers -k models -j create_table\n\neg:\n./cow_boy -u -o\n./cow_boy -u -o -x\n./cow_boy -u -o -x -m\n./cow_boy -u -o -d daos -c mappers -k models -j create_table\n\n```\n### generate model files from sql\n\n```\n./cow_boy -u\n```\ncow_boy will scan all *.sql files. and parse all ```create table(...)...; ```sqls,  and generate model file.\n\n\n### define models\n\n```\n//@Models\n#pragma once\n#include \u003cstring\u003e\n#include \u003clist\u003e\n\n//@Model\n//@Table{customer}\nstruct customer_t\n{\n    customer_t()\n    {\n        id = 0;\n        int a = 2;\n        a++;\n\n    }\n    long long int id;\n    std::string address;\n\n    //@Column{postcode}\n    std::string postcode;\n\n    //@Column{sex}\n    std::string sex;\n\n    //@Column{cname}\n    std::string cname;\n};\n\n//@Model\n//@Table{orders}\nstruct orders_t\n{\n    orders_t()\n    {\n        id = 0;\n        customer_id = 0;\n\n    }\n    int id;\n    std::string code;\n    int customer_id;\n};\n\n//@Model\nstruct customer_order_t :customer_t\n{\n    std::list\u003corders_t\u003e orders;\n};\n\n//@Model\nstruct order_customer_t :orders_t\n{\n    customer_t customer;\n};\n```\n\n* second define mapper\n\n```cpp\n//@Mappers\n#pragma once\n\n//@Mapper\nstruct customer_mapper\n{\n    //@Insert{insert into customer(address,postcode,sex,cname) values (:address,:postcode,:sex,:cname)}\n    virtual bool insert(const customer_t \u0026obj) = 0;\n\n    //@Delete{delete from customer where id=:id}\n    virtual bool delete_by_id(int id) = 0;\n\n    //@Update{update customer set address=:address,postcode=:postcode,sex=:sex,cname=:cname where id=:id}\n    virtual bool update(const customer_t \u0026obj) = 0;\n\n    //@Update{update customer set address=:new_address where id=:id}\n    virtual bool update_address(const customer_t \u0026obj,const std::string \u0026new_address) = 0;\n\n    //@Select{select * from customer where id=:id}\n    virtual bool select_by_id(customer_t \u0026obj, int id) = 0;\n};\n\n//@Mapper\nstruct orders_mapper \n{\n    //@Insert{insert into order(code,customer_id) values (:code,:customer_id)}\n    virtual bool insert(const orders_t \u0026obj) = 0;\n\n    //@Delete{delete from order where id=:id}\n    virtual bool delete_by_id(int id) = 0;\n\n    //@Update{update order set code=:code,customer_id=:customer_id where id=:id}\n    virtual bool update(const orders_t \u0026obj) = 0;\n\n    //@Select{select * from order where id=:id}\n    virtual bool select_by_id(orders_t \u0026obj, int id) = 0;\n\n    //@Select{select * from order where cname=:name}\n    virtual bool select_by_name(std::list\u003corders_t\u003e \u0026obj, std::string \u0026name) = 0;\n\n    //@Select{select * from order where customer_id=:cid}\n    virtual bool get_customer_ordors(std::list\u003corders_t\u003e \u0026obj, int cid) = 0;\n\n    //@Select{select * from order where customer_id=:cid and code !=:code}\n    virtual bool get_customer_ordors_without(std::list\u003corders_t\u003e \u0026obj, int cid, const std::string \u0026code) = 0;\n};\n\n//@Mapper\nstruct customer_order_mapper\n{\n    //@Select{select c.id as cid,c.address,c.postcode,c.sex,c.cname,o.id as od,o.code,o.customer_id from customer c, order o where c.id=:id and o.customer_id=c.id}\n    //@Result{column=cid, property=id}\n    //@Result{column=oid, property=orders.id}\n    virtual bool get_customer_order(customer_order_t \u0026obj, int id) = 0;\n\n    //@Select{select c.id as cid,c.address,c.postcode,c.sex,c.cname,o.id as oid,o.code,o.customer_id from customer c, orders o where  o.customer_id=c.id}\n    //@Result{column=cid, property=id}\n    //@Result{column=oid, property=orders.id}\n    virtual bool get_customer_orders(std::list\u003ccustomer_order_t\u003e \u0026obj) = 0;\n};\n\n//@Mapper\nstruct order_customer_mapper\n{\n    //@Select{select c.id as cid,c.address,c.postcode,c.sex,c.cname,o.id as oid,o.code,o.customer_id from customer c, orders o where o.id=:id and o.customer_id = c.id}\n    //@Result{column=cid, property=customer.id}\n    //@Result{column=oid, property=id}\n    virtual bool get_order_customer(order_customer_t \u0026obj, int id) = 0;\n\n    //@Select{select c.id as cid,c.address,c.postcode,c.sex,c.cname,o.id as oid,o.code,o.customer_id from customer c, orders o where o.customer_id = c.id}\n    //@Result{column=cid, property=customer.id}\n    //@Result{column=oid, property=id}\n    virtual bool get_order_customers(std::list\u003corder_customer_t\u003e \u0026obj) = 0;\n\n\n    //@Select{select c.id as cid,c.address,c.postcode,c.sex,c.cname,o.id as oid,o.code,o.customer_id from customer c, orders o where o.customer_id = c.id and c.cname = :name}\n    //@Result{column=cid, property=customer.id}\n    //@Result{column=oid, property=id}\n    virtual bool get_order_customers_by_name(std::list\u003corder_customer_t\u003e \u0026obj,const std::string \u0026 name) = 0;\n};\n```\n\n* generate c++ code\n\n```\n    akzi@akzi:~/code/dao_generator/cmake_build/dao$ ls\n    CMakeCache.txt  CMakeFiles  cmake_install.cmake  dao  gen_dao  Makefile  mapper.h  model.h\n    ./gen_dao -s . -d ./dao\n    akzi@akzi:~/code/dao_generator/cmake_build/dao$ ls\n    dao.cpp  dao.h\n```\nit will generate dao files.\n\nshow dao.h file\n\n```cpp\n#pragma once\n\nclass customer_dao: public customer_mapper\n{\npublic:\n    customer_dao(acl::db_handle\u0026 handle);\n\n    //@Insert{insert into customer(address,postcode,sex,cname) values (:address,:postcode,:sex,:cname)}\n\tvirtual bool insert(const customer_t \u0026obj) ;\n\n\t//@Delete{delete from customer where id=:id}\n\tvirtual bool delete_by_id(int id) ;\n\n\t//@Update{update customer set address=:address,postcode=:postcode,sex=:sex,cname=:cname where id=:id}\n\tvirtual bool update(const customer_t \u0026obj) ;\n\n\t//@Update{update customer set address=:new_address where id=:id}\n\tvirtual bool update_address(const customer_t \u0026obj,const std::string \u0026new_address) ;\n\n\t//@Select{select * from customer where id=:id}\n\tvirtual bool select_by_id(customer_t \u0026obj, int id) ;\n\nprivate:\n\tacl::db_handle\u0026 db_handle_;\n};\n\nclass orders_dao: public orders_mapper\n{\npublic:\n\torders_dao(acl::db_handle\u0026 handle);\n\n\t//@Insert{insert into order(code,customer_id) values (:code,:customer_id)}\n\tvirtual bool insert(const orders_t \u0026obj) ;\n\n\t//@Delete{delete from order where id=:id}\n\tvirtual bool delete_by_id(int id) ;\n\n\t//@Update{update order set code=:code,customer_id=:customer_id where id=:id}\n\tvirtual bool update(const orders_t \u0026obj) ;\n\n\t//@Select{select * from order where id=:id}\n\tvirtual bool select_by_id(orders_t \u0026obj, int id) ;\n\n\t//@Select{select * from order where cname=:name}\n\tvirtual bool select_by_name(std::list\u003corders_t\u003e \u0026obj, std::string \u0026name) ;\n\n\t//@Select{select * from order where customer_id=:cid}\n\tvirtual bool get_customer_ordors(std::list\u003corders_t\u003e \u0026obj, int cid) ;\n\n\t//@Select{select * from order where customer_id=:cid and code !=:code}\n\tvirtual bool get_customer_ordors_without(std::list\u003corders_t\u003e \u0026obj, int cid, const std::string \u0026code) ;\n\nprivate:\n\tacl::db_handle\u0026 db_handle_;\n};\n\nclass customer_order_dao: public customer_order_mapper\n{\npublic:\n\tcustomer_order_dao(acl::db_handle\u0026 handle);\n\n\t//@Select{select c.id as cid,c.address,c.postcode,c.sex,c.cname,o.id as od,o.code,o.customer_id from customer c, order o where c.id=:id and o.customer_id=c.id}\n\t//@Result{column=cid, property=id}\n\t//@Result{column=oid, property=orders.id}\n\tvirtual bool get_customer_order(customer_order_t \u0026obj, int id) ;\n\n\t//@Select{select c.id as cid,c.address,c.postcode,c.sex,c.cname,o.id as oid,o.code,o.customer_id from customer c, orders o where  o.customer_id=c.id}\n\t//@Result{column=cid, property=id}\n\t//@Result{column=oid, property=orders.id}\n\tvirtual bool get_customer_orders(std::list\u003ccustomer_order_t\u003e \u0026obj) ;\n\nprivate:\n\tacl::db_handle\u0026 db_handle_;\n};\n\nclass order_customer_dao: public order_customer_mapper\n{\npublic:\n\torder_customer_dao(acl::db_handle\u0026 handle);\n\n\t//@Select{select c.id as cid,c.address,c.postcode,c.sex,c.cname,o.id as oid,o.code,o.customer_id from customer c, orders o where o.id=:id and o.customer_id = c.id}\n\t//@Result{column=cid, property=customer.id}\n\t//@Result{column=oid, property=id}\n\tvirtual bool get_order_customer(order_customer_t \u0026obj, int id) ;\n\n\t//@Select{select c.id as cid,c.address,c.postcode,c.sex,c.cname,o.id as oid,o.code,o.customer_id from customer c, orders o where o.customer_id = c.id}\n\t//@Result{column=cid, property=customer.id}\n\t//@Result{column=oid, property=id}\n\tvirtual bool get_order_customers(std::list\u003corder_customer_t\u003e \u0026obj) ;\n\n\t//@Select{select c.id as cid,c.address,c.postcode,c.sex,c.cname,o.id as oid,o.code,o.customer_id from customer c, orders o where o.customer_id = c.id and c.cname = :name}\n\t//@Result{column=cid, property=customer.id}\n\t//@Result{column=oid, property=id}\n\tvirtual bool get_order_customers_by_name(std::list\u003corder_customer_t\u003e \u0026obj,const std::string \u0026 name) ;\n\nprivate:\n\tacl::db_handle\u0026 db_handle_;\n};\n```\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facl-dev%2Fcowboy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Facl-dev%2Fcowboy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facl-dev%2Fcowboy/lists"}