11 Commits

Author SHA1 Message Date
3bc5b50905 refactor: split message classes 2025-02-18 19:40:41 +01:00
66835554f1 enum class field access 2025-02-18 19:33:02 +01:00
e16ad84865 oui 2025-02-18 19:12:51 +01:00
c1e6409c18 idk 2025-02-18 19:12:35 +01:00
3ad18cacf6 add handlers constness 2025-02-18 19:12:16 +01:00
2eab50932f better example 2025-02-18 19:09:40 +01:00
baa52d3baa databuffer 2025-02-18 19:02:33 +01:00
d924685e0c oups 2025-02-18 19:00:59 +01:00
044b12cdec refactor 2025-02-18 19:00:01 +01:00
e39f8de898 better fields access 2025-02-15 12:39:53 +01:00
0b28bde25b test 2025-02-08 20:11:02 +01:00
4 changed files with 86 additions and 14 deletions

View File

@@ -6,8 +6,7 @@
namespace sp { namespace sp {
class PacketHandler; class PacketHandler;
using PacketMessage = Message< using PacketMessage = Message<option::MsgIdType<std::uint8_t>, // add id() operation
option::MsgIdType<std::uint8_t>, // add id() operation
option::ReadOperations, // add read() operation option::ReadOperations, // add read() operation
option::WriteOperations, // add write() operation option::WriteOperations, // add write() operation
option::WriteId, // write id before data option::WriteId, // write id before data

View File

@@ -114,6 +114,6 @@ template <typename TField, typename... TFields>
struct FieldsBuilder<TField, TFields...> { struct FieldsBuilder<TField, TFields...> {
using Type = sp::tuple_cat_t<std::tuple<Field<TField, 0>>, typename FieldsBuilder<TFields...>::Type>; using Type = sp::tuple_cat_t<std::tuple<Field<TField, 0>>, typename FieldsBuilder<TFields...>::Type>;
}; };
} // namespace details } // namespace details
} // namespace sp } // namespace sp

View File

@@ -2,12 +2,15 @@ add_rules("mode.debug", "mode.release")
set_languages("c++17") set_languages("c++17")
add_requires("enet6")
target("SimpleProtocolLib") target("SimpleProtocolLib")
add_includedirs("include") add_includedirs("include", {public = true})
add_headerfiles("include/(sp/**.h)") set_kind("binary")
set_group("Library") add_files("src/**.cpp")
add_files("src/sp/**.cpp") add_packages("enet6", {public = true})
set_kind("$(kind)")
-- Tests -- Tests
for _, file in ipairs(os.files("test/**.cpp")) do for _, file in ipairs(os.files("test/**.cpp")) do
@@ -16,9 +19,79 @@ for _, file in ipairs(os.files("test/**.cpp")) do
set_kind("binary") set_kind("binary")
add_files(file) add_files(file)
add_includedirs("include")
set_default(false)
add_deps("SimpleProtocolLib") add_deps("SimpleProtocolLib")
add_tests("compile_and_run") add_tests("compile_and_run")
end end
--
-- If you want to known more usage about xmake, please see https://xmake.io
--
-- ## FAQ
--
-- You can enter the project directory firstly before building project.
--
-- $ cd projectdir
--
-- 1. How to build project?
--
-- $ xmake
--
-- 2. How to configure project?
--
-- $ xmake f -p [macosx|linux|iphoneos ..] -a [x86_64|i386|arm64 ..] -m [debug|release]
--
-- 3. Where is the build output directory?
--
-- The default output directory is `./build` and you can configure the output directory.
--
-- $ xmake f -o outputdir
-- $ xmake
--
-- 4. How to run and debug target after building project?
--
-- $ xmake run [targetname]
-- $ xmake run -d [targetname]
--
-- 5. How to install target to the system directory or other output directory?
--
-- $ xmake install
-- $ xmake install -o installdir
--
-- 6. Add some frequently-used compilation flags in xmake.lua
--
-- @code
-- -- add debug and release modes
-- add_rules("mode.debug", "mode.release")
--
-- -- add macro definition
-- add_defines("NDEBUG", "_GNU_SOURCE=1")
--
-- -- set warning all as error
-- set_warnings("all", "error")
--
-- -- set language: c99, c++11
-- set_languages("c99", "c++11")
--
-- -- set optimization: none, faster, fastest, smallest
-- set_optimize("fastest")
--
-- -- add include search directories
-- add_includedirs("/usr/include", "/usr/local/include")
--
-- -- add link libraries and search directories
-- add_links("tbox")
-- add_linkdirs("/usr/local/lib", "/usr/lib")
--
-- -- add system link libraries
-- add_syslinks("z", "pthread")
--
-- -- add compilation and link flags
-- add_cxflags("-stdnolib", "-fno-strict-aliasing")
-- add_ldflags("-L/usr/local/lib", "-lpthread", {force = true})
--
-- @endcode
--