This repository has been archived on 2019-12-07. You can view files and clone it, but cannot push or open issues or pull requests.
2012-10-12 17:04:03 +00:00
|
|
|
/*
|
|
|
|
* Yaml.cpp
|
|
|
|
*
|
|
|
|
* Created on: 06.10.2012
|
|
|
|
* Author: Felix
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Yaml.h"
|
|
|
|
|
2012-10-14 17:15:45 +00:00
|
|
|
#include "../util/Log.h"
|
|
|
|
|
2012-10-12 17:04:03 +00:00
|
|
|
String Yaml::mFolder = "";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a readable object from a YAML file. The path must be relative to the directory
|
|
|
|
* set in setFolder().
|
|
|
|
*/
|
2012-10-14 17:15:45 +00:00
|
|
|
Yaml::Yaml(const String& filename) :
|
2012-12-20 13:59:05 +00:00
|
|
|
mFilename(mFolder+filename),
|
|
|
|
mFile(mFilename) {
|
2012-10-14 17:15:45 +00:00
|
|
|
if (mFile.fail()) {
|
|
|
|
LOG_W("Failed to open YAML file: " << mFolder << filename);
|
|
|
|
}
|
|
|
|
YAML::Parser parser(mFile);
|
2012-10-12 17:04:03 +00:00
|
|
|
parser.GetNextDocument(mNode);
|
|
|
|
}
|
|
|
|
|
2012-10-14 17:15:45 +00:00
|
|
|
Yaml::~Yaml() {
|
|
|
|
mFile.close();
|
|
|
|
}
|
|
|
|
|
2012-12-20 13:59:05 +00:00
|
|
|
/**
|
|
|
|
* Return path and name of the file opened in this object.
|
|
|
|
*/
|
|
|
|
String
|
|
|
|
Yaml::getFilename() const {
|
|
|
|
return mFilename;
|
|
|
|
}
|
|
|
|
|
2012-10-12 17:04:03 +00:00
|
|
|
/**
|
|
|
|
* Sets the folder where YAML files are placed. Is added in front of each file name. Allows
|
|
|
|
* shorter strings as this does not have to be added everywhere.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
Yaml::setFolder(const String& folder) {
|
|
|
|
mFolder = folder;
|
|
|
|
}
|