yksten / struct2x Goto Github PK
View Code? Open in Web Editor NEWC++结构体序列化
C++结构体序列化
double GenericReader::convertDouble(const char* value, uint32_t length) {
if (!length) return 0.0;
bool isNegative = false; // Flag to indicate if the number is negative
double result = 0.0;
uint32_t startIdx = 0; // Start index for processing the number
// Check for negative sign
if (value[0] == '-') {
isNegative = true;
startIdx = 1; // Start processing from the next character
}
for (uint32_t idx = startIdx, bFlag = false, num = 0; idx < length; ++idx) {
const char& c = value[idx];
if (c == '.') {
bFlag = true;
continue;
}
uint8_t n = c - '0';
if (!bFlag) {
result *= 10;
result += n;
}
else {
++num;
result += decimal(n, num);
}
}
// Negate the result if the number is negative
if (isNegative) {
result = -result;
}
return result;
}
build in vs2022 come this error
jiuxian.tjo@B-Q3GDMD6M-2146 build % make
Scanning dependencies of target struct2x
[ 9%] Building CXX object CMakeFiles/struct2x.dir/src/struct2x.cpp.o
In file included from /Users/jiuxian.tjo/git/c++_project/struct2x/src/struct2x.cpp:1:
/Users/jiuxian.tjo/git/c++_project/struct2x/./include/struct2x.h:204:71: error: use of undeclared identifier '_atoi64'
static inline int64_t strto(const char* str) { return _atoi64(str); }
^
/Users/jiuxian.tjo/git/c++_project/struct2x/./include/struct2x.h:209:82: error: use of undeclared identifier '_atoi64'
static inline uint64_t strto(const char* str) { return (uint64_t)_atoi64(str); }
^
/Users/jiuxian.tjo/git/c++_project/struct2x/./include/struct2x.h:235:81: error: implicit instantiation of undefined template
'std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >'
static inline const char* tostr(const std::string& v) { return v.c_str(); }
大致结构就是,一个结构体中嵌套变长数组,以及可能存在链表或者链树这种数据结构,这个项目支持吗,谢谢
vector容器支持自定义结构体吗?
您好,打算将您的代码用于商业用途,不知这个项目的开源协议是哪个?
我看里面用到了 cJSON 和 protobuf 的代码,是 MIT 协议么?
谢谢!
protobuf/decoder.h encoder.h缺少cstring
/mnt/d/NEW_CONF/struct2x/./include/struct2x/protobuf/encoder.h: In constructor ‘struct2x::PBEncoder::enclosure_t::enclosure_t(uint32_t, uint32_t)’:
/mnt/d/NEW_CONF/struct2x/./include/struct2x/protobuf/encoder.h:45:70: error: ‘memset’ was not declared in this scope
45 | enclosure_t(uint32_t t, uint32_t n) : type(t), size(n) { memset(sz, 0, 10); }
| ^~~~~~
/mnt/d/NEW_CONF/struct2x/./include/struct2x/protobuf/encoder.h:9:1: note: ‘memset’ is defined in header ‘’; did you forget to ‘#include ’?
8 | #include <struct2x/traits.h>
+++ |+#include
9 |
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.