blob: 06e26e687c311f03471056135db39921de0b421f (
plain)
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
|
// file : xsde/cxx/hybrid/cdr/istream.cxx
// author : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <xsde/cxx/hybrid/cdr/istream.hxx>
namespace xsde
{
namespace cxx
{
namespace hybrid
{
#ifdef XSDE_EXCEPTIONS
#ifdef XSDE_STL
struct str_guard
{
str_guard (char* s) : s_ (s) {}
~str_guard ()
{
#ifndef XSDE_CUSTOM_ALLOCATOR
delete[] s_;
#else
cxx::free (s_);
#endif
}
private:
char* s_;
};
void icdrstream::
operator>> (std::string& x)
{
char* v;
if (!cdr_.read_string (v))
throw cdr_exception ();
str_guard g (v);
x = v;
}
#else
void icdrstream::
operator>> (char*& x)
{
if (!cdr_.read_string (x))
throw cdr_exception ();
}
#endif
void icdrstream::
operator>> (buffer& x)
{
ACE_CDR::ULong n;
if (!cdr_.read_ulong (n))
throw cdr_exception ();
x.size (n);
if (!cdr_.read_octet_array (
reinterpret_cast<ACE_CDR::Octet*> (x.data ()), n))
throw cdr_exception ();
}
#else // XSDE_EXCEPTIONS
#ifdef XSDE_STL
bool icdrstream::
operator>> (std::string& x)
{
char* v;
if (!cdr_.read_string (v))
return false;
x = v;
#ifndef XSDE_CUSTOM_ALLOCATOR
delete[] v;
#else
cxx::free (v);
#endif
return true;
}
#else
bool icdrstream::
operator>> (char*& x)
{
return cdr_.read_string (x);
}
#endif
bool icdrstream::
operator>> (buffer& x)
{
ACE_CDR::ULong n;
if (!cdr_.read_ulong (n))
return false;
x.size (n);
return cdr_.read_octet_array (
reinterpret_cast<ACE_CDR::Octet*> (x.data ()), n);
}
#endif // XSDE_EXCEPTIONS
}
}
}
|