Empty PX_String - strange behaviour on load
Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=11688
Printed Date: 14 September 2025 at 11:01pm Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com
Topic: Empty PX_String - strange behaviour on load
Posted By: mgampi
Subject: Empty PX_String - strange behaviour on load
Date Posted: 01 August 2008 at 5:47am
Hi;
I'm using Toolkit 12.0.1 and CXTPPropExchangeXMLNode to store/load settings into/from XML files. When calling PX_String to store empty CString values (GetLength() returns 0) and afterwards calling PX_String to load the empty string from the XML file, I get a string with three newline ASCII code 10 characters in it!
Is this a BUG or do I miss something?
------------- Martin
Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0 Platform: Windows 10 v 22H2 (64bit) Language: VC++ 2022
|
Replies:
Posted By: Oleg
Date Posted: 03 August 2008 at 4:16am
Hi,
Show code lines
------------- Oleg, Support Team CODEJOCK SOFTWARE SOLUTIONS
|
Posted By: mgampi
Date Posted: 07 August 2008 at 5:29pm
Hi Oleg;
Here is my code to store the settings into the XML file:
bool StoreEventConfigSettings(struct _EventConfigOptions& gSettings, DWORD& dwError) { TCHAR pszPath[MAX_PATH]; if (SHGetFolderPath(0, CSIDL_COMMON_APPDATA, 0, SHGFP_TYPE_CURRENT, pszPath)==S_OK) { _tcscat(pszPath, _T("\\XRangeEye EventConfig 1.5"));
CXTPPropExchangeXMLNode px(FALSE, 0, _T("EventConfigSettings")); px.SetCompactMode(FALSE);
if (px.OnBeforeExchange()) { VERIFY(PX_String(&px, _T("DBConnect"), gSettings.EventConfigGeneralOptions.strService)); CXTPPropExchangeSection pxSubNode1(px.GetSection(_T("Service"))); VERIFY(PX_String(&pxSubNode1, _T("User"), gSettings.EventConfigServiceOptions.strUser)); VERIFY(PX_Blob(&pxSubNode1, _T("Security"), gSettings.EventConfigServiceOptions.lpPassword, gSettings.EventConfigServiceOptions.dwLen)); VERIFY(PX_String(&pxSubNode1, _T("Domain"), gSettings.EventConfigServiceOptions.strDomain));
_tcscat(pszPath, _T("\\Options.xml")); return (px.SaveToFile(pszPath)==S_OK) } } return false; } |
And here is the counterpart...
bool LoadEventConfigSettings(struct _EventConfigOptions& gSettings) { TCHAR pszPath[MAX_PATH]; if (SHGetFolderPath(0, CSIDL_COMMON_APPDATA, 0, SHGFP_TYPE_CURRENT, pszPath)==S_OK) { _tcscat(pszPath, _T("\\XRangeEye EventConfig 1.5\\Options.xml"));
CXTPPropExchangeXMLNode px(TRUE, 0, _T("EventConfigSettings")); if (px.LoadFromFile(pszPath)) { VERIFY(PX_String(&px, _T("DBConnect"), gSettings.EventConfigGeneralOptions.strService));
CXTPPropExchangeSection pxSubNode1(px.GetSection(_T("Service"))); VERIFY(PX_String(&pxSubNode1, _T("User"), gSettings.EventConfigServiceOptions.strUser)); if (gSettings.EventConfigServiceOptions.lpPassword!=0) { free(gSettings.EventConfigServiceOptions.lpPassword); gSettings.EventConfigServiceOptions.lpPassword=0; gSettings.EventConfigServiceOptions.dwLen=0; } VERIFY(PX_String(&pxSubNode1, _T("Domain"), gSettings.EventConfigServiceOptions.strDomain)); VERIFY(PX_Blob(&pxSubNode1, _T("Security"), gSettings.EventConfigServiceOptions.lpPassword, gSettings.EventConfigServiceOptions.dwLen)); return true; } }
XREventConfigOptions=XREventConfigDefaultOptions;
return false; } |
In my case, most of the time the parameter "Domain" is an empty string. So storing the empty string and afterwards loading it results in a string with \n three times
------------- Martin
Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0 Platform: Windows 10 v 22H2 (64bit) Language: VC++ 2022
|
Posted By: Oleg
Date Posted: 08 August 2008 at 6:19am
Hi,
Please remove px.SetCompactMode(FALSE); line. or don't format XML:
px.SaveToFile(pszPath, FALSE);
------------- Oleg, Support Team CODEJOCK SOFTWARE SOLUTIONS
|
Posted By: mgampi
Date Posted: 10 August 2008 at 11:10am
Hi Oleg;
Shouldn't it also work with non compact mode and/or formatted XML? Is this a bug of the MSXML implementation?
------------- Martin
Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0 Platform: Windows 10 v 22H2 (64bit) Language: VC++ 2022
|
Posted By: Oleg
Date Posted: 11 August 2008 at 2:11am
Shouldn't
------------- Oleg, Support Team CODEJOCK SOFTWARE SOLUTIONS
|
|