Documentation for Ice 3.5. The latest release is Ice 3.7. Refer to the space directory for other releases.

The default behavior of the run time can be changed by providing application-specific string converters. If you install such converters, all Slice strings will be passed to the appropriate converter when they are marshaled and unmarshaled. Therefore, the string converters allow you to convert all strings transparently into their native representation without having to insert explicit conversion calls whenever a string crosses a Slice interface boundary.

You can install string converters on a per-communicator basis when you create a communicator by setting the stringConverter and wstringConverter members of the InitializationData structure. Any strings that use the default (std::string) mapping are passed through the specified stringConverter, and any strings that use the wide (std::wstring) mapping are passed through the specified wstringConverter.

The string converters are defined as follows:

C++
namespace Ice {

class UTF8Buffer {
public:
    virtual Byte* getMoreBytes(size_t howMany, Byte* firstUnused) = 0;
    virtual ~UTF8Buffer() {}
};

template<typename charT>
class BasicStringConverter : public IceUtil::Shared {
public:
    virtual Byte* toUTF8(const charT* sourceStart, const charT* sourceEnd,
                         UTF8Buffer&) const = 0;

    virtual void fromUTF8(const Byte* sourceStart,
                          const Byte* sourceEnd,
                          std::basic_string<charT>& target) const;
};

typedef BasicStringConverter<char> StringConverter;
typedef IceUtil::Handle<StringConverter> StringConverterPtr;

typedef BasicStringConverter<wchar_t> WstringConverter;
typedef IceUtil::Handle<WstringConverter> WstringConverterPtr;

}

As you can see, both narrow and wide string converters are simply templates with either a narrow or a wide character (char or wchar_t) as the template parameter.

See Also
  • No labels