Overte C++ Documentation
DataViewPrototype.h
1 //
2 // DataViewPrototype.h
3 //
4 //
5 // Created by Clement on 7/8/14.
6 // Copyright 2014 High Fidelity, Inc.
7 // Copyright 2023 Overte e.V.
8 //
9 // Distributed under the Apache License, Version 2.0.
10 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
11 // SPDX-License-Identifier: Apache-2.0
12 //
13 
16 
17 #ifndef hifi_DataViewPrototype_h
18 #define hifi_DataViewPrototype_h
19 
20 #include <QtCore/QObject>
21 
22 #include "V8Types.h"
23 #include "../Scriptable.h"
24 
25 // V8TODO Do not remove yet, this will be useful in later PRs
26 /*/// [V8] The javascript functions associated with a <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView">DataView</a></code> instance prototype
27 class DataViewPrototype : public QObject, public Scriptable {
28  Q_OBJECT
29 public:
30  DataViewPrototype(QObject* parent = NULL);
31 
32 public slots:
33  // Gets the value of the given type at the specified byte offset
34  // from the start of the view. There is no alignment constraint;
35  // multi-byte values may be fetched from any offset.
36  //
37  // For multi-byte values, the optional littleEndian argument
38  // indicates whether a big-endian or little-endian value should be
39  // read. If false or undefined, a big-endian value is read.
40  //
41  // These methods raise an exception if they would read
42  // beyond the end of the view.
43  qint32 getInt8(qint32 byteOffset);
44  quint32 getUint8(qint32 byteOffset);
45  qint32 getInt16(qint32 byteOffset, bool littleEndian = false);
46  quint32 getUint16(qint32 byteOffset, bool littleEndian = false);
47  qint32 getInt32(qint32 byteOffset, bool littleEndian = false);
48  quint32 getUint32(qint32 byteOffset, bool littleEndian = false);
49  V8ScriptValue getFloat32(qint32 byteOffset, bool littleEndian = false);
50  V8ScriptValue getFloat64(qint32 byteOffset, bool littleEndian = false);
51 
52  // Stores a value of the given type at the specified byte offset
53  // from the start of the view. There is no alignment constraint;
54  // multi-byte values may be stored at any offset.
55  //
56  // For multi-byte values, the optional littleEndian argument
57  // indicates whether the value should be stored in big-endian or
58  // little-endian byte order. If false or undefined, the value is
59  // stored in big-endian byte order.
60  //
61  // These methods raise an exception if they would write
62  // beyond the end of the view.
63  void setInt8(qint32 byteOffset, qint32 value);
64  void setUint8(qint32 byteOffset, quint32 value);
65  void setInt16(qint32 byteOffset, qint32 value, bool littleEndian = false);
66  void setUint16(qint32 byteOffset, quint32 value, bool littleEndian = false);
67  void setInt32(qint32 byteOffset, qint32 value, bool littleEndian = false);
68  void setUint32(qint32 byteOffset, quint32 value, bool littleEndian = false);
69  void setFloat32(qint32 byteOffset, float value, bool littleEndian = false);
70  void setFloat64(qint32 byteOffset, double value, bool littleEndian = false);
71 
72 private:
73  QByteArray* thisArrayBuffer() const;
74  bool realOffset(qint32& offset, size_t size) const;
75 };
76 */
77 #endif // hifi_DataViewPrototype_h
78