Preliminary setup - basic data structures are there.

This commit is contained in:
Jesse Beder 2008-06-25 23:00:18 +00:00
parent e22eea26b1
commit 4ed7f62431
12 changed files with 186 additions and 4 deletions

12
content.cpp Normal file
View file

@ -0,0 +1,12 @@
#include "content.h"
namespace YAML
{
Content::Content()
{
}
Content::~Content()
{
}
}

13
content.h Normal file
View file

@ -0,0 +1,13 @@
#pragma once
namespace YAML
{
class Content
{
public:
Content();
virtual ~Content();
protected:
};
}

View file

@ -1,5 +1,6 @@
#include "document.h"
#include "node.h"
#include <fstream>
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);
}
}

17
map.cpp Normal file
View file

@ -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;
}
}
}

20
map.h Normal file
View file

@ -0,0 +1,20 @@
#pragma once
#include "content.h"
#include <map>
namespace YAML
{
class Node;
class Map: public Content
{
public:
Map();
virtual ~Map();
protected:
typedef std::map <Node *, Node *> node_map;
node_map m_data;
};
}

View file

@ -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)
{
}
}

13
node.h
View file

@ -1,12 +1,15 @@
#pragma once
#include <string>
#include <ios>
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;
};
}

12
scalar.cpp Normal file
View file

@ -0,0 +1,12 @@
#include "scalar.h"
namespace YAML
{
Scalar::Scalar()
{
}
Scalar::~Scalar()
{
}
}

17
scalar.h Normal file
View file

@ -0,0 +1,17 @@
#pragma once
#include "content.h"
#include <string>
namespace YAML
{
class Scalar: public Content
{
public:
Scalar();
virtual ~Scalar();
protected:
std::string m_data;
};
}

15
sequence.cpp Normal file
View file

@ -0,0 +1,15 @@
#include "sequence.h"
#include "node.h"
namespace YAML
{
Sequence::Sequence()
{
}
Sequence::~Sequence()
{
for(unsigned i=0;i<m_data.size();i++)
delete m_data[i];
}
}

19
sequence.h Normal file
View file

@ -0,0 +1,19 @@
#pragma once
#include "content.h"
#include <vector>
namespace YAML
{
class Node;
class Sequence: public Content
{
public:
Sequence();
virtual ~Sequence();
protected:
std::vector <Node *> m_data;
};
}

View file

@ -161,6 +161,10 @@
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\content.cpp"
>
</File>
<File
RelativePath=".\document.cpp"
>
@ -169,24 +173,52 @@
RelativePath=".\main.cpp"
>
</File>
<File
RelativePath=".\map.cpp"
>
</File>
<File
RelativePath=".\node.cpp"
>
</File>
<File
RelativePath=".\scalar.cpp"
>
</File>
<File
RelativePath=".\sequence.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\content.h"
>
</File>
<File
RelativePath=".\document.h"
>
</File>
<File
RelativePath=".\map.h"
>
</File>
<File
RelativePath=".\node.h"
>
</File>
<File
RelativePath=".\scalar.h"
>
</File>
<File
RelativePath=".\sequence.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"