Code Monkey home page Code Monkey logo

capsfactory's Introduction

基于caps的消息类生成工具,支持序列化,反序列化,访问器,支持的语言:c++, js,java; js需要node-caps支持; java需要caps-jni支持;

编译

linux,mac测试通过 mkdir build; cd build; cmake../; make

Usage

c++代码生成: /PATH/TO/CapsFactory -i ./message_define.json -l cpp 将在当前目录创建cpp文件夹,include "MessageCommon.h"即可

js代码生成: /PATH/TO/CapsFactory -i ./message_define.json -l js

java代码生成: /PATH/TO/CapsFactory -i ./message_define.json -l java

消息定义

    "NameSpace": "rokid",
    "Comment": "demo message namespace",
    "Message": [
    {
      "MsgName": "DemoMessage",
      "Comment": "demo mesage define",
      "Fields": [
        {
          "Name": "msg_id",
          "Type": "uint32",
          "Comment": "message id with default value 123",
          "Default": 123
        },
        {
          "Name": "content_list",
          "Type": "string",
          "Repeated": true,
          "Comment": "array of message content"
        },{
          "Name": "msg_time",
          "Type": "string",
          "Comment": "message datetime string"
        }
      ]
    },
    {
      "MsgName": "MessageContainAnotherMessage",
      "Comment": "a message contains other messsages",
      "Fields": [
        {
          "Name": "id",
          "Type": "uint32",
          "Comment": "id"
        },
        {
          "Name": "AnotherMessage",
          "Type": "DemoMessage",
          "Comment": "user-defined message"
        }
      ]
    }
    ]
}

NameSpace 命名空间,c++对应namespace, java对应package, nodejs对应文件名

Comment 注释(NameSpace,Message,Field都可以添加注释)

Message 消息定义

Message.MsgName 消息名称,每个消息对应一个消息类,MsgName为类名

Message.Fields 消息类的成员变量

Message.Fields.Name 变量名称

Message.Fields.Type 变量类型, 目前支持的类型为int32 uint32 int64 uint64 float double string和自定义数据; 自定义数据就是当前定义文件内定义的其他Message

Message.Fields.Repeated 可选,bool,为true表示当前字段为数组

Message.Fields.Default 可选,当前字段默认值,int32, uint32, int64, uint64, float, double等类型字段必须为number; string型数据输入必须为string 自定义类型暂不支持默认值设置

capsfactory's People

Contributors

feelychau avatar

Watchers

James Cloos avatar

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.