You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Hannum Daniel <da...@siemens.com> on 2003/06/05 16:55:52 UTC

How can I tell if Xerces has been initialized?

I have a utility function that calls Xerces to do string transcoding. This
requires XMLPlatformUtils::Initialize() to be called. However, I can't
guarantee that a random client calling me has called this before. At the
same time, I can't just call it because the caller might be in the middle of
a parse.

How can I check if Xerces has been initialized already? I thought of
checking the value of the pointer that I need
(XMLPlatformUtils::fgTransService), but of course I won't be able to tell.
It will have a garbage value that looks just like a valid pointer.

Any help is appreciated.

dan

-------------------------------------------------------------------------------
This message and any included attachments are from Siemens Medical Solutions 
USA, Inc. and are intended only for the addressee(s).  
The information contained herein may include trade secrets or privileged or 
otherwise confidential information.  Unauthorized review, forwarding, printing, 
copying, distributing, or using such information is strictly prohibited and may 
be unlawful.  If you received this message in error, or have reason to believe 
you are not authorized to receive it, please promptly delete this message and 
notify the sender by e-mail with a copy to CSOffice@smed.com.  Thank you

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: How can I tell if Xerces has been initialized?

Posted by da...@us.ibm.com.



> I have a utility function that calls Xerces to do string transcoding.
This
> requires XMLPlatformUtils::Initialize() to be called. However, I can't
> guarantee that a random client calling me has called this before. At the
> same time, I can't just call it because the caller might be in the middle
of
> a parse.

Yes, you can.  There's a counting scheme that keeps the library from being
initialized more than once.  However, the initialization counting scheme is
not thread-safe, so you had better make sure multiple threads don't try to
initialize Xerces-C at the same time.

>
> How can I check if Xerces has been initialized already? I thought of
> checking the value of the pointer that I need
> (XMLPlatformUtils::fgTransService), but of course I won't be able to
tell.
> It will have a garbage value that looks just like a valid pointer.

No, I don't think it will -- it will either be a valid pointer, or 0.  Some
investigation on your part could confirm this.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org