File: plmemsink.cpp

package info (click to toggle)
paintlib 2.6.2-14
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 7,920 kB
  • ctags: 3,874
  • sloc: cpp: 25,209; sh: 10,605; ansic: 1,891; makefile: 120
file content (111 lines) | stat: -rw-r--r-- 2,471 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
|
|      $Id: plmemsink.cpp,v 1.7 2004/11/09 15:55:06 artcom Exp $
|      Memory "Data Sink" Class
|
|      This class uses memory as a destination for picture data.
|
|      Copyright (c) 1996-2002 Ulrich von Zadow
|
\--------------------------------------------------------------------
*/

#include "plmemsink.h"
#include "plexcept.h"
#include "plpaintlibdefs.h"
#include "plexcept.h"

PLMemSink::PLMemSink ()
  : PLDataSink(),    
    m_pDataBuf (NULL)
{

}

PLMemSink::~PLMemSink ()
{  
  Close();
}

int PLMemSink::Open (const char * pszFName, int MaxFileSize)
{
  if (m_pDataBuf = new PLBYTE [MaxFileSize])
  {
    PLDataSink::Open(pszFName, m_pDataBuf, MaxFileSize);
    return 0;
  }
  else
    return -1;
}

#ifdef _WIN32
int PLMemSink::OpenW (const wchar_t * pszwFName, int MaxFileSize)
{
  if (m_pDataBuf = new PLBYTE [MaxFileSize])
  {
    PLDataSink::OpenW(pszwFName, m_pDataBuf, MaxFileSize);
    return 0;
  }
  else
    return -1;
}
#endif

void PLMemSink::Close ()
{
  if (m_pDataBuf)
  {
    delete [] m_pDataBuf;
    m_pDataBuf = NULL;
  }

  PLDataSink::Close();
}

PLBYTE* PLMemSink::GetBytes()
{
	if (m_pDataBuf)
		return m_pDataBuf;
	else
		throw PLTextException(PL_ERRINTERNAL, "Open was not called for CMemSink");
}


/*
/--------------------------------------------------------------------
|
|      $Log: plmemsink.cpp,v $
|      Revision 1.7  2004/11/09 15:55:06  artcom
|      changed #ifdef _WINDOWS to #ifdef _WIN32 (since this is a macro that actually is predefined on  win32 platforms)
|
|      Revision 1.6  2004/09/11 12:41:35  uzadow
|      removed plstdpch.h
|
|      Revision 1.5  2003/08/03 12:03:20  uzadow
|      Added unicode support; fixed some header includes.
|
|      Revision 1.4  2002/03/31 13:36:42  uzadow
|      Updated copyright.
|
|      Revision 1.3  2001/10/16 17:12:26  uzadow
|      Added support for resolution information (Luca Piergentili)
|
|      Revision 1.2  2001/10/06 22:03:26  uzadow
|      Added PL prefix to basic data types.
|
|      Revision 1.1  2001/09/16 19:03:22  uzadow
|      Added global name prefix PL, changed most filenames.
|
|      Revision 1.3  2001/02/04 14:31:52  uzadow
|      Member initialization list cleanup (Erik Hoffmann).
|
|      Revision 1.2  2001/01/21 14:28:21  uzadow
|      Changed array cleanup from delete to delete[].
|
|      Revision 1.1  2000/10/12 21:57:26  uzadow
|      no message
|
|
|
\--------------------------------------------------------------------
*/