1 : //==============================================================================
2 : // File <$/src/cpp/prod/protocol/cdr/cdr_memory.cpp>
3 : // This file is part of YaOrb : Yet Another Object Request Broker,
4 : // Copyright (c) 2000-2003, 2006, Marc Alff.
5 : //
6 : // This program is free software; you can redistribute it and/or
7 : // modify it under the terms of the GNU General Public License
8 : // as published by the Free Software Foundation; either version 2
9 : // of the License, or (at your option) any later version.
10 : //
11 : // This program is distributed in the hope that it will be useful,
12 : // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 : // GNU General Public License for more details.
15 : //
16 : // You should have received a copy of the GNU General Public License
17 : // along with this program; if not, write to the Free Software
18 : // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 : //
20 : //==============================================================================
21 :
22 : // Portability
23 : #include "yaorb/config.h"
24 : #include "src/cpp/prod/port/port_stdc.h"
25 :
26 : #include <yaorb/CORBA.h>
27 :
28 : #include "src/cpp/prod/tool/DEVELOPMENT.h"
29 : #include "src/cpp/prod/protocol/cdr/msg.h"
30 : #include "src/cpp/prod/protocol/cdr/cdr_memory.h"
31 : #include "src/cpp/prod/tool/Assert.h"
32 :
33 18 : CDRMemory::CDRMemory(CORBA::Octet *buffer, int size, YAORB::CDR_Op op)
34 18 : : YAORB::CDR(op), _buffer(buffer), _size(size)
35 : {
36 : ASSERT((op == YAORB::CDR_WRITE) || (buffer != NULL)) ;
37 : }
38 :
39 18 : CDRMemory::~CDRMemory()
40 : {
41 18 : if (_op == YAORB::CDR_WRITE)
42 : {
43 0 : delete [] _buffer ;
44 : }
45 18 : }
46 :
47 : void CDRMemory::GetBytes(CORBA::Octet *buffer, int size)
48 166 : throw (CORBA::SystemException)
49 : {
50 166 : if ((_position + size) > _size)
51 : {
52 0 : ThrowMarshal(this) ;
53 : }
54 :
55 166 : (void) memcpy(buffer, & _buffer[_position], size) ;
56 166 : _position += size ;
57 166 : }
58 :
59 : void CDRMemory::PutBytes(CORBA::Octet *buffer, int size)
60 0 : throw (CORBA::SystemException)
61 : {
62 0 : NON_DEV("cdr") ;
63 : }
64 :
|