Rumba C++ SDK
Array.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 #include <iterator>
21 
22  namespace maquina
23  {
25 
26  class MAQUINA_EXPORT Array : public Value
27  {
28  public:
30  Array();
31 
33 
34  Array(const Value &v);
35 
37  size_t size() const;
38 
40  void resize(size_t size);
41 
43  void reserve(size_t size);
44 
46 
47  const Value read(size_t i) const;
48 
50 
51  void write(size_t i, const Value &v);
52 
54 
55  const Value operator[](size_t i) const;
56 
58 
59  bool as_bool( size_t i ) const;
60 
62 
63  int as_int( size_t i ) const;
64 
66 
67  float as_float( size_t i ) const;
68 
70 
71  double as_double( size_t i ) const;
72 
74 
75  const std::string& as_string( size_t i ) const;
76 
78 
79  const Imath::V2d& as_V2d( size_t i ) const;
80 
82 
83  const Imath::V3d& as_V3d( size_t i ) const;
84 
86 
87  const Imath::V4d& as_V4d( size_t i ) const;
88 
90 
91  const Imath::M44d& as_M44d( size_t i ) const;
92 
94 
95  const Imath::Box3f& as_Box3f( size_t i ) const;
96 
98 
99  const Imath::Quatd& as_Quatd( size_t i ) const;
100 
102 
103  const Imath::Color4f& as_Color4f(size_t i ) const;
104 
106 
107  void push_back(const Value &value);
108 
110 
111  Array& operator<<(const Value& value);
112  Array& operator<<(float value);
113  Array& operator<<(int value);
114 
116  {
117  public:
118  using iterator_category = std::forward_iterator_tag;
119  using value_type = const Value;
120  using difference_type = std::ptrdiff_t;
121  using pointer = const Value;
122  using reference = const Value;
123 
124  Iterator( const void* internal ) : _internal{ internal }{}
125  Iterator& operator++();
126  Iterator& operator+(int);
127  reference operator*() const;
128  pointer operator->() const;
129  bool operator==( const Iterator& other ) const { return _internal == other._internal; }
130  bool operator!=( const Iterator& other ) const { return _internal != other._internal; }
131  private:
132  const void* _internal;
133  };
134 
135  Iterator begin() const;
136  Iterator end() const;
137 
139  static const Array default_value;
140 
142  Array(std::shared_ptr<Impl> impl) { _impl=impl; }
143  };
144  }
Definition: ImathBox.h:71
std::ptrdiff_t difference_type
Definition: Array.h:120
std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &os, const StringViewBase< C, STDS > &sv)
Definition: StringView.h:349
Definition: ImathFrame.h:42
bool operator==(const Iterator &other) const
Definition: Array.h:129
Definition: ImathColor.h:120
Definition: ImathFrame.h:43
Quat< T > operator+(const Quat< T > &q1, const Quat< T > &q2)
Definition: ImathQuat.h:918
static const Array default_value
The default value.
Definition: Array.h:139
Definition: ImathVec.h:63
This version of the SDK is unstable, i-e, it may change with no warning.
Definition: AddCurveAction.h:20
bool operator!=(const Iterator &other) const
Definition: Array.h:130
Definition: Array.h:115
An array of values.
Definition: Array.h:26
Definition: ImathQuat.h:71
MAQUINA_EXPORT Node reference(Node &root, const std::wstring &filepath, const std::string &reference_root_name="", const ProgressCallback &progress={})
Reference the content of a file into the project.
#define MAQUINA_EXPORT
Definition: Export.h:31
Definition: ImathVec.h:61
Color4< T > operator*(S a, const Color4< T > &v)
Definition: ImathColor.h:727
Iterator(const void *internal)
Definition: Array.h:124
std::forward_iterator_tag iterator_category
Definition: Array.h:118
Base class of all Rumba values.
Definition: Value.h:34