Home » U++ Library support » U++ Core » StringBuffer size [BUG]
Re: StringBuffer size [BUG] [message #21558 is a reply to message #21557] |
Tue, 26 May 2009 15:04  |
cbpporter
Messages: 1428 Registered: September 2007
|
Ultimate Contributor |
|
|
AFAIK StringBuffer is meant to be a helper when one needs to interoperate with C like API that expects a preallocated buffer and a size for it. So instead of doing:
char* temp = (char *)malloc(MAXSIZE);
c_api_call(temp, MAXSIZE);
...
free(temp);
we can use StringBuffer to make it more safe. String Buffer also has pick semantics relative to String, so you can be convert it with zero cost if let's say you want to return the value of the buffer as a string from a function.
StringBuffer is not a class meant to build strings more efficiently like StringBuffer in Java or StringBuilder in C++. In U++ String plays the role of such classes, that's why it has a capacity.
It is also not meant to handle a raw pointer as a vector, though I find the idea very interesting. I think I saw somewhere a similar idea, but I don't remember where.
|
|
|
Goto Forum:
Current Time: Fri Aug 15 08:48:03 CEST 2025
Total time taken to generate the page: 0.11375 seconds
|