David Baird | 1 Nov 01:31
Picon

[Boot.Pool] Opinions about inconsistent pointer types

Hi,

I was looking through the Pool code and noticed that it presents
inconsistent pointer types to the user ("void *" versus "char *").

For example, if the user wants to implement his/her own user
allocator, they have to write it like, e.g. (using "char *" as the
pointer type):

    struct default_user_allocator_new_delete
    {
      typedef std::size_t size_type;
      typedef std::ptrdiff_t difference_type;

      static char * malloc(const size_type bytes)
      { return new (std::nothrow) char[bytes]; }
      static void free(char * const block)
      { delete [] block; }
    };

However, other classes return "void *" as their pointer types, e.g.
singleton_pool:

    template <typename Tag, unsigned RequestedSize,
        typename UserAllocator,
        typename Mutex,
        unsigned NextSize>
    struct singleton_pool
    {
        static void * malloc()
(Continue reading)

Christoph | 1 Nov 14:42
Picon
Picon

Boost.Serialization: error checking

I am experimenting with Boost.Serialization.
I tried to de-serialize a (binary) file written for a *different* class.
Obviously, this can not work.

However, there is not thrown an exception.
Question: (How) can I determine that the reading failed?
(In case of corrupted or non-matching archives.)

(I have attached a small demo.)

Best regards
Christoph
Attachment (data.cpp): text/x-csrc, 1588 bytes
Attachment (data.hpp): text/x-c++src, 1903 bytes
Attachment (serial_main.cpp): text/x-csrc, 1724 bytes
_______________________________________________
Boost-users mailing list
Boost-users <at> lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Tim St. Clair | 1 Nov 15:11
Picon
Gravatar

Re: Boost.Serialization: error checking

I've encountered the same issue(s) in the past where signals will be
raised when the data serialized is nothing close to what is expected.

I have been able to deal with it is by doing one, or all, of the following:

     Derive all types which are "Serializable" from common base, then
always try to unserialize to<->from that base.  From there,
switch/vector on the derived type, either through RTTI or some other
mechanism.
     I would also recommend overloading the sig_hdlr, so you can
gracefully shutdown in case something runs-a-muck.

Hope this helps,
-Tim

On 11/1/07, Christoph <christoph.duelli <at> gmx.de> wrote:
> I am experimenting with Boost.Serialization.
> I tried to de-serialize a (binary) file written for a *different* class.
> Obviously, this can not work.
>
> However, there is not thrown an exception.
> Question: (How) can I determine that the reading failed?
> (In case of corrupted or non-matching archives.)
>
> (I have attached a small demo.)
>
> Best regards
> Christoph
>
> _______________________________________________
(Continue reading)

Robert Ramey | 1 Nov 17:29

Re: Boost.Serialization: error checking

binary archives are implemented to be as fast as possible.
There isn't any checking which would impact erformance.

One thing that I've found useful is to check the serialization
using xml archives.  Since these have "end" tags, mis-matched
saved/load functions can be detected.  This is much harder
in other archives.

Robert Ramey

"Christoph" <christoph.duelli <at> gmx.de> wrote in message 
news:fgcl3s$2fp$1 <at> ger.gmane.org...
I am experimenting with Boost.Serialization.
I tried to de-serialize a (binary) file written for a *different* class.
Obviously, this can not work.

However, there is not thrown an exception.
Question: (How) can I determine that the reading failed?
(In case of corrupted or non-matching archives.)

(I have attached a small demo.)

Best regards
Christoph

--------------------------------------------------------------------------------

> _______________________________________________
> Boost-users mailing list
> Boost-users <at> lists.boost.org
(Continue reading)

Robert Ramey | 1 Nov 17:37

Re: Boost.Serialization: error checking

Personally I would not use this approach.  To some extent
it can be seen as a matter of taste.  I prefer to spend effort
in finding, fixing, and preventing the source of the problem.

So if there is an easy mistake to make which makes archives
which cannot be loaded, I would be interested in hearing
about it.  I have considered making and "archive adaptor"
which would add redundent data to an archive to detect
save/load mismatches, editing of archive data outside
the serialization system and things like that.  Also we
might add and "archive class" key to the header so
that an attempt to read the archive with the wrong
code would be detected.  Of course, if this is a big
problem at your installation, it would be easy to add
a string at the start of each archive which specified
the class name of the archive creating it and
checks the class name of any archive being loaded.

Just some ideas for cases where it might be difficult
to guarentee that the loading archive class isn't
compatible with the saving archive class.

But I have to confess that I don't see this as a big problem.
And I don't think its something that the library can solve.

Robert Ramey

"Tim St. Clair" <timothysc <at> gmail.com> wrote in message 
news:ef85fd8f0711010711v55768a02s97411302423a2b2f <at> mail.gmail.com...
> I've encountered the same issue(s) in the past where signals will be
(Continue reading)

Christoph | 1 Nov 17:19
Picon
Picon

Re: Boost.Serialization: error checking

Robert Ramey wrote:

> binary archives are implemented to be as fast as possible.
> There isn't any checking which would impact erformance.
> 
> One thing that I've found useful is to check the serialization
> using xml archives.  Since these have "end" tags, mis-matched
> saved/load functions can be detected.  This is much harder
> in other archives.
Yes, that seems to be a good idea. Thank you.
Stefan Kok | 2 Nov 06:40
Picon

C++ & Enterprise Solutions

Dear List

If this is not the correct list to post to. Then please forgive my
ignorance.

I have been admiring the work of Boost and its contributors for some
time now. My questions / comments :

1) Would their be any benefit to the community, developing a
specification for C++ similar to SUN's J2EE and JEE specification ?

