Class: SFML::Buffer
- Inherits:
-
Object
- Object
- SFML::Buffer
- Defined in:
- ext/system/buffer.c,
ext/system/buffer.c
Overview
A raw byte buffer, as used for encoded/decoded audio and image data elsewhere in the library.
Instance Method Summary collapse
-
#data ⇒ String
Returns the raw bytes held by the buffer.
-
#empty? ⇒ Boolean
Returns
trueif the buffer holds no bytes. -
#new ⇒ Buffer
constructor
Creates a new, empty byte buffer.
-
#size ⇒ Integer
Returns the size of the buffer in bytes.
-
#size ⇒ Integer
Returns the size of the buffer in bytes.
-
#data ⇒ String
Returns the raw bytes held by the buffer.
Constructor Details
#new ⇒ Buffer
Creates a new, empty byte buffer.
41 42 43 |
# File 'ext/system/buffer.c', line 41 static VALUE Buffer_initialize(VALUE self) { return self; } |
Instance Method Details
#data ⇒ String
Returns the raw bytes held by the buffer.
61 62 63 64 65 66 67 68 69 70 71 |
# File 'ext/system/buffer.c', line 61
static VALUE Buffer_get_data(VALUE self) {
sfBuffer* buffer = Get_Buffer_Struct(self);
size_t size = sfBuffer_getSize(buffer);
const uint8_t* data = sfBuffer_getData(buffer);
if (data == NULL || size == 0) {
return rb_str_new("", 0);
}
return rb_str_new((const char*)data, (long)size);
}
|
#empty? ⇒ Boolean
Returns true if the buffer holds no bytes.
79 80 81 |
# File 'ext/system/buffer.c', line 79 static VALUE Buffer_is_empty(VALUE self) { return BOOL2RB(sfBuffer_getSize(Get_Buffer_Struct(self)) == 0); } |
#size ⇒ Integer
Returns the size of the buffer in bytes.
51 52 53 |
# File 'ext/system/buffer.c', line 51 static VALUE Buffer_get_size(VALUE self) { return SIZET2NUM(sfBuffer_getSize(Get_Buffer_Struct(self))); } |
#size ⇒ Integer
Returns the size of the buffer in bytes.
51 52 53 |
# File 'ext/system/buffer.c', line 51 static VALUE Buffer_get_size(VALUE self) { return SIZET2NUM(sfBuffer_getSize(Get_Buffer_Struct(self))); } |
#data ⇒ String
Returns the raw bytes held by the buffer.
61 62 63 64 65 66 67 68 69 70 71 |
# File 'ext/system/buffer.c', line 61
static VALUE Buffer_get_data(VALUE self) {
sfBuffer* buffer = Get_Buffer_Struct(self);
size_t size = sfBuffer_getSize(buffer);
const uint8_t* data = sfBuffer_getData(buffer);
if (data == NULL || size == 0) {
return rb_str_new("", 0);
}
return rb_str_new((const char*)data, (long)size);
}
|