Page 1 of 1

String type casting

Posted: Wed Jan 04, 2006 2:57 pm
by Rajesh_kr82
How do i type cast a std::string object into APT_String object in a buildop stage??

Rajesh

Posted: Fri Jan 06, 2006 2:50 pm
by bcarlson
What do you mean by 'std::string'?

If you have a standard C string (i.e. an array of characters) or can convert your string to this format, then there are built-in conversions.

Check out the header files in AscentialRootDir/DataStage/PXEngine/include/apt_util. The most useful headers in this case would be basicstring.h and string.h. The basicstring.h defines a parent class of APT_BasicString from which APT_String, defined in string.h, is derived.

APT_String has constructors that have parameters of a standard C-string with an optional length:

Code: Select all

APT_String(const char *str)

-or-

APT_String(const char *str, APT_Int32 len)
For example:

Code: Select all

char myCString1[20]="Have a nice day.";
char *myCString2="Hello world.";

APT_String myDSString1(myCString1, 20);
APT_String myDSString2(myCString2);
Hope this helps.

Brad.

Posted: Fri Jan 06, 2006 6:13 pm
by Rajesh_kr82
I got it by doing this:

APT_String( Cstring.c_str( ) ); -- where Cstring is a standard C string.

Thanks for help