]> git.saurik.com Git - wxWidgets.git/blame - include/wx/buffer.h
For non-Unicode added #include <ctype.h> and <string.h> to avoid some missing
[wxWidgets.git] / include / wx / buffer.h
CommitLineData
14971e5b
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: buffer.h
3// Purpose: auto buffer classes: buffers which automatically free memory
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 12.04.99
7// RCS-ID: $Id$
8// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9// Licence: wxWindows license
10///////////////////////////////////////////////////////////////////////////////
11
12// these classes are for private use only for now, they're not documented
13
14#ifndef _WX_BUFFER_H
15#define _WX_BUFFER_H
16
17#include <string.h> // strdup()
18#include <wchar.h> // wcsdup()
19
20// ----------------------------------------------------------------------------
21// Special classes for (wide) character strings: they use malloc/free instead
22// of new/delete
23// ----------------------------------------------------------------------------
24
25class wxCharBuffer
26{
27public:
28 wxCharBuffer(const char *str)
29 {
30 wxASSERT_MSG( str, "NULL string in wxCharBuffer" );
31
32 m_str = str ? strdup(str) : (char *)NULL;
33 }
34
35 // no need to check for NULL, free() does it
36 ~wxCharBuffer() { free(m_str); }
37
38 operator const char *() const { return m_str; }
39
40private:
41 char *m_str;
42};
43
44class wxWCharBuffer
45{
46public:
47 wxWCharBuffer(const wchar_t *wcs)
48 {
49 wxASSERT_MSG( wcs, "NULL string in wxWCharBuffer" );
50
51 m_wcs = wcs ? wcsdup(wcs) : (wchar_t *)NULL;
52 }
53
54 // no need to check for NULL, free() does it
55 ~wxWCharBuffer() { free(m_wcs); }
56
57 operator const wchar_t *() const { return m_wcs; }
58
59private:
60 wchar_t *m_wcs;
61};
62
63// ----------------------------------------------------------------------------
64// template class for any kind of data
65// ----------------------------------------------------------------------------
66
67// TODO
68
69#endif // _WX_BUFFER_H