2008-06-25 22:45:08 +00:00
|
|
|
#include "document.h"
|
|
|
|
|
#include "node.h"
|
2008-06-26 06:49:50 +00:00
|
|
|
#include "parser.h"
|
2008-06-26 09:05:28 +00:00
|
|
|
#include "scanner.h"
|
2008-06-26 19:30:11 +00:00
|
|
|
#include "exceptions.h"
|
2008-06-25 23:00:18 +00:00
|
|
|
#include <fstream>
|
2008-06-25 22:45:08 +00:00
|
|
|
|
|
|
|
|
namespace YAML
|
|
|
|
|
{
|
|
|
|
|
Document::Document(): m_pRoot(0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Document::Document(const std::string& fileName): m_pRoot(0)
|
|
|
|
|
{
|
|
|
|
|
Load(fileName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Document::~Document()
|
|
|
|
|
{
|
|
|
|
|
Clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Document::Clear()
|
|
|
|
|
{
|
|
|
|
|
delete m_pRoot;
|
|
|
|
|
m_pRoot = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Document::Load(const std::string& fileName)
|
|
|
|
|
{
|
2008-06-25 23:00:18 +00:00
|
|
|
Clear();
|
|
|
|
|
|
|
|
|
|
std::ifstream fin(fileName.c_str());
|
2008-06-26 09:05:28 +00:00
|
|
|
Scanner scanner(fin);
|
2008-06-26 19:30:11 +00:00
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
scanner.Scan();
|
2008-06-26 22:00:39 +00:00
|
|
|
} catch(const Exception& e) {
|
2008-06-26 19:30:11 +00:00
|
|
|
}
|
2008-06-26 22:00:39 +00:00
|
|
|
getchar();
|
2008-06-26 09:05:28 +00:00
|
|
|
// if(!scanner)
|
|
|
|
|
// return;
|
2008-06-26 06:49:50 +00:00
|
|
|
|
2008-06-26 09:05:28 +00:00
|
|
|
// m_pRoot = parser.ReadNextNode();
|
2008-06-25 22:45:08 +00:00
|
|
|
}
|
|
|
|
|
}
|