]> git.saurik.com Git - wxWidgets.git/blame - src/common/ipcbase.cpp
fix undefined structs under 10.2 (tinderbox)
[wxWidgets.git] / src / common / ipcbase.cpp
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: ipcbase.cpp
3// Purpose: IPC base classes
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
55d99c7a 8// Copyright: (c) Julian Smart
7beb59f3 9// Licence: wxWindows licence
c801d85f
KB
10/////////////////////////////////////////////////////////////////////////////
11
c801d85f
KB
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
15#ifdef __BORLANDC__
16#pragma hdrstop
17#endif
18
19#ifndef WX_PRECOMP
20#include "wx/defs.h"
21#endif
22
23#include "wx/ipcbase.h"
24
c801d85f
KB
25IMPLEMENT_CLASS(wxServerBase, wxObject)
26IMPLEMENT_CLASS(wxClientBase, wxObject)
27IMPLEMENT_CLASS(wxConnectionBase, wxObject)
c801d85f 28
9d860992 29wxConnectionBase::wxConnectionBase(wxChar *buffer, int bytes)
7beb59f3 30 : m_connected(true),
b7282ad2 31 m_buffer(buffer),
9d860992 32 m_buffersize(bytes),
7beb59f3 33 m_deletebufferwhendone(false)
44379ce6
JS
34{
35 if ( buffer == (wxChar *)NULL )
36 { // behave like next constructor
37 m_buffersize = 0;
7beb59f3 38 m_deletebufferwhendone = true;
44379ce6
JS
39 }
40}
41
42wxConnectionBase::wxConnectionBase()
7beb59f3 43 : m_connected(true),
bbcd408a
JS
44 m_buffer(NULL),
45 m_buffersize(0),
7beb59f3 46 m_deletebufferwhendone(true)
44379ce6
JS
47{
48}
49
fbfb8bcc 50wxConnectionBase::wxConnectionBase(const wxConnectionBase& copy)
60431236
WS
51 : wxObject(),
52 m_connected(copy.m_connected),
bbcd408a
JS
53 m_buffer(copy.m_buffer),
54 m_buffersize(copy.m_buffersize),
7beb59f3 55 m_deletebufferwhendone(false)
bbcd408a 56
44379ce6
JS
57{
58 // copy constructor would require ref-counted pointer to buffer
59 wxFAIL_MSG( _T("Copy constructor of wxConnectionBase not implemented") );
60}
61
62
63wxConnectionBase::~wxConnectionBase(void)
64{
65 if ( m_deletebufferwhendone && m_buffer )
66 delete m_buffer;
67}
68
69wxChar *wxConnectionBase::GetBufferAtLeast( size_t bytes )
70{
71 if ( m_buffersize >= bytes )
72 return m_buffer;
73 else
74 { // need to resize buffer
75 if ( m_deletebufferwhendone )
76 { // we're in charge of buffer, increase it
01d0d0e5 77 if ( m_buffer )
44379ce6 78 delete m_buffer;
9d860992
JS
79 // the argument specifies **byte size**, but m_buffer is of type
80 // wxChar. Under unicode: sizeof(wxChar) > 1, so the buffer size is
81 // bytes / sizeof(wxChar) rounded upwards.
82 m_buffer = new wxChar[(bytes + sizeof(wxChar) - 1) / sizeof(wxChar)];
44379ce6
JS
83 m_buffersize = bytes;
84 return m_buffer;
85 } // user-supplied buffer, fail
86 else
87 return NULL;
88 }
89}
c801d85f 90