#pragma once

/*
	GameEngine and Editor
	by John Ryland
	Copyright (c) 2023
*/

////////////////////////////////////////////////////////////////////////////////////
//	XML Tokenizer

enum XmlTokenType
{
	XT_Text,		//  in "abc<blah>xyz</blah>def" it will match 'abc', 'xyz' and 'def'
	XT_ElementBegin,	//  emitted after parsing:  '<TAG ', returns 'TAG'
	XT_ElementEnd,		//  emitted after parsing:  either  '/>'  or  '</TAG>'
	XT_AttributeName,	//  in <blah attrib="val"> it will match "attrib"
	XT_AttributeValue,	//  in <blah attrib="val"> it will match "\"val\""
	XT_Comment,		//  emitted after parsing:  '<!-- .* -->'
	XT_Unknown
};

struct XmlToken
{
	XmlTokenType    type;
	const char*     buffer;
	size_t          length;
};

typedef void (*XmlTokenConsumer)(const XmlToken& token, void* user);

// Doesn't alloc any memory. Mostly plain 'C' code.
void XmlTokenize(const char *data, size_t size, const XmlTokenConsumer& consume, void* user);

