2020-01-24 18:56:51 +00:00
|
|
|
/*
|
|
|
|
Header BitStream
|
|
|
|
|
|
|
|
Copyright (C) 2019 AleaJactaEst
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifndef BIT_STREAM_H
|
|
|
|
#define BIT_STREAM_H
|
|
|
|
|
|
|
|
#include "core/reference.h"
|
|
|
|
|
|
|
|
class BitStream : public Reference {
|
|
|
|
GDCLASS(BitStream, Reference)
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
private:
|
|
|
|
uint32_t _pos;
|
|
|
|
uint32_t _read;
|
|
|
|
PoolByteArray _data;
|
|
|
|
public:
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
BitStream();
|
|
|
|
~BitStream();
|
|
|
|
|
|
|
|
static void init(); // our initializer called by Godot
|
|
|
|
|
|
|
|
bool is_little_endian();
|
|
|
|
|
|
|
|
int size();
|
|
|
|
int size_data();
|
|
|
|
|
|
|
|
void put_serial(uint32_t value, uint32_t nbits);
|
|
|
|
void put_bool(bool value);
|
|
|
|
void put_sint8(int8_t value);
|
|
|
|
void put_uint8(uint8_t value);
|
|
|
|
void put_sint16(int16_t value);
|
|
|
|
void put_uint16(uint16_t value);
|
|
|
|
void put_sint32(int32_t value);
|
|
|
|
void put_uint32(uint32_t value);
|
|
|
|
void put_sint64(int64_t value);
|
|
|
|
void put_uint64(uint64_t value);
|
|
|
|
void put_string_hexa32(String hexa);
|
|
|
|
void put_char(String value);
|
|
|
|
void put_string(String value);
|
|
|
|
void put_array_uint8(PoolByteArray value);
|
|
|
|
|
|
|
|
String show();
|
|
|
|
String show_detail();
|
|
|
|
String show_counter();
|
|
|
|
|
|
|
|
PoolByteArray get_data();
|
|
|
|
void put_data(PoolByteArray value);
|
2020-03-03 21:45:30 +00:00
|
|
|
|
|
|
|
void put_bitstream(Ref<BitStream> value);
|
2020-01-24 18:56:51 +00:00
|
|
|
|
|
|
|
uint32_t get_serial(uint32_t nbits);
|
|
|
|
bool get_bool();
|
|
|
|
int8_t get_sint8();
|
|
|
|
uint8_t get_uint8();
|
|
|
|
int16_t get_sint16();
|
|
|
|
uint16_t get_uint16();
|
|
|
|
int32_t get_sint32();
|
|
|
|
uint32_t get_uint32();
|
|
|
|
int64_t get_sint64();
|
|
|
|
uint64_t get_uint64();
|
|
|
|
PoolByteArray get_array_uint8(uint32_t length);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|