|
Key order is not a property of such a collection (see the documentation[^]) unlike, for instance, the std::map .
So yes, you have to work around that.
|
|
|
|
|
Hello Everybody,
I am trying to read XML file using MSXML parser. Till now, all paths are in English characters and inside file also all are in English only.
Now, we are trying to move with Chinese characters also. So, inside file wherever needed, we are able to manage conversion and load the file using MSXML parser.
Now, the problem is, if the path of the xml file consists of Chinese characters, then
IXMLDOMDocumentPtr->load(path)
is not working.
Is there anyway to load the file ?
PS. we can able to write a new parser, but need to change a lot in our existing application.
Thanks in advance.
Regards,
Gopinath.
|
|
|
|
|
Gopi Nath wrote: is not working What does that mean?
|
|
|
|
|
Hello Richard,
MSXML::IXMLDOMDocumentPtr->load function, when I tried to load a file in which the path or file name contains Chinese characters, its not loading. Means, it fails to load the file into the document pointer and return false.
Regards,
Gopinath.
|
|
|
|
|
|
Thanks Richard,
I will check and will get back to you on this.
Regards,
Gopinath.
|
|
|
|
|
Do you need to canonicalize the path?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Perhaps, there is some problem with encoding?
|
|
|
|
|
Gopi Nath wrote: Now, the problem is, if the path of the xml file consists of Chinese characters, then
IXMLDOMDocumentPtr->load(path)
is not working.
You left out so much relevant information...
1.) Could you give an example path containing Chinese characters that fails to load?
2.) What MSXML DLL version?
3.) What operating system version?
Best Wishes,
-David Delaune
|
|
|
|
|
Hello Everybody,
Sorry for late reply.
It was character issue. My application is with Unicode character type. If I send the path as TSTR, then it works fine properly.
Thanks again.
Regards,
Gopinath.
|
|
|
|
|
Input:
The first line of the input contains integer T denoting the number of test cases. For each test case, there are two integer inputs a & b.
Output:
For each test case, the output is the integer displaying the XOR of a & b after making them of equal lengths.
Constraints:
1<=T<=100
1<=a,b<=107
Example:
Input:
4
2 6
3 10
5 24
1 20
Output:
2
6
12
4
Explanation:
1. The binary representation of 2 is 10 and of 6 is 110. As the length of "10" is smaller, so add a '0' to it making it "100', to make the length of binary representations equal. XOR of 100 and 110 gives 010 which is 2.
Below is my code
#include <iostream>
#include <cmath>
#include <sstream>
#include <cstring>
#include <string>
using namespace std;
int main()
{
int cases, binary[100];
cin>>cases;
int *result = new int[cases];
int j;
for(j=0; j<cases; j++){
stringstream ss[3];
for(int k=0; k<2; k++)
{
int n;
cin>>n;
int temp=n, i=0, len;
while(temp > 0){
binary[i] = temp%2;
temp /= 2;
i++;
}
len = i;
string str ;
for(int i=0; i<len; ++i){
stringstream ss;
ss << binary[(len-1)-i];
str += ss.str() ;
}
ss[k] << str;
}
string str1 = ss[0].str(), str2 = ss[1].str();
int len = (str1.length() > str2.length()) ? str1.length() : str2.length() ;
if(str1.length() < (unsigned)len){
int diff = len - str1.length();
for(int i=0; i<diff; ++i){
str1 += '0';
}
}
else if(str2.length() < (unsigned)len){
int diff = len - str2.length();
for(int i=0; i<diff; ++i){
str2 += '0';
}
}
string str3 = str1;
for(int i=0; i<len; ++i){
if(str1[i]==str2[i]){
str3[i]='0';
}else str3[i]='1';
}
int length = str3.length(), val=0;
for(int i=0, m=length-1; i<length, m>=0; ++i,--m){
if(str3[i] == '1'){
val += pow(2, m);
}
}
result[j] = val;
}
for(int i=0; i<cases; i++){
cout<<result[i]<<endl;
}
return 0;
}
how to make it more efficient & short(i haven't studied oops yet)
|
|
|
|
|
You can get the length of each value (remember to save the originals) by repeatedly shifting one bit right until it is zero. You then shift the smaller value left by the difference between their lengths. That will give you two integers of the same length. All you need then is to create the XOR of the two and print it out.
|
|
|
|
|
Using Richard's suggestion:
unsigned int myxor(unsigned int a, unsigned int b)
{
if ( a < b) swap(a,b);
int lab = 0; int ca = a;
int cb = b;
while ( ca )
{
if ( cb == 0 )
++lab;
ca >>= 1;
cb >>= 1;
}
return ( a ^ (b << lab));
}
|
|
|
|
|
Better than my idea.
|
|
|
|
|
|
In the C/C++ code below debugptr comes up as null however when I go into Disassembly the value return in register rax from __imp_Cwnd::FromHandle is correct as I place an eyecatcher "Debug" in CprogDebug and when I go to look at that memory address I can see that literal in the memory
more so when I got to rsi + 118h the value of the rax register is there
When I do a quickwatch in VS on Debugptr its NULL
BTW I do a get an exception utilizing debugptr as a pointer
133: debugptr = (CprogDebug *)temptr->GetOwner();
00007FF635B24727 48 8B 88 98 00 00 00 mov rcx,qword ptr [rax+98h]
00007FF635B2472E 48 85 C9 test rcx,rcx
00007FF635B24731 75 0D jne CMypercolate::process_sdump+60h (07FF635B24740h)
00007FF635B24733 48 8B 48 40 mov rcx,qword ptr [rax+40h]
00007FF635B24737 FF 15 A3 AC 00 00 call qword ptr [__imp_GetParent (07FF635B2F3E0h)]
00007FF635B2473D 48 8B C8 mov rcx,rax
00007FF635B24740 FF 15 BA B8 00 00 call qword ptr [__imp_CWnd::FromHandle (07FF635B30000h)]
00007FF635B24746 48 89 86 18 01 00 00 mov qword ptr [rsi+118h],rax
|
|
|
|
|
The source and assembly do not appear to match.
|
|
|
|
|
Wow you are good I’ll do it again but I was still at a breakpoint when I copied the text while was tracing and verifying the output I’m in bed as it’s 2:37 in the morning so I’ll do it again tommorow or in the morning
|
|
|
|
|
ForNow wrote: Wow you are good Not at all. It's just that every so often I actually read a question carefully.
|
|
|
|
|
I re-built its the the code at 5:52 est I just tested it did a disassembly it the same disassembly I posted it strange because the value returned from Cwnd::FromHandle has a valid return in rax I check rsi + 118 h and that value has the rax register also nore rsi + 118h = FA2C48D158 however I do quick watch on &debugptr and that value is null the value of &debugptr is 7FFd34e61810 which is strange shouldn't rsi + 118h == &debugptr ???
thanks
|
|
|
|
|
Sorry I must be missing something . I do not see the connection between Cwnd::FromHandle and debugptr = (CprogDebug *)temptr->GetOwner(); .
|
|
|
|
|
First let just say what I am trying to accomplish I have CProgDebug object of Cwnd type I am trying to save all the info in that Object I have two modal dialogboxes which gather info that I need so when I create these two Modal Dialog Boxes one after the other I create them with pParent being = to the Created Dialog the documentation says in that Case if pParent is not equal to NULL the pParent Cwnd will be the Parent or Owner maybe I should try debugptr = temptr->GetParent(); and see what Happens I think your logic is right though
Thanks
|
|
|
|
|
this is what documentation states Quote: Points to the parent or owner window object (of type CWnd
I just stepped thru my constructer of both modal dialog boxes in my quick watch I had this->m_WndOwner (from Cwnd) and this->m_pParent (from Cdialog) I had passed a valid Cwnd
after in Disassembly mode I executed Cdialog:Cdialog this->m_pParent is Null while this->m_pParent has a value in fact the pointer to the pParent I pass as I can see the eyecatcher
|
|
|
|
|
I have never used GetOwner , but there seem to be some caveats about its usage at CWnd::GetOwner[^]. You also need to be sure that temptr is pointing at the object you think it is.
|
|
|
|
|
Richard as you noted the assembly didn't match the source It lead me to insert #pragma optimize("",off) and #pragma optimize ('',on) around the function the call to __imp CWnd::FromHandle disappeard and debugptr had the right value
Thanks
|
|
|
|