整理代码

This commit is contained in:
蒲爽 2026-09-28 21:33:04 +08:00
commit c7b4e178ec
364 changed files with 59691 additions and 0 deletions

23
util/xpack/example/bitfield.cpp Executable file
View file

@ -0,0 +1,23 @@
#include <iostream>
#include "xpack/json.h"
#include "xpack/xml.h"
using namespace std;
struct Test {
short ver:8;
short len:8;
string name;
XPACK(B(F(0), ver, len), O(name));
};
int main() {
Test t;
string json="{\"ver\":4, \"len\":20, \"name\":\"IPv4\"}";
xpack::json::decode(json, t);
cout<<t.ver<<endl;
cout<<t.len<<endl;
cout<<xpack::xml::encode(t, "root")<<endl;
return 0;
}