LCOV - code coverage report
Current view: top level - app/src/utils - serialize.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 38 0.0 %
Date: 2023-08-17 16:45:52 Functions: 0 12 0.0 %

          Line data    Source code
       1             : #include "utils/serialize.hpp"
       2             : 
       3             : using namespace std;
       4             : using namespace utils::serialize;
       5             : 
       6           0 : serialize<string>::serialize(const string &obj):
       7           0 :     t(obj) {}
       8             : 
       9           0 : ostream &std::operator<<(ostream &os, const serialize<string> &s) {
      10           0 :     size_t sz = s.t.size();
      11           0 :     os.write(reinterpret_cast<const char *>(&sz), sizeof(sz));
      12           0 :     os.write(s.t.data(), sz);
      13           0 :     return os;
      14             : }
      15             : 
      16           0 : deserialize<string>::deserialize(string &obj):
      17           0 :     t(obj) {}
      18             : 
      19           0 : istream &std::operator>>(istream &is, deserialize<string> s) {
      20           0 :     size_t sz = 0;
      21           0 :     is.read(reinterpret_cast<char *>(&sz), sizeof(sz));
      22             : 
      23           0 :     char *buf = new char[sz + 1];
      24           0 :     is.read(buf, sz);
      25           0 :     buf[sz] = '\0';
      26             : 
      27           0 :     s.t = string(buf);
      28             : 
      29           0 :     delete buf;
      30           0 :     return is;
      31             : }
      32             : 
      33           0 : serialize<bool>::serialize(bool obj):
      34           0 :     t(obj) {}
      35             : 
      36           0 : ostream &std::operator<<(ostream &os, const serialize<bool> &s) {
      37           0 :     os.write(reinterpret_cast<const char *>(&s.t), sizeof(s.t));
      38           0 :     return os;
      39             : }
      40             : 
      41           0 : deserialize<bool>::deserialize(bool &obj):
      42           0 :     t(obj) {}
      43             : 
      44           0 : istream &std::operator>>(istream &is, deserialize<bool> s) {
      45           0 :     is.read(reinterpret_cast<char *>(&s.t), sizeof(s.t));
      46           0 :     return is;
      47             : }
      48             : 
      49           0 : serialize<int>::serialize(int obj):
      50           0 :     t(obj) {}
      51             : 
      52           0 : ostream &std::operator<<(ostream &os, const serialize<int> &s) {
      53           0 :     os.write(reinterpret_cast<const char *>(&s.t), sizeof(s.t));
      54           0 :     return os;
      55             : }
      56             : 
      57           0 : deserialize<int>::deserialize(int &obj):
      58           0 :     t(obj) {}
      59             : 
      60           0 : istream &std::operator>>(istream &is, deserialize<int> s) {
      61           0 :     is.read(reinterpret_cast<char *>(&s.t), sizeof(s.t));
      62           0 :     return is;
      63             : }

Generated by: LCOV version 1.14