Skip to content

Instantly share code, notes, and snippets.

@takumn
Last active December 10, 2015 17:28
Show Gist options
  • Save takumn/4467923 to your computer and use it in GitHub Desktop.
Save takumn/4467923 to your computer and use it in GitHub Desktop.
boost::filesystem::ifstream ifs;
boost::filesystem::path filepath(path);
ifs.open(filepath/filename);
std::string line;
std::istream is(&ifs);
while(getline(is, line)) {
msgpack::unpacked msg;
msgpack::unpack(&msg, line.data(), line.size());
msgpack::object obj = msg.get();
msgpack::object_map objmap = obj.via.map;
msgpack::object_kv* p(objmap.ptr);
msgpack::object_kv* const pend(objmap.ptr + objmap.size);
std::string k, v;
for(; p != pend; ++p) {
p->key.convert(&k);
p->val.convert(&v);
...
}
}
File file = new File(filename);
BufferedReader reader = new BufferedReader(new FileReader(file);
MessagePack msgpack = new MessagePack();
Template<Map<Value, Value>> mapTmpl = tMap(TValue, TValue);
String line;
while((line = reader.readLine()) != null) {
InputStream lineInputStream = new ByteArrayInputStream(line.getBytes());
Unpacker unpacker = msgpack.createUnpacker(lineInputStream);
Map<Value, Value> objMap = unpacker.read(mapTmpl);
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment