35 #ifndef PYTHONPP_PDT_H
36 #define PYTHONPP_PDT_H
79 PyObject* tmp_obj = PyBool_FromLong(
value);
100 if (
Get() != obj ) {
113 return Get() == Py_True;
119 return PyBool_Check (obj);
123 return PyBool_Check (obj);
127 #if PY_MAJOR_VERSION < 3
144 PyObject* tmp_obj = PyNumber_Int(obj);
167 if (
this != &obj ) {
168 PyObject* tmp_obj = PyNumber_Int(obj);
178 if (
Get() != obj ) {
179 PyObject* tmp_obj = PyNumber_Int(obj);
200 operator long()
const
202 return PyInt_AsLong(
Get());
208 return PyInt_Check (obj);
212 return PyInt_CheckExact (obj);
246 PyObject* tmp_obj = PyNumber_Long(obj);
256 #if PY_MAJOR_VERSION < 3
296 if (
this != &obj ) {
297 PyObject* tmp_obj = PyNumber_Long(obj);
307 if (
Get() != obj ) {
308 PyObject* tmp_obj = PyNumber_Long(obj);
316 #if PY_MAJOR_VERSION < 3
362 #if PY_MAJOR_VERSION >= 3
365 return _PyLong_AsInt(
Get());
367 operator unsigned int()
const
369 return PyLong_AsUnsignedLong(
Get());
372 operator long()
const
374 return PyLong_AsLong(
Get());
376 operator unsigned long()
const
378 return PyLong_AsUnsignedLong(
Get());
380 operator long long()
const
382 return PyLong_AsLongLong(
Get());
384 operator unsigned long long()
const
386 return PyLong_AsUnsignedLongLong(
Get());
388 operator double()
const
390 return PyLong_AsDouble(
Get());
396 return PyLong_Check (obj);
400 return PyLong_CheckExact (obj);
404 #if PY_MAJOR_VERSION >= 3
449 PyObject* tmp_obj = PyNumber_Float(obj);
468 if (
this != &obj ) {
469 PyObject* tmp_obj = PyNumber_Float(obj);
479 if (
Get() != obj ) {
480 PyObject* tmp_obj = PyNumber_Float(obj);
496 operator double()
const
498 return PyFloat_AsDouble(
Get());
504 return PyFloat_Check (obj);
508 return PyFloat_CheckExact (obj);
553 if (
this != &obj ) {
563 if (
Get() != obj ) {
579 operator double()
const
581 return PyFloat_AsDouble(
Get());
587 return PyComplex_RealAsDouble(
Get());
591 return PyComplex_ImagAsDouble(
Get());
597 return PyComplex_Check (obj);
601 return PyComplex_CheckExact (obj);
703 #if PY_MAJOR_VERSION >= 3
745 if (
this != &obj ) {
755 if (
Get() != obj ) {
765 #if PY_MAJOR_VERSION < 3
768 basic_string<Py_UNICODE> str_uni(CUtf8::AsBasicString<Py_UNICODE>(
str));
769 #if PY_MAJOR_VERSION >= 3
770 Set(PyUnicode_FromWideChar(str_uni.data(), str_uni.size()),
775 #if PY_MAJOR_VERSION < 3
791 if ( PyUnicode_Check(
Get()) ) {
792 #if PY_VERSION_HEX >= 0x03030000
793 return static_cast<size_t>( PyUnicode_GET_LENGTH(
Get() ) );
795 return static_cast<size_t>( PyUnicode_GET_SIZE(
Get() ) );
798 #if PY_MAJOR_VERSION >= 3
799 return static_cast<size_t>( PyBytes_Size (
Get() ) );
801 return static_cast<size_t>( PyString_Size (
Get() ) );
812 if( PyUnicode_Check(
Get()) ) {
813 #if PY_VERSION_HEX >= 0x03030000
815 auto utf = PyUnicode_AsUTF8AndSize(
Get(), &
size);
819 PyUnicode_AS_UNICODE(
Get() ),
820 static_cast<size_t>( PyUnicode_GET_SIZE(
Get() ) ) );
823 #if PY_MAJOR_VERSION >= 3
825 static_cast<size_t>(PyBytes_Size(
Get())));
827 return string( PyString_AsString(
Get() ),
static_cast<size_t>( PyString_Size(
Get() ) ) );
835 #if PY_MAJOR_VERSION >= 3
836 return PyUnicode_CheckExact(obj) || PyBytes_CheckExact(obj);
838 return PyString_CheckExact(obj) || PyUnicode_CheckExact(obj);
843 #if PY_MAJOR_VERSION >= 3
844 return PyUnicode_Check(obj) || PyBytes_Check(obj);
846 return PyString_Check(obj) || PyUnicode_Check(obj);
856 #if PY_MAJOR_VERSION >= 3
914 #if PY_MAJOR_VERSION >= 3
917 Set(PyString_FromStringAndSize(
str.data(),
str.size()),
930 #if PY_MAJOR_VERSION >= 3
931 return static_cast<size_t>(PyBytes_Size(
Get()));
933 return static_cast<size_t>(PyString_Size(
Get()));
943 #if PY_MAJOR_VERSION >= 3
945 static_cast<size_t>(PyBytes_Size(
Get())));
948 static_cast<size_t>(PyString_Size(
Get())));
955 #if PY_MAJOR_VERSION >= 3
956 return PyBytes_CheckExact(obj);
958 return PyString_CheckExact(obj);
963 #if PY_MAJOR_VERSION >= 3
964 return PyBytes_Check(obj);
966 return PyString_Check(obj);
995 static bool HasExactSameType(PyObject* obj)
997 return PyFile_CheckExact(obj);
999 static bool HasSameType(PyObject* obj)
1001 return PyFile_Check(obj);
1009 PyObject* tmp_obj = PyNumber_Add(
a.Get(),
CInt(j).
Get());
1017 PyObject* tmp_obj = PyNumber_Add(
a.Get(),
CFloat(v).
Get());
1025 PyObject* tmp_obj = PyNumber_Add(
CInt(j).
Get(),
b.Get());
1033 PyObject* tmp_obj = PyNumber_Add(
CFloat(v).
Get(),
b.Get());
1041 PyObject* tmp_obj = PyNumber_Subtract(
a.Get(),
CInt(j).
Get());
1049 PyObject* tmp_obj = PyNumber_Subtract(
a.Get(),
CFloat(v).
Get());
1057 PyObject* tmp_obj = PyNumber_Subtract(
CInt(j).
Get(),
b.Get());
1065 PyObject* tmp_obj = PyNumber_Subtract(
CFloat(v).
Get(),
b.Get());
1073 PyObject* tmp_obj = PyNumber_Multiply(
a.Get(),
CInt(j).
Get());
1081 PyObject* tmp_obj = PyNumber_Multiply(
a.Get(),
CFloat(v).
Get());
1089 PyObject* tmp_obj = PyNumber_Multiply(
CInt(j).
Get(),
b.Get());
1097 PyObject* tmp_obj = PyNumber_Multiply(
CFloat(v).
Get(),
b.Get());
1105 PyObject* tmp_obj = PyNumber_TrueDivide(
a.Get(),
CInt(j).
Get());
1113 PyObject* tmp_obj = PyNumber_TrueDivide(
a.Get(),
CFloat(v).
Get());
1121 PyObject* tmp_obj = PyNumber_TrueDivide(
CInt(j).
Get(),
b.Get());
1129 PyObject* tmp_obj = PyNumber_TrueDivide(
CFloat(v).
Get(),
b.Get());
1137 PyObject* tmp_obj = PyNumber_Remainder(
a.Get(),
CInt(j).
Get());
1145 PyObject* tmp_obj = PyNumber_Remainder(
a.Get(),
CFloat(v).
Get());
1153 PyObject* tmp_obj = PyNumber_Remainder(
CInt(j).
Get(),
b.Get());
1161 PyObject* tmp_obj = PyNumber_Remainder(
CFloat(v).
Get(),
b.Get());
string AsStdSring(void) const
CBinary & operator=(const CObject &obj)
static bool HasExactSameType(PyObject *obj)
CBinary(const string &str)
CBinary(const CObject &obj)
CBinary(const CBinary &obj)
CBinary(PyObject *obj, EOwnership ownership=eAcquireOwnership)
CBinary(const char *str, size_t str_size)
size_t GetSize(void) const
static bool HasSameType(PyObject *obj)
static bool HasExactSameType(PyObject *obj)
static bool HasSameType(PyObject *obj)
CBool(const CObject &obj)
CBool & operator=(const CObject &obj)
CBool(PyObject *obj, EOwnership ownership=eAcquireOwnership)
CComplex(const CObject &obj)
CComplex(PyObject *obj, EOwnership ownership=eAcquireOwnership)
CComplex(double v=0.0, double w=0.0)
static bool HasExactSameType(PyObject *obj)
CComplex(const CComplex &obj)
static bool HasSameType(PyObject *obj)
CComplex & operator=(const CObject &obj)
CFloat(const CObject &obj)
CFloat(const CFloat &obj)
static bool HasSameType(PyObject *obj)
CFloat & operator=(const CObject &obj)
CFloat(PyObject *obj, EOwnership ownership=eAcquireOwnership)
static bool HasExactSameType(PyObject *obj)
static bool HasExactSameType(PyObject *obj)
CInt & operator=(const CObject &obj)
CInt(PyObject *obj, EOwnership ownership=eAcquireOwnership)
static bool HasSameType(PyObject *obj)
static bool HasExactSameType(PyObject *obj)
CLong(unsigned long long value)
CLong(const CObject &obj)
CLong(PyObject *obj, EOwnership ownership=eAcquireOwnership)
CLong(unsigned long value)
static bool HasSameType(PyObject *obj)
CLong & operator=(const CObject &obj)
CObject(void)
* Generic operations on objects */
void Set(PyObject *obj, EOwnership ownership=eAcquireOwnership)
Not exception-safe this time.
PyObject * Get(void) const
CString(const char *str, size_t str_size)
CString(const CObject &obj)
CString(const CString &obj)
CString(PyObject *obj, EOwnership ownership=eAcquireOwnership)
string AsStdSring(void) const
static bool HasSameType(PyObject *obj)
size_t GetSize(void) const
CString & operator=(const CObject &obj)
CString(const string &str)
static bool HasExactSameType(PyObject *obj)
The NCBI C++ standard methods for dealing with std::string.
static const char * str(char *buf, int n)
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static CStringUTF8 AsUTF8(const CTempString &src, EEncoding encoding, EValidate validate=eNoValidate)
Convert into UTF8 from a C/C++ string.
unsigned int
A callback function used to compare two keys in a database.
const TYPE & Get(const CNamedParameterList *param)
const struct ncbi::grid::netcache::search::fields::SIZE size
CObject operator+(const CObject &a)
CObject operator%(const CObject &a, const CObject &b)
CObject operator*(const CObject &a, const CObject &b)
CObject operator-(const CObject &a)
CObject operator/(const CObject &a, const CObject &b)
const GenericPointer< typename T::ValueType > T2 value
bool g_PythonStrDefToUnicode
Flag showing whether all pythonpp::CString objects should be created as Python unicode strings (TRUE ...