Files
spark/src/lib/utils/PBUtils.cpp
T

28 lines
641 B
C++
Executable File

#include "PBUtils.h"
#include <google/protobuf/text_format.h>
#include <google/protobuf/timestamp.pb.h>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/date_time/posix_time/conversion.hpp>
namespace bts {
namespace utils {
namespace pb {
std::string to_string (google::protobuf::Message const &msg)
{
std::string result;
google::protobuf::TextFormat::PrintToString (msg, &result);
return result;
}
google::protobuf::Timestamp to_timestamp(datetime::PTime const &ptime)
{
google::protobuf::Timestamp gts;
gts.set_seconds(boost::posix_time::to_time_t(ptime));
gts.set_nanos(0);
return gts;
}
}}}