Comments (2)
我用的是2010的buttonrpc:
https://github.com/button-chen/buttonrpc
from buttonrpc_cpp14.
修改了一下,好像是可以了:
`
template
inline void Serializer::output_type(T& t)
{
int len = sizeof(T);
char* d = new char[len];
if (!m_iodevice.is_eof()){
memcpy(d, m_iodevice.current(), len);
m_iodevice.offset(len);
byte_orser(d, len);
t = reinterpret_cast<T>(&d[0]);
}
delete [] d;
}
template<>
inline void Serializer::output_type(std::string& in)
{
int marklen = sizeof(uint32_t);
char* d = new char[marklen];
memcpy(d, m_iodevice.current(), marklen);
byte_orser(d, marklen);
int len = reinterpret_cast<uint32_t>(&d[0]);
m_iodevice.offset(marklen);
delete [] d;
if (len == 0) return;
in.insert(in.begin(), m_iodevice.current(), m_iodevice.current() + len);
m_iodevice.offset(len);
}
template
inline void Serializer::input_type(T t)
{
int len = sizeof(T);
char* d = new char[len];
const char* p = reinterpret_cast<const char*>(&t);
memcpy(d, p, len);
byte_orser(d, len);
m_iodevice.input(d, len);
delete [] d;
}
template<>
inline void Serializer::input_type(std::string in)
{
// 先存入字符串长度
uint32_t len = in.size();
char* p = reinterpret_cast< char*>(&len);
byte_orser(p, sizeof(uint32_t));
m_iodevice.input(p, sizeof(uint32_t));
// 存入字符串
if (len == 0) return;
char* d = new char[len];
memcpy(d, in.c_str(), len);
m_iodevice.input(d, len);
delete [] d;
}
template<>
inline void Serializer::input_type(const char* in)
{
input_typestd::string(std::string(in));
}`
from buttonrpc_cpp14.
Related Issues (10)
- RPC 服务器端不支持并发式执行 HOT 2
- client报错栈溢出
- 可以增加传输opencv图像cv::Mat格式的数据吗? HOT 2
- zmq 是啥版本的? HOT 1
- [BUG] 学习过程中看到的一些问题 HOT 1
- 请问这种写法是什么意思?看不太明白
- 跑readme中的demo,发现异常。 HOT 3
- 想请问一下opencv图片Mat该如何传递
- 大文件支持
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from buttonrpc_cpp14.