3 #include "ypc/core/exceptions.h"
4 #include "ypc/core/filesystem.h"
5 #include "ypc/corecommon/package.h"
6 #include <ff/net/middleware/ntpackage.h>
16 : m_path(file_path) {}
18 inline NtObjTy &data() {
return m_sfm_data; }
20 inline const NtObjTy &data()
const {
return m_sfm_data; }
23 if (!is_file_exists(m_path)) {
28 fs.open(m_path, std::ios::in | std::ios::binary);
31 size_t size = fs.tellg();
35 fs.read((
char *)buf.data(), size);
36 ff::net::marshaler m((
const char *)buf.data(), size,
37 ff::net::marshaler::deserializer);
45 fs.open(m_path, std::ios::out | std::ios::binary);
49 ff::net::marshaler m(ff::net::marshaler::length_retriver);
51 size_t len = m.get_length();
54 ff::net::marshaler sm((
char *)buf.data(), len,
55 ff::net::marshaler::serializer);
58 fs.write((
const char *)buf.data(), len);
68 constexpr
static uint32_t value = 0;
70 template <
typename... ARGS>
72 constexpr
static uint32_t value = 1;
74 template <uint32_t PackageID,
typename... ARGS>
76 constexpr
static uint32_t value = 2;
80 template <
typename NtObjTy,
84 template <
typename NtObjTy>
87 typename cast_obj_to_package<NtObjTy>::type> {
94 inline NtObjTy &data() {
return m_local_data; }
96 inline const NtObjTy &data()
const {
return m_local_data; }
99 m_local_data = base_t::m_sfm_data;
102 base_t::m_sfm_data = m_local_data;
107 NtObjTy m_local_data;
110 template <
typename NtObjTy>
122 "ntobject_file only support ff::util::ntobject and ff::net::ntpackage");