Euphoria
propertytree.cc
Go to the documentation of this file.
1 #include "core/propertytree.h"
2 
3 #include "assert/assert.h"
4 
5 
6 namespace eu::core
7 {
9 
11 
12  int&
14  {
15  ASSERT(value);
17  return static_cast<IntValue*>(value)->value;
18  }
19 
21 
23 
24  float&
26  {
27  ASSERT(value);
29  return static_cast<FloatValue*>(value)->value;
30  }
31 
33 
35  {}
36 
37  vec3f&
39  {
40  ASSERT(value);
42  return static_cast<Vec3fValue*>(value)->value;
43  }
44 
45 
47 
49 
50  void
51  MapValue::set(const std::string& name, std::shared_ptr<Value> value)
52  {
53  properties[name] = value;
54  }
55 
56  std::shared_ptr<Value>
57  MapValue::get_or_null(const std::string& name)
58  {
59  auto found = properties.find(name);
60  if(found == properties.end())
61  {
62  return nullptr;
63  }
64  else
65  {
66  return found->second;
67  }
68  }
69 }
#define ASSERT(x)
Definition: assert.h:29
static float & get(core::Value *value)
Definition: propertytree.cc:25
static int & get(core::Value *value)
Definition: propertytree.cc:13
std::shared_ptr< Value > get_or_null(const std::string &name)
Definition: propertytree.cc:57
void set(const std::string &name, std::shared_ptr< Value > value)
Definition: propertytree.cc:51
std::map< std::string, std::shared_ptr< Value > > properties
Definition: propertytree.h:61
Vec3fValue(const vec3f &v)
Definition: propertytree.cc:34
static vec3f & get(core::Value *value)
Definition: propertytree.cc:38
Definition: vec3.h:48