Re: Why std::string is used for the file paths?
- From: Toralf Lund <toralf procaptura com>
- To: Roman Yazmin <roman yazmin gmail com>
- Cc: gtkmm-list gnome org
- Subject: Re: Why std::string is used for the file paths?
- Date: Mon, 14 Jul 2008 11:16:35 +0200
Roman Yazmin wrote:
Gtkmm doesn't have its own "string" class. It has a special class
for UTF-8 encoded strings. That's what Glib::ustring is.
And all library use this special class for UTF-8 encoded strings. And
must be used for file paths also.
If not, please show me the benefits of using std::string for file
paths instead of ustring.
I think you are looking at this from the wrong side, so as to speak.
As far as I understand, Glib::ustring is not intended as a "separate"
string class. It may be implemented somewhat separately for some obscure
technical reason, but you should view it as a specialisation of
std::string with additional support for UTF-8 encoding and variable
length characters.
So, generally std::string is used all over the place. In some places, a
specialised class with support for a special case of a string, i.e. an
UTF-8 encoded text, is needed. This is where Glib::ustring is used. But
Glib::ustring "is a" std::string, at least conceptually. Other places,
strings are just general character sequences, so the generic string
class is used directly. std::string, that is.
Also using the current Glib::ustring implementation for the more general
strings may work from a technical perspective, but it would break with
the normal rules for object orientation, and Glib::ustring *might* also
be implemented in such a way that non-UTF-8 strings would simply be
rejected.
- Toralf
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]