5 * Created by Alyssa Milburn on Thu Jun 03 2004.
6 * Copyright (c) 2004 Alyssa Milburn. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
24 # define M_PI 3.14159265358979323846 /* pi */
30 #include <boost/shared_ptr.hpp>
31 #include <boost/format.hpp>
32 using boost::shared_ptr
;
34 #include "exceptions.h"
36 typedef std::vector
<unsigned char> bytestring_t
;
38 class assertFailure
: public creaturesException
{
40 assertFailure(const char *x
) throw() : creaturesException(x
) { }
43 #define caos_assert(x) if (!(x)) { throw caosException(boost::str(boost::format("%s thrown from %s:%d") % #x % __FILE__ % __LINE__)); }
44 #define ensure_assert(x) do {\
45 bool ensure__v = (x); \
47 assert(ensure__v && (x)); \
50 // Forward declarations so we can friend them later without pulling in
51 // huge system headers.
53 namespace serialization
{
58 #define SER_PROTO(friend, fname, c, const) \
59 template <class Archive> friend void fname(Archive &ar, const c & obj, const unsigned int version)
61 // put this in serializable classes, to befriend any serializers in use
62 #define FRIEND_SERIALIZE(c) \
63 friend class boost::serialization::access; \
64 SER_PROTO(friend, o_save, c, const); \
65 SER_PROTO(friend, o_load, c, ); \
66 SER_PROTO(friend, o_serialize, c, );