Pioneer
Loading...
Searching...
No Matches
Parser.h
Go to the documentation of this file.
1// Copyright © 2008-2023 Pioneer Developers. See AUTHORS.txt for details
2// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
3
4#ifndef _SCENEGRAPH_PARSER_H_
5#define _SCENEGRAPH_PARSER_H_
6/*
7 * Newmodel .model config file parser.
8 * It's pretty bad, someone please redesign.
9 */
10#include "FileSystem.h"
11#include "Loader.h"
12#include <stdexcept>
13
14namespace SceneGraph {
15
16 struct ParseError : public std::runtime_error {
17 ParseError(const std::string &str) :
18 std::runtime_error(str.c_str()) {}
19 };
20
21 class Parser {
22 public:
23 Parser(FileSystem::FileSource &, const std::string &filename, const std::string &path);
24
25 void Parse(ModelDefinition *m);
26
27 private:
28 bool m_isMaterial;
29 MaterialDefinition *m_curMat;
30 ModelDefinition *m_model;
32 std::string m_path;
33
34 bool checkColor(std::stringstream &ss, Color &color);
35 bool checkString(std::stringstream &ss, std::string &out, const std::string &what);
36 bool checkTexture(std::stringstream &ss, std::string &out);
37 bool isComment(const std::string &s);
38 bool match(const std::string &s, const std::string &what);
39 bool parseLine(const std::string &line);
40 inline bool checkMaterialName(std::stringstream &ss, std::string &out);
41 inline bool checkMesh(std::stringstream &ss, std::string &out);
42 void endMaterial();
43 };
44
45} // namespace SceneGraph
46
47#endif
Definition FileSystem.h:197
Definition RefCounted.h:36
Definition Parser.h:21
void Parse(ModelDefinition *m)
Definition Parser.cpp:28
Definition CityOnPlanet.h:31
Definition Color.h:66
Definition LoaderDefinitions.h:12
Definition LoaderDefinitions.h:68
Definition Parser.h:16
ParseError(const std::string &str)
Definition Parser.h:17