Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef CARTOGRAPHER_COMMON_PORT_H_
00018 #define CARTOGRAPHER_COMMON_PORT_H_
00019
00020 #include <boost/iostreams/device/back_inserter.hpp>
00021 #include <boost/iostreams/filter/gzip.hpp>
00022 #include <boost/iostreams/filtering_stream.hpp>
00023 #include <cinttypes>
00024 #include <cmath>
00025 #include <string>
00026
00027 namespace cartographer {
00028
00029 using int8 = int8_t;
00030 using int16 = int16_t;
00031 using int32 = int32_t;
00032 using int64 = int64_t;
00033 using uint8 = uint8_t;
00034 using uint16 = uint16_t;
00035 using uint32 = uint32_t;
00036 using uint64 = uint64_t;
00037
00038 namespace common {
00039
00040 inline int RoundToInt(const float x) { return std::lround(x); }
00041
00042 inline int RoundToInt(const double x) { return std::lround(x); }
00043
00044 inline int64 RoundToInt64(const float x) { return std::lround(x); }
00045
00046 inline int64 RoundToInt64(const double x) { return std::lround(x); }
00047
00048 inline void FastGzipString(const std::string& uncompressed,
00049 std::string* compressed) {
00050 boost::iostreams::filtering_ostream out;
00051 out.push(
00052 boost::iostreams::gzip_compressor(boost::iostreams::zlib::best_speed));
00053 out.push(boost::iostreams::back_inserter(*compressed));
00054 boost::iostreams::write(out,
00055 reinterpret_cast<const char*>(uncompressed.data()),
00056 uncompressed.size());
00057 }
00058
00059 inline void FastGunzipString(const std::string& compressed,
00060 std::string* decompressed) {
00061 boost::iostreams::filtering_ostream out;
00062 out.push(boost::iostreams::gzip_decompressor());
00063 out.push(boost::iostreams::back_inserter(*decompressed));
00064 boost::iostreams::write(out, reinterpret_cast<const char*>(compressed.data()),
00065 compressed.size());
00066 }
00067
00068 }
00069 }
00070
00071 #endif // CARTOGRAPHER_COMMON_PORT_H_