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
|
// **********************************************************************
//
// Copyright (c) 2001
// MutableRealms, Inc.
// Huntsville, AL, USA
//
// All Rights Reserved
//
// **********************************************************************
#include <Ice/PicklerI.h>
#include <Ice/Stream.h>
#include <Ice/LocalException.h>
using namespace std;
using namespace Ice;
using namespace IceInternal;
void
Ice::PicklerI::pickle(const ObjectPtr& obj, std::ostream& out)
{
Stream s(_instance);
s.startWriteEncaps();
s.write(obj);
s.endWriteEncaps();
out.write(s.b.begin(), s.b.size());
if (!out)
{
throw SystemException(__FILE__, __LINE__);
}
}
ObjectPtr
Ice::PicklerI::unpickle(std::istream& in)
{
Stream s(_instance);
s.b.resize(5);
in.read(s.b.begin(), 5);
if (in.eof())
{
throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
}
if (!in)
{
throw SystemException(__FILE__, __LINE__);
}
s.i = s.b.begin();
Byte encVer;
s.read(encVer);
Int sz;
s.read(sz);
// Don't use s.b.resize() here, otherwise no size sanity checks
// will be done
s.resize(5 + sz);
in.read(s.b.begin() + 5, sz);
if (in.eof())
{
throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
}
if (!in)
{
throw SystemException(__FILE__, __LINE__);
}
s.i = s.b.begin();
s.startReadEncaps();
ObjectPtr obj;
s.read(obj, "::Ice::Object");
s.endReadEncaps();
if (!obj)
{
throw NoFactoryException(__FILE__, __LINE__);
}
return obj;
}
Ice::PicklerI::PicklerI(const InstancePtr& instance) :
_instance(instance)
{
}
|