34 lines
780 B
C++
34 lines
780 B
C++
#include "Security.h"
|
|
#include "lib/domain_model/Security.pb.h"
|
|
|
|
#include <google/protobuf/text_format.h>
|
|
|
|
namespace bts {
|
|
namespace securities {
|
|
|
|
std::string to_str (api::Security const&sec)
|
|
{
|
|
std::string serialized;
|
|
google::protobuf::TextFormat::PrintToString (sec, &serialized);
|
|
return serialized;
|
|
}
|
|
|
|
std::pair<bool, api::Security> from_str(std::string const&str)
|
|
{
|
|
api::Security result;
|
|
auto success = google::protobuf::TextFormat::ParseFromString (str,&result);
|
|
return std::make_pair(success,result);
|
|
}
|
|
|
|
std::string descriptor(api::Security const&sec)
|
|
{
|
|
if (sec.has_glbx())
|
|
return sec.glbx().security_desc();
|
|
else if (sec.has_ice())
|
|
return sec.ice().security_desc();
|
|
else
|
|
return "No descriptor for non glbx exchange";
|
|
}
|
|
|
|
}}
|