17 #ifndef CARTOGRAPHER_COMMON_PORT_H_ 18 #define CARTOGRAPHER_COMMON_PORT_H_ 24 #include <boost/iostreams/device/back_inserter.hpp> 25 #include <boost/iostreams/filter/gzip.hpp> 26 #include <boost/iostreams/filtering_stream.hpp> 41 inline int RoundToInt(
const float x) {
return std::lround(x); }
43 inline int RoundToInt(
const double x) {
return std::lround(x); }
50 std::string* compressed) {
51 boost::iostreams::filtering_ostream out;
53 boost::iostreams::gzip_compressor(boost::iostreams::zlib::best_speed));
54 out.push(boost::iostreams::back_inserter(*compressed));
55 boost::iostreams::write(out,
56 reinterpret_cast<const char*>(uncompressed.data()),
61 std::string* decompressed) {
62 boost::iostreams::filtering_ostream out;
63 out.push(boost::iostreams::gzip_decompressor());
64 out.push(boost::iostreams::back_inserter(*decompressed));
65 boost::iostreams::write(out, reinterpret_cast<const char*>(compressed.data()),
72 #endif // CARTOGRAPHER_COMMON_PORT_H_
int RoundToInt(const float x)
void FastGunzipString(const std::string &compressed, std::string *decompressed)
void FastGzipString(const std::string &uncompressed, std::string *compressed)
int64 RoundToInt64(const float x)