/usr/include/libwildmagic/Wm5Stream.h is in libwildmagic-dev 5.13-1+b2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | // Geometric Tools, LLC
// Copyright (c) 1998-2014
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
// http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
//
// File Version: 5.0.1 (2010/10/01)
#ifndef WM5STREAM_H
#define WM5STREAM_H
#include "Wm5CoreLIB.h"
#include "Wm5BufferIO.h"
#include "Wm5InitTerm.h"
#include "Wm5SmartPointer.h"
namespace Wm5
{
class WM5_CORE_ITEM Stream
{
public:
// This function returns the number of bytes required to store a string.
// The string length is stored first, as an integer, followed by its
// characters. The string is padded with zeros so that the total storage
// uses a multiple of four bytes.
static int GetStreamingSize (const std::string& input);
protected:
// Abstract base class.
Stream ();
virtual ~Stream ();
};
}
//----------------------------------------------------------------------------
#define WM5_DECLARE_STREAM(classname) \
public: \
static bool RegisterFactory (); \
static void InitializeFactory (); \
static Object* Factory (InStream&); \
virtual void Load (InStream&); \
virtual void Link (InStream&); \
virtual void PostLink (); \
virtual bool Register (OutStream&) const; \
virtual void Save (OutStream&) const; \
virtual int GetStreamingSize () const; \
protected: \
friend class Memory; \
classname (LoadConstructor value); \
private: \
static bool msStreamRegistered
//----------------------------------------------------------------------------
#define WM5_IMPLEMENT_STREAM(classname) \
bool classname::msStreamRegistered = false; \
\
bool classname::RegisterFactory () \
{ \
if (!msStreamRegistered) \
{ \
InitTerm::AddInitializer(classname::InitializeFactory); \
msStreamRegistered = true; \
} \
return msStreamRegistered; \
} \
\
void classname::InitializeFactory () \
{ \
if (!msFactories) \
{ \
msFactories = new0 Object::FactoryMap(); \
} \
msFactories->insert(std::make_pair(TYPE.GetName(), Factory)); \
}
//----------------------------------------------------------------------------
#define WM5_IMPLEMENT_DEFAULT_STREAM(baseclassname, classname) \
classname::classname (LoadConstructor value) \
: \
baseclassname(value) \
{ \
} \
\
void classname::Load (InStream& source) \
{ \
WM5_BEGIN_DEBUG_STREAM_LOAD(source); \
baseclassname::Load(source); \
WM5_END_DEBUG_STREAM_LOAD(baseclassname, source); \
} \
\
void classname::Link (InStream& source) \
{ \
baseclassname::Link(source); \
} \
void classname::PostLink () \
{ \
baseclassname::PostLink(); \
} \
\
bool classname::Register (OutStream& target) const \
{ \
return baseclassname::Register(target); \
} \
\
void classname::Save (OutStream& target) const \
{ \
WM5_BEGIN_DEBUG_STREAM_SAVE(target); \
baseclassname::Save(target); \
WM5_END_DEBUG_STREAM_SAVE(baseclassname, target); \
} \
\
int classname::GetStreamingSize () const \
{ \
return baseclassname::GetStreamingSize(); \
}
//----------------------------------------------------------------------------
#define WM5_IMPLEMENT_ABSTRACT_FACTORY(classname) \
Object* classname::Factory (InStream&) \
{ \
assertion(false, "Abstract classes have no factory.\n"); \
return 0; \
}
//----------------------------------------------------------------------------
#define WM5_IMPLEMENT_FACTORY(classname) \
Object* classname::Factory (InStream& source) \
{ \
classname* object = new0 classname(LC_LOADER); \
object->Load(source); \
return object; \
}
//----------------------------------------------------------------------------
#define WM5_REGISTER_STREAM(classname) \
static bool gsStreamRegistered_##classname = classname::RegisterFactory()
//----------------------------------------------------------------------------
#ifdef WM5_USE_ASSERT
#define WM5_BEGIN_DEBUG_STREAM_LOAD(source) \
int beginLoad_ = source.GetBytesRead()
#else
#define WM5_BEGIN_DEBUG_STREAM_LOAD(source)
#endif
//----------------------------------------------------------------------------
#ifdef WM5_USE_ASSERT
#define WM5_END_DEBUG_STREAM_LOAD(classname,source) \
int endLoad_ = source.GetBytesRead(); \
int usedLoad_ = endLoad_ - beginLoad_ + \
Stream::GetStreamingSize(GetRttiType().GetName()); \
int usedReported_ = classname::GetStreamingSize(); \
assertion(usedLoad_ == usedReported_, \
"Mismatched bytes during Load: loaded = %d, required = %d\n", \
usedLoad_, usedReported_)
#else
#define WM5_END_DEBUG_STREAM_LOAD(classname,source)
#endif
//----------------------------------------------------------------------------
#ifdef WM5_USE_ASSERT
#define WM5_BEGIN_DEBUG_STREAM_SAVE(target) \
int beginSave_ = target.GetBytesWritten()
#else
#define WM5_BEGIN_DEBUG_STREAM_SAVE(target)
#endif
//----------------------------------------------------------------------------
#ifdef WM5_USE_ASSERT
#define WM5_END_DEBUG_STREAM_SAVE(classname,target) \
int endSave_ = target.GetBytesWritten(); \
int usedSave_ = endSave_ - beginSave_; \
int usedReported_ = classname::GetStreamingSize(); \
assertion(usedSave_ == usedReported_, \
"Mismatched bytes during Save: saved = %d, required = %d\n", \
usedSave_, usedReported_)
#else
#define WM5_END_DEBUG_STREAM_SAVE(classname,target)
#endif
//----------------------------------------------------------------------------
// The WM5_POINTERSIZE macro is used by the streaming system. A unique ID is
// an unsigned int written to 4 bytes on disk.
#define WM5_POINTERSIZE(value) 4
//----------------------------------------------------------------------------
// The WM5_BOOLSIZE macro is used by the streaming system. A bool is written
// to 4 bytes on disk.
#define WM5_BOOLSIZE(value) 4
//----------------------------------------------------------------------------
// The WM5_ENUMSIZE macro is used by the streaming system. An enum is written
// to 4 bytes on disk.
#define WM5_ENUMSIZE(value) 4
//----------------------------------------------------------------------------
#define WM5_STRINGSIZE(value) Stream::GetStreamingSize(value)
//----------------------------------------------------------------------------
#endif
|