content.h 1.29 KB
Newer Older
1
2
#pragma once

3
#include <ios>
4
5
#include <vector>
#include <map>
6
#include "parserstate.h"
7
#include "exceptions.h"
8

9
10
namespace YAML
{
11
	class Scanner;
12
	class Parser;
13
	class Node;
14

15
16
17
18
19
20
	class Content
	{
	public:
		Content();
		virtual ~Content();

21
		virtual void Parse(Scanner *pScanner, const ParserState& state) = 0;
22
23
		virtual void Write(std::ostream& out, int indent) = 0;

24
25
26
27
28
29
		virtual bool GetBegin(std::vector <Node *>::const_iterator& it) const { return false; }
		virtual bool GetBegin(std::map <Node *, Node *>::const_iterator& it) const { return false; }
		virtual bool GetEnd(std::vector <Node *>::const_iterator& it) const { return false; }
		virtual bool GetEnd(std::map <Node *, Node *>::const_iterator& it) const { return false; }
		virtual Node *GetNode(unsigned i) const { return 0; }
		virtual unsigned GetSize() const { return 0; }
30
31
32
33
34
35
36
37
38
39

		// extraction
		virtual void Read(std::string& s) { throw InvalidScalar(); }
		virtual void Read(int& i) { throw InvalidScalar(); }
		virtual void Read(unsigned& u) { throw InvalidScalar(); }
		virtual void Read(long& l) { throw InvalidScalar(); }
		virtual void Read(float& f) { throw InvalidScalar(); }
		virtual void Read(double& d) { throw InvalidScalar(); }
		virtual void Read(char& c) { throw InvalidScalar(); }

40
41
42
	protected:
	};
}