Skip to content

Instantly share code, notes, and snippets.

@zhangce
Created September 26, 2014 02:51
Show Gist options
  • Select an option

  • Save zhangce/b3e3c9b3039882b1e51a to your computer and use it in GitHub Desktop.

Select an option

Save zhangce/b3e3c9b3039882b1e51a to your computer and use it in GitHub Desktop.
bool Deserialize(int fd) {
int flag;
int length;
ReadN(fd, (char*) &flag, sizeof(flag));
contains_value_ = flag;
ReadN(fd, (char*) &length, sizeof(length));
ReadN(fd, (char*) buf, length);
key_ = std::string(buf);
ReadN(fd, (char*) &length, sizeof(length));
ReadN(fd, (char*) buf, length);
value_ = std::string(buf);
/*
if (ReadN(fd, (char*) &contains_value_, sizeof(contains_value_)) <= 0)
return false;
if (!ReadString(fd, &key_))
return false;
if (contains_value_ && !ReadString(fd, &value_))
return false;
*/
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment