]> git.saurik.com Git - wxWidgets.git/blame - src/common/ipcbase.cpp
don't do anything before including the PCH header
[wxWidgets.git] / src / common / ipcbase.cpp
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
8898456d 2// Name: src/common/ipcbase.cpp
c801d85f
KB
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__
8898456d 16 #pragma hdrstop
c801d85f
KB
17#endif
18
19#ifndef WX_PRECOMP
c801d85f
KB
20#endif
21
22#include "wx/ipcbase.h"
23
c801d85f
KB
24IMPLEMENT_CLASS(wxServerBase, wxObject)
25IMPLEMENT_CLASS(wxClientBase, wxObject)
26IMPLEMENT_CLASS(wxConnectionBase, wxObject)
c801d85f 27
9d860992 28wxConnectionBase::wxConnectionBase(wxChar *buffer, int bytes)
7beb59f3 29 : m_connected(true),
b7282ad2 30 m_buffer(buffer),
9d860992 31 m_buffersize(bytes),
7beb59f3 32 m_deletebufferwhendone(false)
44379ce6
JS
33{
34 if ( buffer == (wxChar *)NULL )
35 { // behave like next constructor
36 m_buffersize = 0;
7beb59f3 37 m_deletebufferwhendone = true;
44379ce6
JS
38 }
39}
40
41wxConnectionBase::wxConnectionBase()
7beb59f3 42 : m_connected(true),
bbcd408a
JS
43 m_buffer(NULL),
44 m_buffersize(0),
7beb59f3 45 m_deletebufferwhendone(true)
44379ce6
JS
46{
47}
48
fbfb8bcc 49wxConnectionBase::wxConnectionBase(const wxConnectionBase& copy)
60431236
WS
50 : wxObject(),
51 m_connected(copy.m_connected),
bbcd408a
JS
52 m_buffer(copy.m_buffer),
53 m_buffersize(copy.m_buffersize),
7beb59f3 54 m_deletebufferwhendone(false)
bbcd408a 55
44379ce6
JS
56{
57 // copy constructor would require ref-counted pointer to buffer
58 wxFAIL_MSG( _T("Copy constructor of wxConnectionBase not implemented") );
59}
60
61
62wxConnectionBase::~wxConnectionBase(void)
63{
64 if ( m_deletebufferwhendone && m_buffer )
65 delete m_buffer;
66}
67
68wxChar *wxConnectionBase::GetBufferAtLeast( size_t bytes )
69{
70 if ( m_buffersize >= bytes )
71 return m_buffer;
72 else
73 { // need to resize buffer
74 if ( m_deletebufferwhendone )
75 { // we're in charge of buffer, increase it
01d0d0e5 76 if ( m_buffer )
44379ce6 77 delete m_buffer;
9d860992
JS
78 // the argument specifies **byte size**, but m_buffer is of type
79 // wxChar. Under unicode: sizeof(wxChar) > 1, so the buffer size is
80 // bytes / sizeof(wxChar) rounded upwards.
81 m_buffer = new wxChar[(bytes + sizeof(wxChar) - 1) / sizeof(wxChar)];
44379ce6
JS
82 m_buffersize = bytes;
83 return m_buffer;
84 } // user-supplied buffer, fail
85 else
86 return NULL;
87 }
88}