/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
#ifndef LOADSCENE_H
#define LOADSCENE_H

#include <string>
#include <vector>
#include <boost/foreach.hpp>
#include <boost/property_tree/json_parser.hpp>

#include "Common.h"

using namespace glTF;

class Parser
{
public:
    glTFHandle* getFileNameInJson(const std::string& jsonFile);
    bool releaseFileName();
	bool parseScene(class Scene* pscene);
	bool parseJsonFile();
    void setJsonInfo(const std::string& sbuffer);
    void setJsonInfo(std::string direct, std::string fileName);
    Parser();
	~Parser();
private:
	bool readBuffers();
	bool parseNodes();	
	bool parseMeshs();
	bool parseMaterials();	
	bool parseCameras();
	bool parseLights();
	bool parseAttributes();
	bool parseTechniques();

	bool parsePrimitive(boost::property_tree::ptree& pTree, class Mesh* pMesh);
	bool parseMaterialProper(boost::property_tree::ptree& pTree,
							class Material* pMaterial, std::string& techniqueId);
	bool parseNode(std::string& id, class Node* pParentNode, glm::mat4* pmatrix);
	bool parseTechniqueProgram(boost::property_tree::ptree& pInstanceTree, 
							boost::property_tree::ptree& pParameterTree, 
							class Technique* pTechnique);

    bool parseTechniqueState(boost::property_tree::ptree& pInstanceTree,
                            class Technique* pTechnique);


	boost::property_tree::ptree ptParse;
	class Scene* pScene;
	std::string json_file;
	std::string json_directory;
    std::string json_buffer;
    bool is_json_in_buffer;
};

#endif