Skip to content

📦 A C++23 SECS-II/SEMI E5 serialization library, supporting byte serialization and SML formatting.(使用C++23开发的SECS-II/SEMI E5序列化库,支持字节序列化和SML格式化。)

License

Notifications You must be signed in to change notification settings

Zhuagenborn/SECS-II-Serialization

Repository files navigation

SECS-II Serialization

C++ CMake GitHub Actions License

Introduction

A SECS-II/SEMI E5 serialization library written in C++23, supporting:

  • Deserializing SECS-II data from bytes.
  • Serializing SECS-II data to bytes.
  • Formatting SECS-II data to SML (SECS Message Language) strings.

Unit Tests

Prerequisites

  • Install GoogleTest.
  • Install CMake.

Building

Go to the project folder and run:

mkdir -p build
cd build
cmake -DSECS2_BUILD_TESTS=ON ..
cmake --build .

Running

Go to the build folder and run:

ctest -V

Examples

Serialization

List list;
list.push_back(U1 {1, 2});
list.push_back(list);
list.push_back(ASCII {"msg"});
list.push_back(U2 {3, 4});
list.push_back(U1 {});

const auto bytes {Message {list}.ToBytes()};

The value of bytes is:

0x01 (List, 1 size byte)
0x05 (5 elements)
    0xA5 (U1, 1 size byte)
    0x02 (2 bytes)
        0x01 (1)
        0x02 (2)
    0x01 (List, 1 size byte)
    0x01 (1 element)
        0xA5 (U1, 1 size byte)
        0x02 (2 bytes)
            0x01 (1)
            0x02 (2)
    0x41 (ASCII, 1 size byte)
    0x03 (3 bytes)
        0x6D ('m')
        0x73 ('s')
        0x67 ('g')
    0xA9 (U2, 1 size byte)
    0x02 (4 bytes)
        0x00 0x03 (3)
        0x00 0x04 (4)
    0xA5 (U1, 1 size byte)
    0x00 (0 bytes)

SML Formatting

List list;
list.push_back(I1 {});
list.push_back(Binary {static_cast<std::byte>(1), static_cast<std::byte>(2)});
list.push_back(list);
list.push_back(ASCII {"hello"});

const auto sml {Message {list}.ToSml()};

The value of sml is:

<L [4]
    <I1 [0]>
    <B [2] 0x01 0x02>
    <L [2]
        <I1 [0]>
        <B [2] 0x01 0x02>
    >
    <A [5] "hello">
>

License

Distributed under the MIT License. See LICENSE for more information.

About

📦 A C++23 SECS-II/SEMI E5 serialization library, supporting byte serialization and SML formatting.(使用C++23开发的SECS-II/SEMI E5序列化库,支持字节序列化和SML格式化。)

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •