gpt4 book ai didi

时间:2019-03-08 标签:c++bloombergapicorrelationId

转载 作者:太空狗 更新时间:2023-10-29 20:56:53 24 4
gpt4 key购买 nike

我正在使用 bloomberg api 来编写一个 cpp 项目。
当我需要向 Bloomberg 数据提要发送请求时,我必须发送带有 ID 的请求。例如:

session->sendRequest(*request, CorrelationId(20));

CorrelationId 由 bloomberg api 提供,用于生成 ID。
这里的 ID 是 20。来自 bloomberg 数据提要的结果包含 ID 20,因此我可以识别结果和请求。这意味着当我从数据馈送中得到结果时,有这样的东西:
correlationId=[ valueType=INT classId=0 value=20 ]

现在我想制作一个字符串 ID,而不是 int ID。例如,我想生成一个像 CorrelationId("US543119ES") 这样的 ID。
如果这样做,我不会收到任何错误,但结果中的 ID 将变为:
correlationId=[ valueType=POINTER classId=0 value=00731378 ]

好像ID变成了一个指针,它发送的是指针的值,而不是指针的内容。显然value=00731378是一个地址。

难道不能生成字符串ID吗?
如果可以,我该怎么做?
我找到了 CorrelationId 的文档.

CorrelationId有两个构造函数我不知道怎么用,不知道是不是我需要的:

CorrelationId (void *value, int classId=0);
template<typename TYPE >
CorrelationId (const TYPE &smartPtr, void *pointerValue, int classId=0);

最佳答案

如果我们想生成一个字符串ID,我们可以只发送字符串的地址。然后 bloomberg data feed 会发回地址,类型为 void *。所以我们只需要将它转换成char *即可。下面是一个例子:

// sending
const char * id = "abc";
session->sendRequest(*request, CorrelationId(const_cast<char *>(id))); // it can't take "const char *"

// handling response
cout << (char *)message.correlationId().asPointer(); // it will show "abc".

关于时间:2019-03-08 标签:c++bloombergapicorrelationId,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32422429/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com