Last active
December 10, 2015 17:28
-
-
Save takumn/4467923 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
... | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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