String type casting

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
Rajesh_kr82
Participant
Posts: 24
Joined: Sat Oct 15, 2005 1:09 pm

String type casting

Post by Rajesh_kr82 »

How do i type cast a std::string object into APT_String object in a buildop stage??

Rajesh
Regards,
Rajesh
bcarlson
Premium Member
Premium Member
Posts: 772
Joined: Fri Oct 01, 2004 3:06 pm
Location: Minnesota

Post 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.
Rajesh_kr82
Participant
Posts: 24
Joined: Sat Oct 15, 2005 1:09 pm

Post by Rajesh_kr82 »

I got it by doing this:

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

Thanks for help
Regards,
Rajesh
Post Reply