OUString is mutable?
Michael Stahl
mstahl at redhat.com
Fri Sep 28 05:09:11 PDT 2012
On 28/09/12 13:46, Noel Grandin wrote:
> Hi
>
> I don't really understand the point of not being able to mutate OUString
> in-place, but being able to overwrite it via the assignment operator?
>
> It seems to me it should be one or the other.
> Either OUString is immutable, and it cannot be assigned to, except via a
> constructor, or it is mutable, and we can pretty much throw away
> OUStringBuffer.
[accidentally sent this first to Noel only instead of the list]
the point you are missing is that OUString is a sort of "smart pointer"
to an immutable buffer. it works similarly to "String" in Java, e.g. in
Java "String s = "foo"; s = "bar"" is legal but you cannot modify the
content of whatever value is assigned to "s".
that's why OUString has an operator= that makes it point at a different
buffer but offers no way to write into the buffer (at least i hope it
doesn't...).
More information about the LibreOffice
mailing list