Created
November 16, 2019 02:59
-
-
Save vinniefalco/bde6ccdc46d62819109f18ba284aa0f8 to your computer and use it in GitHub Desktop.
This file contains 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
json::value | |
parse_file( char const* filename ) | |
{ | |
json::error_code ec; | |
file f; | |
f.open( filename, "r", ec ); | |
if(ec) | |
throw json::system_error(ec); | |
json::parser p; | |
p.start(); | |
do | |
{ | |
char buf[4096]; | |
auto const nread = f.read( buf, sizeof(buf), ec ); | |
if(! ec) | |
p.write( buf, nread, ec ); | |
if( ec ) | |
throw json::system_error(ec); | |
} | |
while( ! f.eof() ); | |
p.finish(ec); | |
if( ec ) | |
throw json::system_error(ec); | |
return p.release(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment