about summary refs log tree commit diff stats
path: root/src/godot_variant.h
blob: 620e569d8f5428f7bf6cf1d77c678517fc33ba32 (plain) (blame)
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
#ifndef GODOT_VARIANT_H_ED7F2EB6
#define GODOT_VARIANT_H_ED7F2EB6

#include <string>
#include <variant>
#include <vector>

struct GodotVariant {
  using value_type = std::variant<std::monostate, bool, std::vector<std::string>, std::vector<GodotVariant>>;

  value_type value;

  GodotVariant(value_type v) : value(v) {}

  bool AsBool() const { return std::get<bool>(value); }

  const std::vector<std::string>& AsNodePath() const {
    return std::get<std::vector<std::string>>(value);
  }

  const std::vector<GodotVariant>& AsArray() const {
    return std::get<std::vector<GodotVariant>>(value);
  }
};

GodotVariant ParseGodotFile(std::string filename);

#endif /* end of include guard: GODOT_VARIANT_H_ED7F2EB6 */