stringstream/facet issues with XCode 2.1
stringstream/facet issues with XCode 2.1
- Subject: stringstream/facet issues with XCode 2.1
- From: Tom Bednarz <email@hidden>
- Date: Tue, 14 Jun 2005 14:31:17 -0400
I'm in the process of porting code from MW (and other platform compilers)
and have encountered an issue with char_traits and stringstream classes
with XCode 2.1. We have types that define basic_strings of both
UTF-8 and UTF-16 characters, along with streams to work with these
types,
for example:
namespace dvtypes {
typedef
std::uint16_t UTF16Char;
typedef std::basic_string<UTF16Char> UTF16String;
typedef std::basic_ostringstream<dva::UTF16Char, std::char_traits<dva::UTF16Char>, std::allocator<dva::UTF16Char> > oUTF16StringStream;
typedef std::basic_istringstream<dva::UTF16Char, std::char_traits<dva::UTF16Char>, std::allocator<dva::UTF16Char> > iUTF16StringStream;
typedef std::uint8_t UTF8Char;
typedef std::basic_string<UTF8Char> UTF8String;
typedef std::basic_ostringstream<dva::UTF8Char, std::char_traits<dva::UTF8Char>, std::allocator<dva::UTF8Char> > oUTF8StringStream;
typedef std::basic_istringstream<dva::UTF8Char, std::char_traits<dva::UTF8Char>, std::allocator<dva::UTF8Char> > iUTF8StringStream;
typedef std::basic_ofstream<dva::UTF8Char, std::char_traits<dva::UTF8Char> > ofUTF8Stream;
}
A common code patten using these types follows:
dvtypes ::UTF8String currValUTF8((const dvtypes::UTF8Char*)"82");
std::uint32_t newVal=0;
dvtypes ::iUTF8StringStream stream(currValUTF8);
stream >> newVal;
Compiled with XCode 2.1, attempting to use the extraction operator will throw a bad_cast exception. It appears as though there is no suitable facet for the UTF8Char types. To address this, I have tried the following:
* creating a subclass of std::facet, specialized on <unsigned char>, creating a custom locale with the facet<unsigned char> and imbuing the stringstream. The new facet was not found.
* i also tried creating a custom specialization of char_traits<unsigned char>. Still no success.
I assume that this is what is required to support streams that aren't based on char or wchar_t. Is there anything I'm missing? Has anyone been successful in doing this with XCode 2.1/gcc4?
thanks
--tom
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden