Panagiotis Christopoulos Charitos před 15 roky
rodič
revize
96347a0ad8
2 změnil soubory, kde provedl 104 přidání a 3 odebrání
  1. 1 3
      src/Resources/Model.cpp
  2. 103 0
      src/Util/BldfTree.h

+ 1 - 3
src/Resources/Model.cpp

@@ -163,9 +163,7 @@ void Model::load(const char* filename)
 //======================================================================================================================
 void Model::parseSubModel(Scanner& scanner)
 {
-	const Scanner::Token* token = &scanner.getCrntToken();
-
-	scanner.getNextToken();
+	const Scanner::Token* token = &scanner.getNextToken();
 
 	if(token->getCode() != Scanner::TC_LBRACKET)
 	{

+ 103 - 0
src/Util/BldfTree.h

@@ -0,0 +1,103 @@
+#ifndef BLDF_TREE_H
+#define BLDF_TREE_H
+
+#include "Properties.h"
+#include "Vec.h"
+
+
+namespace Bldf {
+
+
+/// Entity as a base class
+class Entity
+{
+	public:
+		enum EntityType
+		{
+			ET_KEY,
+			ET_VALUE
+		};
+
+	PROPERTY_R(int, line, getLine)
+	PROPERTY_R(EntityType, type, getType)
+
+	public:
+		Entity(int line, EntityType type);
+};
+
+
+inline Entity::Entity(int line_, EntityType type_):
+	line(line_),
+	type(type_)
+{}
+
+
+/// Value
+class Value: public Entity
+{
+	public:
+		/// The type of the value
+		enum ValueType
+		{
+			VT_STRING,
+			VT_NUMBER,
+			VT_BOOL
+		};
+
+	PROPERTY_R(ValueType, type, getType) ///< Type
+
+	public:
+		Value(int line, const char* str);
+		Value(int line, double num);
+		Value(int line, bool b);
+
+	private:
+		std::string str;
+		double num;
+		bool b;
+};
+
+
+inline Value::Value(int line, const char* str_):
+	Entity(line, ET_VALUE),
+	type(VT_STRING),
+	str(str_)
+{}
+
+
+inline Value::Value(int line, double num_):
+	Entity(line, ET_VALUE),
+	type(VT_NUMBER),
+	num(num_)
+{}
+
+
+inline Value::Value(int line, bool b_):
+	Entity(line, ET_VALUE),
+	type(VT_BOOL),
+	b(b_)
+{}
+
+
+///
+class Key: public Element
+{
+	PROPERTY_R(std::string, name, getName)
+	PROPERTY_R(Vec<Key>, keys, getKeys)
+	PROPERTY_R(Vec<Value>, values, getValues)
+
+	public:
+		Key(int line): Element(line, ET_KEY) {}
+};
+
+
+/// Bracket loving data file (aka BLDF) tree structure with parser
+class Tree
+{
+
+};
+
+
+} // end namespace Bldf
+
+#endif