在哪个头文件中,在 ZeroMQ 中定义了 smessage() 方法
In which header file is the method smessage() defined in ZeroMQ?
下面是ZeroMQ中使用smessage
方法的代码。我在zhelpers.hpp
头文件中搜索了它的定义,但它不存在。
#include "zhelpers.hpp"
#include <string>
int main (int argc, char *argv[])
{
// Process tasks forever
while (1) {
zmq::message_t message;
int workload; // Workload in msecs
receiver.recv(&message);
std::string smessage(static_cast<char*>(message.data()), message.size());
std::istringstream iss(smessage);
iss >> workload;
// Do the work
s_sleep(workload);
// Send results to sink
message.rebuild();
sender.send(message);
// Simple progress indicator for the viewer
std::cout << "." << std::flush;
}
return 0;
}
smessage
不是方法。它是 std::string
类型的变量,它是通过使用接受指针和大小的重载构造函数创建的。
顺便说一句,您可以直接使用zmq::message_t::str()
函数来获取std::string
。
例如:
zmq::message_t msg;
// read some data...
std::string smessage = msg.str();
std::string smessage(static_cast<char*>(message.data()), message.size());
不是对函数smessage
的调用,而是调用构造函数的std::string
变量的定义
basic_string( const CharT* s,
size_type count,
const Allocator& alloc = Allocator() );
相关文章:
- 为不同配置设置MSVC_RUNTIME_LIBRARY的正确方法是什么
- 通过方法访问结构
- 最小硬币更换问题(自上而下方法)
- C++为构建时间获取QDateTime的可靠方法
- 在C#中处理C++指针而不使用unsafe的最佳方法
- 处理多个异常集合的C++方法
- 如果C++类在类方法中具有动态分配,但没有构造函数/析构函数或任何非静态成员,那么它仍然是POD类型吗
- 有什么方法可以遍历结构吗
- 当类在C++中定义时,有什么方法可以"register"类吗?
- 在C++中,将大的无符号浮点数四舍五入为整数的最佳方法是什么
- 实现无开销push_back的最佳方法是什么
- 使用std::函数映射对象方法
- 有符号的int和int-有没有一种方法可以在C++中区分它们
- C++从另一个类访问公共静态向量的正确方法是什么
- C++优先级队列,按对象的唯一指针的特定方法升序排列
- 没有为自己的结构调用列表推回方法
- 有没有什么方法可以使用一个函数中定义的常量变量,也可以由c++中同一程序中的其他函数使用
- 在类定义之后定义一个私有方法
- 枚举环境变量的惯用C++14/C++17方法
- 在哪个头文件中,在 ZeroMQ 中定义了 smessage() 方法