2 Star 6 Fork 2

brinkqiang / luapb

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

luapb

Copyright (c) 2013-2018 brinkqiang (brink.qiang@gmail.com)

luapb License blog Open Source Love GitHub stars GitHub forks

Build status

Linux Mac Windows
lin-badge mac-badge win-badge

Intro

luapb

win

build.bat
cd bin\relwithdebinfo
lua ..\script\msg.lua  

linux

bash build.sh
cd bin/relwithdebinfo
./lua ../script/msg.lua  
pb_import enter
pb_import leave
pbtest 1361563254513615632545@163.com (2first2second2three
local pb = require("luapb")
local luajson = require("luajson")

pb.import("net.proto")

local name = pb.id2name(8345))
local id = pb.name2id("net.tb_Person"))

local msg = pb.pb_new("net.tb_Person")

msg.number = "13615632545"
msg.email = "13615632545@163.com"
msg.age = 28
msg.ptype = 2
msg.desc:add("first")
msg.desc:add("second")
msg.desc:add("three")

local msg_debugstring = pb.tostring(msg)

local buffer = pb.serializeToString(msg)

local msg2 = pb.new("net.tb_Person")
pb.parseFromString(msg2, buffer)

local tb_msg = {
    number = "13615632545",
    email = "13615632545@163.com",
    age = 28,
    ptype = "WORK",
    desc = {"first", "second", "three"},
    jobs = {
        {
            jobtype = 8345,
            jobdesc = "coder"
        },
        {
            jobtype = 9527,
            jobdesc = "coder2"
        }
    }
}

local buffer2 = pb.encode("net.tb_Person", tb_msg)
local tb_msg2 = pb.decode("net.tb_Person", buffer2)

local str_json = pb.table2json("net.tb_Person", tb_msg2)
local str_xml = pb.table2xml("net.tb_Person", tb_msg2)
local str_yaml = pb.table2yaml("net.tb_Person", tb_msg2)

local tb_json = pb.json2table("net.tb_Person", str_json)
local tb_xml = pb.xml2table("net.tb_Person", str_xml)
local tb_yaml = pb.yaml2table("net.tb_Person", str_yaml)

Contacts

Join the chat

Thanks

MIT License Copyright (c) 2018 brinkqiang (brink.qiang@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Lua 内置模块实现了类似于 CMake 的模块化功能。它通过在模块内直接调用 Protobuf 的反射特性,实现了在 Lua 层面上的自动反射。该模块支持 Protobuf 2 和 Protobuf 3,并能实现 Protobuf、Lua table 与其他数据结构(如 XML、JSON、YAML)之间的转换。该模块已经通过了 Windows 和 Linux 的编译测试。 展开 收起
C++ 等 4 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C++
1
https://gitee.com/brinkqiang/luapb.git
git@gitee.com:brinkqiang/luapb.git
brinkqiang
luapb
luapb
master

搜索帮助