parcel | Clownfish |
class variable | CFISH_BYTEBUF |
struct symbol | cfish_ByteBuf |
class nickname | cfish_BB |
header file | Clownfish/ByteBuf.h |
Clownfish::ByteBuf – Growable buffer holding arbitrary bytes.
cfish_ByteBuf* // incremented
cfish_BB_new(
size_t capacity
);
Return a new zero-sized ByteBuf.
Initial minimum capacity of the ByteBuf, in bytes.
cfish_ByteBuf*
cfish_BB_init(
cfish_ByteBuf *self,
size_t capacity
);
Initialize a ByteBuf.
Initial minimum capacity of the ByteBuf, in bytes.
cfish_ByteBuf* // incremented
cfish_BB_new_bytes(
void *bytes,
size_t size
);
Return a new ByteBuf which holds a copy of the passed-in bytes.
Pointer to an array of bytes.
Size of the array in bytes.
cfish_ByteBuf*
cfish_BB_init_bytes(
cfish_ByteBuf *self,
void *bytes,
size_t size
);
Initialize a ByteBuf which holds a copy of the passed-in bytes.
Pointer to an array of bytes.
Size of the array in bytes.
cfish_ByteBuf* // incremented
cfish_BB_new_steal_bytes(
void *bytes,
size_t size,
size_t capacity
);
Return a new ByteBuf which assumes ownership of the passed-in string.
Pointer to an array of bytes.
Initial size of the ByteBuf in bytes.
Total allocated bytes in the array.
cfish_ByteBuf*
cfish_BB_init_steal_bytes(
cfish_ByteBuf *self,
void *bytes,
size_t size,
size_t capacity
);
Initialize a ByteBuf and assume ownership of the passed-in string.
Pointer to an array of bytes.
Initial size of the ByteBuf in bytes.
Total allocated bytes in the array.
void
cfish_BB_Set_Size(
cfish_ByteBuf *self,
size_t size
);
Resize the ByteBuf to size
. If greater than the object’s capacity,
throws an error.
size_t
cfish_BB_Get_Size(
cfish_ByteBuf *self
);
Return the size of the ByteBuf in bytes.
char*
cfish_BB_Get_Buf(
cfish_ByteBuf *self
);
Accessor for raw internal buffer.
size_t
cfish_BB_Get_Capacity(
cfish_ByteBuf *self
);
Return the number of bytes in the ByteBuf’s allocation.
void
cfish_BB_Cat_Bytes(
cfish_ByteBuf *self,
void *bytes,
size_t size
);
Concatenate the passed-in bytes onto the end of the ByteBuf. Allocate more memory as needed.
Pointer to an array of bytes.
Size of the array in bytes.
void
cfish_BB_Cat(
cfish_ByteBuf *self,
cfish_Blob *blob
);
Concatenate the contents of Blob blob
onto the end of the
original ByteBuf. Allocate more memory as needed.
char*
cfish_BB_Grow(
cfish_ByteBuf *self,
size_t capacity
);
Assign more memory to the ByteBuf, if it doesn’t already have enough
room to hold capacity
bytes. Cannot shrink the allocation.
The new minimum capacity of the ByteBuf.
Returns: a pointer to the raw buffer.
cfish_Blob* // incremented
cfish_BB_Yield_Blob(
cfish_ByteBuf *self
);
Return the content of the ByteBuf as Blob and clear the ByteBuf.
cfish_String* // incremented
cfish_BB_Utf8_To_String(
cfish_ByteBuf *self
);
Return a String which holds a copy of the UTF-8 character data in the ByteBuf after checking for validity.
cfish_String* // incremented
cfish_BB_Trusted_Utf8_To_String(
cfish_ByteBuf *self
);
Return a String which holds a copy of the UTF-8 character data in the ByteBuf, skipping validity checks.
bool
cfish_BB_Equals(
cfish_ByteBuf *self,
cfish_Obj *other
);
Equality test.
Returns: true if other
is a ByteBuf with the same content as self
.
bool
cfish_BB_Equals_Bytes(
cfish_ByteBuf *self,
void *bytes,
size_t size
);
Test whether the ByteBuf matches the passed-in bytes.
Pointer to an array of bytes.
Size of the array in bytes.
int32_t
cfish_BB_Compare_To(
cfish_ByteBuf *self,
cfish_Obj *other
);
Indicate whether one ByteBuf is less than, equal to, or greater than
another. The byte contents of the ByteBufs are compared
lexicographically. Throws an exception if other
is not a ByteBuf.
Returns: 0 if the ByteBufs are equal, a negative number if self
is
less than other
, and a positive number if self
is greater than
other
.
cfish_ByteBuf* // incremented
cfish_BB_Clone(
cfish_ByteBuf *self
);
Return a clone of the object.
Clownfish::ByteBuf is a Clownfish::Obj.
Copyright © 2010-2015 The Apache Software Foundation, Licensed under the
Apache License, Version 2.0.
Apache Lucy, Lucy, Apache, the Apache feather logo, and the Apache Lucy project logo are trademarks of The
Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their
respective owners.