You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by Edward Slattery <ed...@googlemail.com> on 2006/03/21 19:04:47 UTC

SDO STL API

Hi all,

I want to replace the current C++ SDO interface with a C++ STL interface.
Particularly, I want to have a means of loading XML strings into some stored
string, and preserving the character set. I also want to provide a get/set
API for data object which returns some form of string, not a char* as at
present.

I think the way to do that cleanly would be to create an SDOString class,
which internally holds either a std::wstring, or a std::wstring*. This class
would have minimal functionality such as operator=, construction from char*,
construction from wchar_t* etc.

Is this a good way to make progress?

I am assuming that I would be able to use stdcxx on linux and windows, and
just put it ahead of the microsoft equivalent headers in the include path -
is that OK?

Any ideas, assistance, known issues etc? Anyone done just that a few days
ago?

regards,

Ed.

Re: SDO STL API

Posted by Martin Sebor <se...@roguewave.com>.
Edward Slattery wrote:
> Hi all,
> 
> I want to replace the current C++ SDO interface with a C++ STL
> interface.
> Particularly, I want to have a means of loading XML strings into some
> stored
> string, and preserving the character set. I also want to provide a
> get/set
> API for data object which returns some form of string, not a char* as at
> present.
> 
> I think the way to do that cleanly would be to create an SDOString
> class,
> which internally holds either a std::wstring, or a std::wstring*. This
> class
> would have minimal functionality such as operator=, construction from
> char*,
> construction from wchar_t* etc.
> 
> Is this a good way to make progress?

It sounds doable to me :) The only caveat to keep in mind is that
std::string is a sequence of bytes (and std::wstring is a sequence
of wchar_t elements), and not a sequence of (potentially multibyte)
characters. E.g., string::length() has the same semantics as strlen()
and not mbslen().

If this is acceptable, it may not be necessary to introduce another
string class. Exposing std::string directly instead would make the
SDO API more readily interoperable with other APIs.

> 
> I am assuming that I would be able to use stdcxx on linux and windows,
> and
> just put it ahead of the microsoft equivalent headers in the include
> path -
> is that OK?

Yes, that's pretty much how it works. On Linux it's also necessary
to use gcc instead of g++ to compile and link in order to avoid
linking with the native C++ Standard Library. The Windows compiler
provides a command line option that does the same.

Let us know how it goes!
Martin