如何对发起方和接受方的设置进行硬编码,以便不需要外部设置文件?
这就是我到目前为止所尝试的:
FIX::SessionSettings serverSettings;
FIX::Dictionary serverDictionary;
serverDictionary.setString("BeginString", "FIX.4.4");
serverDictionary.setString("UseDataDictionary", "Y");
serverDictionary.setString("DataDictionary", "../../../spec/FIX.4.4.xml");
serverDictionary.setString("SenderCompID", "SRVR");
serverDictionary.setString("TargetCompID", "CLNT");
serverDictionary.setString("SocketAcceptHost", "localhost");
serverDictionary.setLong("SocketAcceptPort", 2024);
FIX::SessionID serverSessionID;
serverSettings.set(serverSessionID, serverDictionary);
Server server; // Extends FIX::Application
FIX::FileStoreFactory serverStoreFactory("server/fileStore/");
FIX::FileLogFactory serverLogFactory("server/logs/");
FIX::SocketAcceptor acceptor(server, serverStoreFactory, serverSettings, serverLogFactory);
我认为我走在正确的道路上,但我得到了这个错误:Configuration failed: BeginString must be FIX.4.0 to FIX.4.4 or FIXT.1.1
有什么想法吗?
发布于 2012-11-20 02:16:42
它与"FIX.4.4“的值无关,它是关于setString
的定义,即;
void Dictionary::setString( const std::string& key,const std::string& value )
它通过引用获取这些字符串,并将其传递给一个临时变量,当setString
尝试访问该值时,该变量会被释放。因为你不能改变你需要做的函数定义;
std::string key = "current key";
std::string value = "current value";
serverDictionary.setString(key, value);
对于所有setString
调用,这样才能正常工作。至少对我来说,这会阻止我走这条路。
发布于 2012-11-21 02:27:32
经过很多努力,我终于把这件事做好了。以下是在接受器中硬编码设置的功能代码,也可以应用于启动器中:
try {
FIX::SessionSettings serverSettings;
FIX::Dictionary serverDictionary;
serverDictionary.setString("ConnectionType", "acceptor");
serverDictionary.setString("DataDictionary", "FIX.4.4.xml");
serverDictionary.setString("StartTime", "00:00:00");
serverDictionary.setString("EndTime", "00:00:00");
serverDictionary.setString("SocketAcceptHost", "localhost");
serverDictionary.setString("SocketAcceptPort", "2024");
FIX::SessionID serverSessionID("FIX.4.4", "SRVR", "CLNT");
serverSettings.set(serverSessionID, serverDictionary);
Server server;
FIX::FileStoreFactory serverStoreFactory("server/fileStore/");
FIX::FileLogFactory serverLogFactory("server/logs/");
FIX::SocketAcceptor acceptor(server, serverStoreFactory, serverSettings, serverLogFactory);
acceptor.start();
// do something
acceptor.stop();
return 0;
} catch (FIX::ConfigError& e) {
std::cout << e.what() << std::endl;
return 1;
}
https://stackoverflow.com/questions/13459627
复制相似问题