[gtkmm] gstrings and file output



Hi.

Maybe someone can help me with this Unicode Problem.

I have a C++ class containing several Glib::usting objects and would
like to save them to a file via an C++ STL ofstream.

To do so, it did the following:

In the Class containing the ustrings:

(1)
friend std::basic_ostream<Glib::ustring::value_type>&
		operator<<(basic_ostream<Glib::ustring::value_type>& out, const Box& box)
{
		out << "partitions:" << box.m_partitions << std::endl;
		.....
		out << std::endl;
}

And in the class doing the actual writing to the file

(2)
blah blah ....
{
	std::basic_ofstream<Glib::ustring::value_type> to("test.box")
	if (!to) std::cerr << "Cannot open file" << std::endl;
	to << *box;
	to.close();
}
												
If I use std::ostream, (1) gives me a conversion error from Glib,
and if I use std::basic_ofstream<Glib::ustring::value_type>, (2) gives
me a segmentation fault.

Can anybody tell me what I'm doing wrong??






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]