Print Page | Close Window

significance of AFX_CODEJOCK_PRIVATE

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: General Discussion
Forum Description: Topics Related to Visual C++ MFC Development in General
URL: http://forum.codejock.com/forum_posts.asp?TID=15701
Printed Date: 28 April 2024 at 10:15am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: significance of AFX_CODEJOCK_PRIVATE
Posted By: JohnPerks
Subject: significance of AFX_CODEJOCK_PRIVATE
Date Posted: 24 November 2009 at 10:03am
I've just inherited a fairly large body of MFC code that uses Codejock. I've noticed that the code refers to types (such asCXTPPropExchangeEnumeratorPtr) and methods (such as CXTPPropExchangeXmlNode::PreformatString) that are in an AFX_CODEJOCK_PRIVATE block. (The former of these is used in the examples in the documentatin, which muddies the waters yet further.)

Is such code intended to be called, or is it best avoided as an internal detail?

Many thanks




Replies:
Posted By: Oleg
Date Posted: 25 November 2009 at 5:00am
Hi,
I don't see how PreformatString can be useful in application code. Please show it with context.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: JohnPerks
Date Posted: 25 November 2009 at 7:49am
Originally posted by oleg oleg wrote:

I don't see how PreformatString can be useful in application code.


Without wishing to speak ill of my predecessor, neither can I at the moment. The code is below if that helps.

In general, should the items declared in such PRIVATE blocks be avoided? In which case, is std::auto_ptr<CXTPPropExchangeEnumerator> to be preferred over CXTPPropExchangeEnumeratorPtr?

void SomeClass::LoadXMLString(CXTPPropExchange* pPX, LPCTSTR pszPropName, CString& strValue)
{
#ifdef _UNICODE
    PX_String(pPX, pszPropName, strValue);
#else

    BSTR bstrValue = 0;
    PX_Bstr(pPX, pszPropName, bstrValue, 0);

    ASSERT(!bstrValue || wcslen(bstrValue) < 1024);

    if (bstrValue)
    {
        WideCharToMultiByte(0, 0, bstrValue, -1, strValue.GetBuffer(1024), 1024, 0, 0);
        strValue.ReleaseBuffer();
        SysFreeString(bstrValue);
    }
#endif
    CXTPPropExchangeXMLNode::PreformatString(strValue, FALSE);
}



Posted By: Oleg
Date Posted: 26 November 2009 at 2:02am
hmm.
Maybe it was added to support some national characters.   but XML should handle it without problems.
 
Anyway I think single
 
PX_String(pPX, pszPropName, strValue);
 
can replace it all.
 
at least move CXTPPropExchangeXMLNode::PreformatString one line up - to call it only with ANSI version. PX_String already run it.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net