Skip to content

Commit

Permalink
Merge branch 'master' into array-of-hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
skystrife committed Sep 10, 2013
2 parents 59e8b82 + 48adccf commit 5063d2b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/cpptoml.h
Original file line number Diff line number Diff line change
Expand Up @@ -802,8 +802,15 @@ class parser {
std::unordered_set<std::string> groups_;
};

/**
* Utility function to parse a file as a TOML file. Returns the root group.
* Throws a toml_parse_exception if the file cannot be opened.
*/
toml_group parse_file( const std::string & filename ) {
std::ifstream file{ filename };
if( !file.is_open() )
throw toml_parse_exception{ filename
+ " could not be opened for parsing" };
parser p{ file };
return p.parse();
}
Expand Down

0 comments on commit 5063d2b

Please sign in to comment.