SPARK-1126. Hopefully finally nailed FIX price encoding.

This commit is contained in:
Pedro Pinto committed 2018-05-23 21:40:21 +00:00
1 parent 68fb8dade4
commit f9c15a4d44
8 files changed
+56 -78

No files matched your search

+28 -40
View File
@@ -3,52 +3,40 @@
#include "lib/utils/bts_chrono.h"
#include "lib/config/config.h"
#include "lib/config/protos/quickbus_cfg.pb.h"
#include "lib/config/protos/Ports.pb.h"
#include "lib/quickbus/quickbus.h"
#include "server/sparkd/http/WebServer.h"
#include "lib/api/public/ServiceContext.h"
#include "lib/api/test/HelloServiceServer.h"
#include "server/sparkd/jetfix/codec/f_toa.h"
#include "server/sparkd/jetfix/codec/i32_toa.h"
#include <double-conversion/double-conversion.h>
#include <iostream>
namespace bts {
namespace cmd {
int QuickTest::execute(std::vector<std::string> const &args) {
using namespace double_conversion;
void hello() {
// Create quickbus and service context
config::QuickbusNodeCfg qb_cfg;
auto& ports = config::get<config::Ports>();
qb_cfg.set_my_port(ports.qbus_port());
qbus::Quickbus quickbus(qb_cfg);
api::ServiceContext sc(&quickbus);
// serve config
http::SparkWebServer webserver(sc, ports.config_port());
// Start a test service
api::test::HelloServiceServer hello_svc(sc);
api::test::ShoutServiceServer shout_svc(sc);
sleep_for(1000000s);
}
int QuickTest::execute(std::vector<std::string> const & args)
{
if (*args.begin() == "hello") {
hello();
static char buffer[102];
static char buffer2[102];
static char buffer3[102];
int flags = DoubleToStringConverter::UNIQUE_ZERO;
static DoubleToStringConverter converter(flags, "Infinity", "NaN", 'e', -6,
21, 0, 0);
auto n = std::stod(args[0], nullptr);
auto p = std::stoi(args[1], nullptr);
{
double_conversion::StringBuilder builder(buffer, sizeof(buffer));
converter.ToPrecision(n, p, &builder);
}
// write your discardable test code here. don't commit anything, it
// will be deleted by the next guy or gall
sleep_for(1000000s);
d_toa(n, buffer2, sizeof(buffer2), p);
d_toa(n, buffer3, sizeof(buffer3));
std::cout << n << " -> " << buffer << " (" << strlen(buffer) << ") "
<< " -> " << buffer2 << " (" << strlen(buffer2) << ") "
<< " -> " << buffer3 << " (" << strlen(buffer3) << ") \n";
return 0;
}
std::string QuickTest::help ()
{return "This is a place holder to make it easy to quickly write discardable test code";}
}}
std::string QuickTest::help() {
return "This is a place holder to make it easy to quickly write discardable "
"test code";
}
}
}