|
i do have a closure tag. that is not the problem....
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
Ok if this is the case I want to confirm one more thing.
Since you are using IXMLDOMDocument, have you initialize the pointer with statement like this?
SUCCEEDED (CoCreateInstance(CLSID_DOMDocument,
NULL,
CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument,
reinterpret_cast<void**>(&m_pDoc))));
m_pDoc->loadXML("<a></a>");
Regards
Anil
|
|
|
|
|
yes i did
i know there is a IXMLDOMParseErrorPtr object which i can get the error that has occurred but i can't seem to get it properly....
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
the bellow code working fine with me.
IXMLDOMDocument *m_pDoc;
m_pDoc = NULL;
if ( SUCCEEDED (CoCreateInstance(CLSID_DOMDocument,
NULL,
CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument,
reinterpret_cast<void**>(&m_pDoc))))
{
m_pDoc->loadXML("<a></a>");
}
and also the bellow code
{
HRESULT hResult = E_FAIL;
long lErrorCode = E_FAIL;
IXMLDOMParseError *pXMLError = NULL;
if (SUCCEEDED(m_pDoc->get_parseError(&pXMLError))
&& SUCCEEDED(pXMLError->get_errorCode(&lErrorCode))
&& ( lErrorCode != 0 ) )
{
// do some error report procedure
}
//
// Clean-up pointers used.
//
if ( pXMLError )
{
pXMLError->Release();
pXMLError = NULL;
}
//
// Pass back the return code.
//
return lErrorCode;
}
Regards
Anil
|
|
|
|
|
YaronNir wrote: i know there is a IXMLDOMParseErrorPtr object which i can get the error that has occurred but i can't seem to get it properly....
What is the error?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
What type of string are you trying to load the DOM with?
|
|
|
|
|
CString which is cast to _bstr_
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
Regarding the null terminating character being embedded within a source/custom resource (input string) , I'm having some difficulty getting fwrite to continue past embedded 0x00 values in my data...
Someone posted elsewhere on this site:
It acted like it continued beyond the end of the array until it came across the zero byte in memory. I put the "\0" or the 0x00 and it stopped exactly where I told it too. This raises the question, if that array is supposedly a hex representation of an exe, how are you getting away without stumbling across 0x00 somewhere in the binary string? this is one of the reason they tell us to encode binary data when using a null terminated string to contain it.
My code:
CODE
char * cStr = reinterpret_cast< char *>(lpVoid);
cStr = strncat(cStr, "\0", 1);
printf("size of cStr%d\n", sizeof(cStr));
FILE * stream;
if( (stream = fopen( "fread.out", "w" )) != NULL )
{
int num_write = 0;
num_write = fwrite( cStr, sizeof( cStr ), 1, stream );
printf( "Wrote items: %d\n", num_write );
fclose( stream );
}
Results:
follwing were writing sizeof(cStr) - 1 (not wanting to write the trailing null to our output file):
testing: 4d 5a 90 as input, output: 4d 5a 90 (OK)
testing: 4d 5a 90 00 as input, output: 4d 5a 90
testing: 4d 5a 90 00 03 as input, output: 4d 5a 90
testing: 4d 5a 90 03 as input: output: 4d 5a 90
writing sizeof(cStr) :
4d 5a 90 -> 4d 5a 90 00
4d 5a 90 00 -> 4d 5a 90 00
4d 5a 90 00 03 -> 4d 5a 90 00 (stripped trailing character)
Anyone have any suggestions on how to proceed?
How will the program know the difference between the trailing null at the end of the string versus embedded nulls?
|
|
|
|
|
There are two problems. First, cStr is a pointer, so sizeof(cStr) will always be 4 no matter what it's pointing to.
Second, strncat(cStr, "\0", 1) has no effect. A \0 character marks the end of a string, so "\0" is the same as "" , a string with zero length.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
If this is an exe file that your trying to place into some null terminated string, you will probably need to hex encode or base64 encode it so that no nulls appear.
BSTR comes to mind but I've never used them for binary data but it's supposed to be useful for that.
If your into COM, you can use CreateStreamOnHGlobal. I use it when Decoding Base64 encoded binary data to temporarily hold the byte stream before I load a GDI+ image object with the data stream. GetHGlobalFromStream works nicely with CArchive::Write so you can serialize to and from disk with having to deal with strings.
It takes about a weeks effort to build a fairly nice reusable class. But it's worth it if your going to be working with binary streams often. The book "Essential COM" by Don Box has a short but adequate section on it not to mention fairly decent coverage of COM (if there really is such a thing)
|
|
|
|
|
|
well, first, try to reduce the amount of code that you post.
second, yes you can do this!
you read the XML file with the XML DOM API from microsoft ( msxml ).
and for each type you collect the information in the XML file, and call a constructor of your objects with the appropriate values.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hey!!! You are allowed to post code here not the entire project. I think while posting it you should have got atleast three warnings! If the text content is too long normally we get *a* warning.
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[V]--
[My Current Status]
|
|
|
|
|
entire project? I dont think so... the project is huge and is mostly graphics in OpenGL and frames... so this is only a fraction with classes
any examples of the msxml anywhere? is it easy? do you have any sample code?
|
|
|
|
|
we're not on CP to do the job for you....
go and search yourself, and if yoou have any particuliar question, ,then only you are allowed to ask, with a short code sample to explain your problem (but not the whole huge file like you do )
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
ok, next time i'll cut the code short
but please give me some short sample code to show how to do it
like how to save form
class A() to <A =" "> etc..
-- modified at 9:45 Tuesday 30th May, 2006
|
|
|
|
|
Hello I am Javi,
I am doing a validator certificate and i need to use the CMapi of MFC that uses the file mapi.h and in the compilation i have a lot of error, very stupid like missing { before *, when the * is from a pointer.
What can I do? Can anybody help me? I am sure that the source code is correct is only a library problem, anybody knows with library i must to add?
Thank you very much!!!
-- modified at 15:20 Monday 29th May, 2006
|
|
|
|
|
Hi !!!
Can me somebody tell what is an singletone design pattern?
Please give me some little code samle.
Thanks.
-:KNOX:-
|
|
|
|
|
|
search with this key word in code project you will get many.
One example from CP: Singleton Pattern & its implementation with C++
--------------------------------------------------------------------
class my_singleton
{
private:
std::string my_string;
my_singleton() : my_string("foo bar bash") {}
public:
static my_singleton &instance()
{
static my_singleton global_instance;
return global_instance;
}
std::string get_string() { return my_string; }
};
...
cout << my_singleton::get_instance().get_string() << endl;
Nice talking to you.
If you judge people, you have no time to love them. -- Mother Teresa
|
|
|
|
|
Hi,
this class isn't really a singleton, because you can make more than one instances of it.
You need to change the modifier of the constructor from public to at least protected.
This way one is forced to use the instance function.
class my_singleton
{
private:
std::string my_string;
my_singleton() : my_string("foo bar bash") {}
public:
static my_singleton &instance()
{
static my_singleton global_instance;
return global_instance;
}
std::string get_string() { return my_string; }
};
...
cout << my_singleton::instance().get_string() << endl;
codito ergo sum
|
|
|
|
|
Oh. Sorry & Thanks for correcting me.
Nice talking to you.
If you judge people, you have no time to love them. -- Mother Teresa
|
|
|
|
|
Thanks for the help.
-:KNOX:-
|
|
|
|
|
You are always welcome
Nice talking to you.
If you judge people, you have no time to love them. -- Mother Teresa
|
|
|
|
|
Hello!
I have a simple application done with VC++ (2003 .NET). I made simple dialog based application with some buttons (with resource editor). Now I want to do something with images and want to try cool code with CImage class. By MSDN documentation I have to to include
<br />
#include "afxstr.h" (I replaced <> with " so it can be seen in this post)<br />
#include "atlimage.h"<br />
in that exact order. Project setting is "Use MFC in shared DLL". When I do this I get many linker errors like
<br />
LIBCMTD.lib(dbgheap.obj) : error LNK2005: _malloc already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(dbgheap.obj) : error LNK2005: _calloc already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(dbgheap.obj) : error LNK2005: _realloc already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(dbgheap.obj) : error LNK2005: _free already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(dosmap.obj) : error LNK2005: __errno already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(crt0dat.obj) : error LNK2005: _exit already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(crt0dat.obj) : error LNK2005: __exit already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(crt0dat.obj) : error LNK2005: __cexit already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(crt0dat.obj) : error LNK2005: __c_exit already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(fflush.obj) : error LNK2005: _fflush already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(isctype.obj) : error LNK2005: __isctype already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(crt0.obj) : error LNK2005: __amsg_exit already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in msvcrtd.lib(cinitexe.obj)<br />
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in msvcrtd.lib(cinitexe.obj)<br />
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in msvcrtd.lib(cinitexe.obj)<br />
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in msvcrtd.lib(cinitexe.obj)<br />
LIBCMTD.lib(strftime.obj) : error LNK2005: _strftime already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(atox.obj) : error LNK2005: _atoi already defined in msvcrtd.lib(MSVCR71D.dll)<br />
LIBCMTD.lib(getenv.obj) : error LNK2005: _getenv already defined in msvcrtd.lib(MSVCR71D.dll)<br />
zlib.lib(minigzip.obj) : error LNK2005: _error already defined in webServer.lib(uemf.obj)<br />
msvcrtd.lib(MSVCR71D.dll) : error LNK2005: __stricmp already defined in LIBCMTD.lib(stricmp.obj)<br />
msvcrtd.lib(MSVCR71D.dll) : error LNK2005: __strnicmp already defined in LIBCMTD.lib(strnicmp.obj)<br />
msvcrtd.lib(MSVCR71D.dll) : error LNK2005: __write already defined in LIBCMTD.lib(write.obj)<br />
msvcrtd.lib(MSVCR71D.dll) : error LNK2005: _tolower already defined in LIBCMTD.lib(tolower.obj)<br />
msvcrtd.lib(MSVCR71D.dll) : error LNK2005: _strcspn already defined in LIBCMTD.lib(strcspn.obj)<br />
msvcrtd.lib(MSVCR71D.dll) : error LNK2005: __setmbcp already defined in LIBCMTD.lib(mbctype.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: ___crtExitProcess already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: __cinit already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: _exit already defined in msvcrtd.lib(MSVCR71D.dll)<br />
libc.lib(crt0dat.obj) : error LNK2005: __exit already defined in msvcrtd.lib(MSVCR71D.dll)<br />
libc.lib(crt0dat.obj) : error LNK2005: __cexit already defined in msvcrtd.lib(MSVCR71D.dll)<br />
libc.lib(crt0dat.obj) : error LNK2005: __c_exit already defined in msvcrtd.lib(MSVCR71D.dll)<br />
libc.lib(crt0dat.obj) : error LNK2005: __C_Exit_Done already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: __C_Termination_Done already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: __exitflag already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: __wpgmptr already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: __pgmptr already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: ___winitenv already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: __wenviron already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: ___initenv already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: __environ already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: ___wargv already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: ___argv already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: ___argc already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: __winminor already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: __winmajor already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: __winver already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: __osver already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: __osplatform already defined in LIBCMTD.lib(crt0dat.obj)<br />
libc.lib(crt0dat.obj) : error LNK2005: __umaskval already defined in LIBCMTD.lib(crt0dat.obj)<br />
msvcrtd.lib(MSVCR71D.dll) : error LNK2005: __itoa already defined in LIBCMTD.lib(xtoa.obj)<br />
msvcrtd.lib(MSVCR71D.dll) : error LNK2005: __lseek already defined in LIBCMTD.lib(lseek.obj)<br />
msvcrtd.lib(MSVCR71D.dll) : error LNK2005: __unlink already defined in LIBCMTD.lib(unlink.obj)<br />
what can I do. Can I include CImage some other way? Please help!
Best regards,
Rostfrei
|
|
|
|