diff --git a/content.cpp b/content.cpp new file mode 100644 index 0000000000..b68bb25dd8 --- /dev/null +++ b/content.cpp @@ -0,0 +1,12 @@ +#include "content.h" + +namespace YAML +{ + Content::Content() + { + } + + Content::~Content() + { + } +} diff --git a/content.h b/content.h new file mode 100644 index 0000000000..d251bb1862 --- /dev/null +++ b/content.h @@ -0,0 +1,13 @@ +#pragma once + +namespace YAML +{ + class Content + { + public: + Content(); + virtual ~Content(); + + protected: + }; +} diff --git a/document.cpp b/document.cpp index a9ff19afdb..750ef65117 100644 --- a/document.cpp +++ b/document.cpp @@ -1,5 +1,6 @@ #include "document.h" #include "node.h" +#include namespace YAML { @@ -25,5 +26,10 @@ namespace YAML void Document::Load(const std::string& fileName) { + Clear(); + + std::ifstream fin(fileName.c_str()); + m_pRoot = new Node; + m_pRoot->Read(fin); } } diff --git a/map.cpp b/map.cpp new file mode 100644 index 0000000000..882ad15012 --- /dev/null +++ b/map.cpp @@ -0,0 +1,17 @@ +#include "map.h" +#include "node.h" + +namespace YAML +{ + Map::Map() + { + } + + Map::~Map() + { + for(node_map::const_iterator it=m_data.begin();it!=m_data.end();++it) { + delete it->first; + delete it->second; + } + } +} diff --git a/map.h b/map.h new file mode 100644 index 0000000000..b165ac5ae1 --- /dev/null +++ b/map.h @@ -0,0 +1,20 @@ +#pragma once + +#include "content.h" +#include + +namespace YAML +{ + class Node; + + class Map: public Content + { + public: + Map(); + virtual ~Map(); + + protected: + typedef std::map node_map; + node_map m_data; + }; +} diff --git a/node.cpp b/node.cpp index 22c1beb656..0da7c2b0ce 100644 --- a/node.cpp +++ b/node.cpp @@ -1,12 +1,24 @@ #include "node.h" +#include "content.h" namespace YAML { - Node::Node() + Node::Node(): m_pContent(0) { } Node::~Node() + { + Clear(); + } + + void Node::Clear() + { + delete m_pContent; + m_pContent = 0; + } + + void Node::Read(std::istream& in) { } } diff --git a/node.h b/node.h index dd4d362349..e1e5d1db75 100644 --- a/node.h +++ b/node.h @@ -1,12 +1,15 @@ #pragma once #include +#include namespace YAML { - const std::string Str = "!!str"; - const std::string Seq = "!!seq"; - const std::string Map = "!!map"; + const std::string StrTag = "!!str"; + const std::string SeqTag = "!!seq"; + const std::string MapTag = "!!map"; + + class Content; class Node { @@ -14,7 +17,11 @@ namespace YAML Node(); ~Node(); + void Clear(); + void Read(std::istream& in); + private: std::string m_tag; + Content *m_pContent; }; } diff --git a/scalar.cpp b/scalar.cpp new file mode 100644 index 0000000000..787e0960a5 --- /dev/null +++ b/scalar.cpp @@ -0,0 +1,12 @@ +#include "scalar.h" + +namespace YAML +{ + Scalar::Scalar() + { + } + + Scalar::~Scalar() + { + } +} diff --git a/scalar.h b/scalar.h new file mode 100644 index 0000000000..5f3e068a16 --- /dev/null +++ b/scalar.h @@ -0,0 +1,17 @@ +#pragma once + +#include "content.h" +#include + +namespace YAML +{ + class Scalar: public Content + { + public: + Scalar(); + virtual ~Scalar(); + + protected: + std::string m_data; + }; +} diff --git a/sequence.cpp b/sequence.cpp new file mode 100644 index 0000000000..ef1d33649a --- /dev/null +++ b/sequence.cpp @@ -0,0 +1,15 @@ +#include "sequence.h" +#include "node.h" + +namespace YAML +{ + Sequence::Sequence() + { + } + + Sequence::~Sequence() + { + for(unsigned i=0;i + +namespace YAML +{ + class Node; + + class Sequence: public Content + { + public: + Sequence(); + virtual ~Sequence(); + + protected: + std::vector m_data; + }; +} diff --git a/yaml-reader.vcproj b/yaml-reader.vcproj index def7c75e49..d5ea568d28 100644 --- a/yaml-reader.vcproj +++ b/yaml-reader.vcproj @@ -161,6 +161,10 @@ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > + + @@ -169,24 +173,52 @@ RelativePath=".\main.cpp" > + + + + + + + + + + + + + +