Rumba C++ SDK
Dict.h
Go to the documentation of this file.
1 /*
2 
3  *
4  ***
5  *****
6  ********************* Mercenaries Engineering SARL
7  ***************** Copyright (C) 2018
8  *************
9  ********* http://www.mercenaries-engineering.com
10  ***********
11  **** ****
12  ** **
13 
14 */
15 #pragma once
16 
17 #include "Value.h"
18 #include "Impl.h"
19 
20  namespace maquina
21  {
23  class MAQUINA_EXPORT Dict : public Value
24  {
25  public:
26  Dict();
27 
29 
30  Dict(const Value &v);
31 
33  bool has_key(const char *key) const;
34 
36  const Value read(const char *key) const;
37 
39 
40  bool as_bool( const char *key ) const;
41 
47  bool as_bool( const char *key, bool default_value ) const;
48 
50 
51  int as_int( const char *key ) const;
52 
58  int as_int( const char *key, int default_value ) const;
59 
61 
62  float as_float( const char *key ) const;
63 
69  float as_float(const char* key, float default_value) const;
70 
72 
73  double as_double( const char *key ) const;
74 
80  double as_double( const char *key, double default_value ) const;
81 
83 
84  const std::string& as_string( const char *key ) const;
85 
87 
88  Imath::V2f as_V2f( const char *key ) const;
89 
91 
92  Imath::V3f as_V3f( const char *key ) const;
93 
99  Imath::V3f as_V3f( const char *key, const Imath::V3f& default_value ) const;
100 
102 
103  Imath::V4f as_V4f( const char *key ) const;
104 
106 
107  const Imath::V2d& as_V2d( const char *key ) const;
108 
110 
111  const Imath::V3d& as_V3d( const char *key ) const;
112 
118  const Imath::V3d& as_V3d( const char *key, const Imath::V3d& default_value ) const;
119 
121 
122  const Imath::V4d& as_V4d( const char *key ) const;
123 
125 
126  Imath::M44f as_M44f( const char *key ) const;
127 
129 
130  const Imath::M44d& as_M44d( const char *key ) const;
131 
133 
134  const Imath::Box3f& as_Box3f( const char *key ) const;
135 
137 
138  Imath::Quatf as_Quatf( const char *key ) const;
139 
141 
142  const Imath::Quatd& as_Quatd( const char *key ) const;
143 
145 
147  {
148  public:
151  public std::iterator<
152  std::forward_iterator_tag,
153  std::pair<std::string, Value>, std::ptrdiff_t, std::pair<std::string, Value>, std::pair<std::string, Value> >
154  {
155  public:
156  reference operator*() const;
157  bool operator==(const Iterator &other) const;
158  bool operator!=(const Iterator &other) const;
159  Iterator& operator++();
160  Iterator( void *iterator );
161  Iterator( const Iterator &other );
162  ~Iterator();
163  private:
164  void *_internal;
165  };
166 
167  Values( const std::shared_ptr< Impl >& node )
168  : _node{ node }
169  {}
170  Iterator begin();
171  Iterator end();
172  private:
173  std::shared_ptr< Impl > _node;
174  };
175 
176  Values values() const;
177 
180  void insert(const char *key, const Value &value);
181 
183  static const Dict default_value;
184 
186  Dict(std::shared_ptr<Impl> impl) { _impl=impl; }
187  };
188  }
Definition: ImathBox.h:71
MAQUINA_EXPORT Node reference(Node &root, const std::wstring &filepath, const std::string &reference_root_name="")
Reference the content of a file into the project.
Definition: ImathFrame.h:42
Definition: ImathFrame.h:43
Definition: ImathVec.h:63
This version of the SDK is unstable, i-e, it may change with no warning.
Definition: AddCurveAction.h:20
A value accessor.
Definition: Dict.h:146
static const Dict default_value
The default value.
Definition: Dict.h:183
Definition: ImathQuat.h:71
#define MAQUINA_EXPORT
Definition: Export.h:31
bool operator!=(const C *str, const StringViewBase< C, STDS > &sv) noexcept
Definition: StringView.h:305
Definition: ImathVec.h:61
A Plug iterator.
Definition: Dict.h:150
bool operator==(const C *str, const StringViewBase< C, STDS > &sv) noexcept
Definition: StringView.h:273
Color4< T > operator*(S a, const Color4< T > &v)
Definition: ImathColor.h:727
A dictionnary to associate strings to values.
Definition: Dict.h:23
Values(const std::shared_ptr< Impl > &node)
Definition: Dict.h:167
Base class of all Rumba values.
Definition: Value.h:34