I do realize this would require a mammoth effort as well as commitment
in terms of resources.  

2) Is it possible to establish such a project under the open source
banner ?

Given the commitment and resources required.

3) Would this be reinventing the wheel ?

I know SUN & Java got there first (the J2EE thing). But C++ does have
some very powerful features which makes it unique in some ways,
templates for one. 

Thank you in advance.

Stefan.
LoadCom | 2 Nov 08:54
Favicon

[STL] An question about list::iterator

Hello,

It's a question that perhaps has little to do with boost, but I
guess the boosters must be able to help me.  :-)   

The question is: I want to have an iterator of a std::list type
that denotes a NULL iterator, which means the iterator points to
nothing, and is obviously different from list::end(), which points
to the pass-the-end of a list.

I'm using the following code:

list<int> alist;
alist.push_back(1);

list<int>::iterator it_NULL;	// denotes a NULL iterator
list<int>::iterator it_beg = alist.begin();

std::cout << boolalpha;
std::cout << "(it_NULL == it_beg) " << (it_NULL == it_beg) << endl;

I got correct result under VS 2003, but under VS2005, I got an 
runtime error. The cause of the error seems to be I could not compare
2 iterators that don't belong to the same container.

I have looked up the C++ 98 standard, and there seems not to be such a 
restriction for 2 iterators of the same type in comparasion should 
belong to a same container.

What's wrong? Or any other alternative solution available?
(Continue reading)

Benoi^t Dagon | 2 Nov 09:32
Picon
Picon
Favicon

Re: [STL] An question about list::iterator

Hi,

I'm not sure to understand the goal of your test iterator comparison but
if it's to test a list emptiness why not just using alist.empty()?

In my understanding a list iterator is not designed to be NULL. But the
object it points to could be null and thus you should better test the
object than the iterator.

Hope it helps,
~Benoi^t

LoadCom wrote:
> Hello,
> 
> It's a question that perhaps has little to do with boost, but I
> guess the boosters must be able to help me.  :-)   
> 
> The question is: I want to have an iterator of a std::list type
> that denotes a NULL iterator, which means the iterator points to
> nothing, and is obviously different from list::end(), which points
> to the pass-the-end of a list.
> 
> I'm using the following code:
> 
> list<int> alist;
> alist.push_back(1);
> 
> list<int>::iterator it_NULL;	// denotes a NULL iterator
> list<int>::iterator it_beg = alist.begin();
(Continue reading)

question boost | 2 Nov 10:39
Picon

Is anyone going to tell me the way to set the WINDOWS variables for BOOST?

Hi,
 
in the boost directory named "boost_1_33_1"  I 've downloaded, which directories do I have to indicate to the variables INCLUDE and  LIB in order to set them?
 
THANK YOU VERY MUCH,
 
David
 
 

Besoin d'un e-mail ? Créez gratuitement un compte Windows Live Hotmail, plus sûr, plus simple et plus complet ! Windows Live Hotmail
_______________________________________________
Boost-users mailing list
Boost-users <at> lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Gmane