Re: PeerInfo and PeerId

Hi Petr,

Just checked you new revision with PeerInfo - the class looks quite neat :-)

I was thinking that we could also provide a named ctor fromUri() to complement the toUri() function.

Regarding the static initialization dependency, does it still cause trouble if you use QByteArray instead of char *? I think it should not make any difference. The perfect case is when we use static const integral literals, which the compiler can substitute already at compile time - then we have no dependency problems. I’m not hundred pro sure about this, but from what I recently read, I think that using static const members from within the same class will always work. I guess that is so because before e.g. the ctor gets called the module where the ctor is located must be loaded and one of the first things that will happen upon loading the module is that the static members are be initialized.

Here is one test that would fail:

peerInfo.setPeerId (peerId1);
peerInfo.setPeerId (peerId2);
CPPUNIT_ASSERT (peerInfo.peerId() == peerId2);

the internally stored query component of the uri will have become id=peerId1Bytes&id=peerId2Bytes. Calling uri.setQuery(”") before appendQueryItem() would clear the old data. And if we want the strong guarantee of exception safety for setPeerId() we’d better do the job on a temp uri first.

Regards,

Peter

Would you like to post a relpy?


This post is a reply to:
Re: PeerInfo and PeerId
Hi Peter, What about compiling Qt4 first? ;-) It would have been nice to test it but no worries if it does not work. I'll give it a try and let you (more...)

Follow-ups:
Re: PeerInfo and PeerId
Hi Peter, I was thinking that we could also provide a named ctor fromUri() to complement the toUri() function. Sure - good idea. I'll add it. Regarding the static initialization dependency, does it (more...)