]> git.saurik.com Git - wxWidgets.git/blob - src/common/ipcbase.cpp
Applied patch [ 632115 ] Fixed internationalization on tooltips
[wxWidgets.git] / src / common / ipcbase.cpp
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$
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "ipcbase.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WX_PRECOMP
24 #include "wx/defs.h"
25 #endif
26
27 #include "wx/ipcbase.h"
28
29 IMPLEMENT_CLASS(wxServerBase, wxObject)
30 IMPLEMENT_CLASS(wxClientBase, wxObject)
31 IMPLEMENT_CLASS(wxConnectionBase, wxObject)
32
33 wxConnectionBase::wxConnectionBase(wxChar *buffer, int size)
34 : m_connected(TRUE),
35 m_buffer(buffer),
36 m_buffersize(size),
37 m_deletebufferwhendone(FALSE)
38 {
39 if ( buffer == (wxChar *)NULL )
40 { // behave like next constructor
41 m_buffersize = 0;
42 m_deletebufferwhendone = TRUE;
43 }
44 }
45
46 wxConnectionBase::wxConnectionBase()
47 : m_connected(TRUE),
48 m_buffer(NULL),
49 m_buffersize(0),
50 m_deletebufferwhendone(TRUE)
51 {
52 }
53
54 wxConnectionBase::wxConnectionBase(wxConnectionBase& copy)
55 : m_connected(copy.m_connected),
56 m_buffer(copy.m_buffer),
57 m_buffersize(copy.m_buffersize),
58 m_deletebufferwhendone(FALSE)
59
60 {
61 // copy constructor would require ref-counted pointer to buffer
62 wxFAIL_MSG( _T("Copy constructor of wxConnectionBase not implemented") );
63 }
64
65
66 wxConnectionBase::~wxConnectionBase(void)
67 {
68 if ( m_deletebufferwhendone && m_buffer )
69 delete m_buffer;
70 }
71
72 wxChar *wxConnectionBase::GetBufferAtLeast( size_t bytes )
73 {
74 if ( m_buffersize >= bytes )
75 return m_buffer;
76 else
77 { // need to resize buffer
78 if ( m_deletebufferwhendone )
79 { // we're in charge of buffer, increase it
80 if ( !m_buffer )
81 delete m_buffer;
82 m_buffer = new wxChar[bytes];
83 m_buffersize = bytes;
84 return m_buffer;
85 } // user-supplied buffer, fail
86 else
87 return NULL;
88 }
89 }
90