Skip to main content
Participating Frequently
July 3, 2007
Question

How to convert UID to C++ String

  • July 3, 2007
  • 2 replies
  • 944 views
I need to convert a UID to a more generic C++ string in order to concatenate onto a SQL statement. So far I have tried the following to no avail:

1.
UID PreviousUID;
std::string sUID = (std::string)PreviousUID;

produces error: C2440: 'type cast' : cannot convert from 'UID' to 'std::string'

2. Also looked into going through PMString but nothing looked very promising.

Environment: Windows

This seems like something that should be very easy. Anybody know how to do this?

2 replies

Participating Frequently
July 3, 2007
That worked. Thank you.

-Miles smiles
Participating Frequently
July 3, 2007
Hi!<br /><br />The UID is a special InDesign type, so it can't be converted directly to a std::string. However, the underlying representation of the UID is a uint32, or unsigned long, which can be accessed through Get() and then converted to a std::string. For instance by doing something like:<br /><br />#include <sstream><br /><br />UID PreviousUID;<br />std::stringstream ss;<br />ss << PreviousUID.Get();<br />std::string str = out.str();<br /><br />Regards,<br />Andreas