My favorites | Sign in
Project Home Downloads Wiki Issues Source
Repository:
Checkout   Browse   Changes   Clones  
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

#ifndef _PYODBCSQLWCHAR_H
#define _PYODBCSQLWCHAR_H

class SQLWChar
{
// An object designed to convert strings and Unicode objects to SQLWCHAR, hold the temporary buffer, and delete it
// in the destructor.

private:
SQLWCHAR* pch;
Py_ssize_t len;
bool owns_memory;

public:
SQLWChar()
{
pch = 0;
len = 0;
owns_memory = false;
}

SQLWChar(PyObject* o);

bool Convert(PyObject* o);

void Free();

~SQLWChar()
{
Free();
}

void dump();

operator SQLWCHAR*() { return pch; }
operator const SQLWCHAR*() const { return pch; }
operator bool() const { return pch != 0; }
Py_ssize_t size() const { return len; }

SQLWCHAR* operator[] (Py_ssize_t i)
{
I(i <= len); // we'll allow access to the NULL?
return &pch[i];
}

const SQLWCHAR* operator[] (Py_ssize_t i) const
{
I(i <= len); // we'll allow access to the NULL?
return &pch[i];
}
};

// The size of a SQLWCHAR.
extern Py_ssize_t SQLWCHAR_SIZE;

// Allocate a new Unicode object, initialized from the given SQLWCHAR string.
PyObject* PyUnicode_FromSQLWCHAR(const SQLWCHAR* sz, Py_ssize_t cch);

SQLWCHAR* SQLWCHAR_FromUnicode(const Py_UNICODE* pch, Py_ssize_t len);

#endif // _PYODBCSQLWCHAR_H

Change log

c278e74e4434 by Michael Kleehammer <mich...@kleehammer.com> on Nov 2, 2011   Diff
Single source base for Python 2 and 3
Go to: 
Sign in to write a code review

Older revisions

9dd144f9b648 by Michael Kleehammer <mich...@kleehammer.com> on Nov 23, 2010   Diff
Added pyodbc.conf for preprocessor-
time access to sizeof(SQLWCHAR)
a64f28489668 by Michael Kleehammer <mkleeham...@cloak.(none)> on Sep 6, 2010   Diff
More Unicode fixes.  Updated mysql
tests.
523aed0ec8ad by Michael Kleehammer <mich...@kleehammer.com> on Sep 4, 2010   Diff
 Issue 91 : decimal fix; Completely
reworked parameters; added leakcheck

Fixed  issue 91  - handling of decimals
was incorrect (off by 1).  Added lots
...
All revisions of this file

File info

Size: 1313 bytes, 62 lines
Powered by Google Project Hosting