1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/********************************************************************
*
*	File:		gfCCatalogueParserYaml.h
*
*	Purpose:	Parse the catalogue data file
*
*********************************************************************/

#ifndef gfCCatalogueParserYamlhdr
#define gfCCatalogueParserYamlhdr

#include <map>
#include "../gfICatalogueParser.h"

class gfICatalogueEntry;
class gfCCatalogueCatalogue;
class fsCVariableTable;

namespace YAML{
	class Node;
};

class gfCCatalogueParserYaml : public gfICatalogueParser
{
public:

	gfCCatalogueCatalogue* const catalogueLoad(const fsStr& pFileName) override;

	gfCCatalogueParserYaml();
	virtual ~gfCCatalogueParserYaml();<--- Destructor in derived class

protected:


	void categoryLoad(gfCCatalogueCatalogue* pCatalogue, const fsStr& pParentCategory, const fsStr& pFileName);

private:

	struct SSettings
	{
		fsStr mIconFileBase;
		fsStr mImageFileBase;
		fsStr mDefaultAction;
		fsStr mDefaultType;
	};

	void entriesCreate(gfCCatalogueCatalogue* pCatalogue, const fsStr& pParentCategory,
	                   fsCVariableTable* pVarTable, const SSettings& pSettings);
	static fsBool itemCreate(gfCCatalogueCatalogue* pCatalogue, const fsStr& pParentCategory,
	                         fsCVariableTable* pVarTable, const SSettings& pSettings, fsS32 pIndex);
	static void graphicFileBasesGet(fsCVariableTable* pVarTable, SSettings& pSettings);
	static fsStr extensionAdd(const fsStr& pFilename);

	std::map<std::string, std::string> flatten(const YAML::Node& node);
};

#endif