Skip to content

Instantly share code, notes, and snippets.

@RaitoBezarius
Created February 19, 2014 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RaitoBezarius/9095304 to your computer and use it in GitHub Desktop.
Save RaitoBezarius/9095304 to your computer and use it in GitHub Desktop.
C++ unpacker
#include <iostream>
#include <msgpack.hpp>
#include <fstream>
#include <string>
#include <stdexcept>
int main()
{
std::ifstream in("data_python");
std::string file_content;
if (in)
{
while (!in.eof())
{
int len = 64;
char* buffer = new char[len];
in.read(buffer, len);
file_content += buffer;
delete[] buffer;
}
}
else
throw std::runtime_error("failed to open file.");
std::cout << file_content << std::endl;
msgpack::unpacked result;
msgpack::unpack(&result, file_content.data(), file_content.size(), NULL);
std::cout << "unpacked: " << result.get() << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment