-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPythonBuff.h
More file actions
65 lines (47 loc) · 1.18 KB
/
PythonBuff.h
File metadata and controls
65 lines (47 loc) · 1.18 KB
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
// Copyright © 2023 CCP ehf.
/*
*************************************************************************
PythonBuff.h
Project: EVE Server Database Access
Description:
A simple SequentialStream wrapper around a pythonbuffer thing.
It borrows the reference to its python object: It is run in a thread
and addrefing and decrefing is therefore not safe. However, the caller
owns a reference so this is ok.
Dependencies:
Python
*************************************************************************
*/
#pragma once
#ifndef _PYTHONBUFF_H_
#define _PYTHONBUFF_H_
class PythonBuff : public ISequentialStream
{
public:
PythonBuff(PyObject *);
~PythonBuff();
bool Valid() const
{
return m_buff;
}
size_t GetLength() const
{
return m_size;
}
HRESULT WINAPI Read(void* pv, ULONG cb, ULONG* got);
HRESULT WINAPI Write(const void* pv, ULONG cb, ULONG* written) {return E_NOTIMPL;}
HRESULT WINAPI QueryInterface(REFIID riid, void** ppv);
ULONG WINAPI AddRef() {return ++m_refcount;}
ULONG WINAPI Release()
{
if( --m_refcount == 0 )
delete this;
return m_refcount;
}
private:
char* m_buff;
size_t m_size;
size_t m_pos;
int m_refcount;
};
#endif