2021-05-14 11:47:54 -04:00
|
|
|
#pragma once
|
2021-12-17 01:05:38 -05:00
|
|
|
#include <vector>
|
|
|
|
#include <variant>
|
2021-05-14 11:47:54 -04:00
|
|
|
#include <string>
|
2022-08-21 16:24:13 -04:00
|
|
|
#include <utility>
|
2021-12-17 01:05:38 -05:00
|
|
|
#include "Common.h"
|
2021-05-14 16:51:04 -04:00
|
|
|
|
2022-08-21 16:24:13 -04:00
|
|
|
|
2021-12-17 01:05:38 -05:00
|
|
|
namespace NVL::Parse {
|
|
|
|
enum class Type { Symbol, Number, String, Array, Subexpression };
|
|
|
|
|
2022-08-18 12:17:43 -04:00
|
|
|
class Object {
|
2021-12-17 01:05:38 -05:00
|
|
|
public:
|
2022-08-18 12:17:43 -04:00
|
|
|
Object() = delete;
|
|
|
|
Object(const Number& v);
|
2022-08-20 22:12:11 -04:00
|
|
|
Object(Type t, const String& v);
|
2022-08-18 12:17:43 -04:00
|
|
|
Object(Type t, const std::vector<Object>& v);
|
|
|
|
Object(Number&& v);
|
2022-08-20 22:12:11 -04:00
|
|
|
Object(Type t, String&& v);
|
2022-08-18 12:17:43 -04:00
|
|
|
Object(Type t, std::vector<Object>&& v);
|
2021-12-17 01:05:38 -05:00
|
|
|
Type type;
|
|
|
|
std::variant<
|
|
|
|
Number,
|
2022-08-20 22:12:11 -04:00
|
|
|
String,
|
2021-12-17 01:05:38 -05:00
|
|
|
std::vector<Object>
|
|
|
|
> value;
|
|
|
|
};
|
|
|
|
|
|
|
|
using Command = std::vector<Object>;
|
|
|
|
|
|
|
|
class Scene {
|
2022-08-20 22:12:11 -04:00
|
|
|
String name;
|
2021-12-17 01:05:38 -05:00
|
|
|
std::vector<Command> commands{};
|
|
|
|
public:
|
2022-08-20 22:12:11 -04:00
|
|
|
Scene(const String& name) : name(name) {}
|
2021-12-17 01:05:38 -05:00
|
|
|
void append(const Command& c) {
|
|
|
|
commands.push_back(c);
|
|
|
|
}
|
|
|
|
void append(Command&& c) {
|
|
|
|
commands.push_back(std::move(c));
|
|
|
|
}
|
|
|
|
const auto& get() const {
|
|
|
|
return commands;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<Scene> ParseFile(const std::string& path);
|
2021-12-13 14:04:12 -05:00
|
|
|
}
|