mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Switched to reading the entire file into a buffer at the start.\nThis speeds it up a TON (like 100x).
This commit is contained in:
@@ -7,20 +7,13 @@
|
||||
void run()
|
||||
{
|
||||
std::ifstream fin("tests/test.yaml");
|
||||
YAML::Parser parser(fin);
|
||||
|
||||
try {
|
||||
YAML::Parser parser(fin);
|
||||
while(parser)
|
||||
{
|
||||
YAML::Node doc;
|
||||
parser.GetNextDocument(doc);
|
||||
|
||||
std::cout << "name: " << doc["name"] << "\n";
|
||||
std::cout << "age: " << doc["age"] << "\n";
|
||||
} catch(YAML::TypedKeyNotFound <std::string>& e) {
|
||||
std::cout << "Key '" << e.key << "' not found at line " << e.line+1 << ", col " << e.column+1 << "\n";
|
||||
} catch(YAML::KeyNotFound& e) {
|
||||
std::cout << "Key not found at line " << e.line+1 << ", col " << e.column+1 << "\n";
|
||||
} catch(YAML::Exception& e) {
|
||||
std::cout << "Error at line " << e.line+1 << ", col " << e.column+1 << ": " << e.msg << "\n";
|
||||
std::cout << doc;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,3 +1 @@
|
||||
name: Brett Favre
|
||||
position: QB
|
||||
teams: [ Falcons, Packers, Jets ]
|
||||
- test
|
||||
|
Reference in New Issue
Block a user