Board index » cppbuilder » IDURI??

IDURI??


2005-06-10 11:46:34 PM
cppbuilder68
Hi, I'm trying to use the IdURI of Indy, but I have some troblues.
-first I'm not exactly sure how to declare an object of this class, It
wasnt on the pallet, but thats ok, I declared an object like this :
TIdURI *something ; (if I did TIdURI something it will tell me a bad
declaration err so I did it that way),
then when I try to do something->URLEncode(Edit->Text)
I got the following errors:
[C++ Error] mess.cpp(62): E2034 Cannot convert 'AnsiString' to 'TMetaClass
*'
[C++ Error] mess.cpp(62): E2342 Type mismatch in parameter 'vmt' (wanted
'TMetaClass *', got 'AnsiString')
[C++ Error] mess.cpp(62): E2192 Too few parameters in call
And well on the documentation it says that the function headers are like
this:
function URLDecode(psSrc: string)
so I'm not pretty sur ewhat did I missdid or what I did wrong, I'll
apriciate any help, I have been looking for doc on this but couldnt find any
beside the indy doc.
Thanx for any help!
 
 

Re:IDURI??

"federico" < XXXX@XXXXX.COM >wrote in message
Quote
-first I'm not exactly sure how to declare an object of this class
TIdURI *uri = new TIdURI("URIToParse");
//...
delete uri;
Quote
It wasnt on the pallet
TIdURI is not a component to begin with, thus it does not appear on the
Component Palette.
Quote
[C++ Error] mess.cpp(62): E2034 Cannot convert 'AnsiString'
to 'TMetaClass *'
URLEncode() is declared as a 'class' method in Indy's Delphi source code.
The closest C++ equivilent (but not exactly the same) is a 'static' method.
Like a 'static' method, a 'class' method does not need an object instance in
order to be called. The difference between a Delphi 'class' method and a
C++ 'static' method, however, is that the class type information is passed
to a 'class' method, whereas it is not in a 'static' method. That is where
the extra TMetaClass parameter comes into play in C++ (it is implicitally
passed in Delphi, much like the 'this' pointer is for non-static methods).
In C++, you have to pass in the class type manually, via the __classid()
keyword, ie:
... = something->URLEncode(__classid(TIdURI), Edit->Text);
Or alternatively, without an object instance:
... = TIdURI::URLEncode(__classid(TIdURI), Edit->Text);
Quote
And well on the documentation it says that the function headers
are like this:

function URLDecode(psSrc: string)
That is a Delphi declaration, not a C++ declaration. Indy is written in
Delphi, and the documentation shows Delphi examples, not C++ ones. If you
look in IdURI.hpp, you will see this instead:
/* class method */ static AnsiString __fastcall URLEncode(TMetaClass*
vmt, const AnsiString ASrc);
Gambit