35 #ifndef PYTHONPP_OBJECT_H
36 #define PYTHONPP_OBJECT_H
46 #if PY_VERSION_HEX >= 0x02050000
154 operator PyObject* (void)
const
188 PyObject* obj = PyObject_GetAttrString(
Get(),
const_cast<char*
>(name.c_str()));
196 if(PyObject_SetAttrString (
Get(),
const_cast<char*
>(name.c_str()),
value.Get()) == -1) {
202 if(PyObject_DelAttrString (
Get(),
const_cast<char*
>(name.c_str())) == -1) {
208 return PyObject_HasAttrString (
Get(),
const_cast<char*
>(name.c_str())) != 0;
215 PyObject* obj = PyObject_GetItem(
Get(),
key.Get());
231 if(PyObject_DelItem (
Get(),
key.Get()) == -1) {
267 return PyObject_IsTrue(
result);
274 return PyObject_IsTrue(
result);
281 return PyObject_IsTrue(
result);
288 return PyObject_IsTrue(
result);
295 return PyObject_IsTrue(
result);
302 return PyObject_IsTrue(
result);
308 return PyNumber_Check (
Get()) != 0;
312 return PySequence_Check (
Get()) != 0;
316 return PyObject_IsTrue (
Get()) != 0;
363 return obj == Py_None;
369 return obj == Py_None;
414 if (
Get() != obj ) {
423 return PyType_Check (obj);
427 return PyType_CheckExact (obj);
434 return l.
Get() ==
r.Get();
441 PyObject* tmp_obj = PyNumber_Positive(
a.Get());
449 PyObject* tmp_obj = PyNumber_Negative(
a.Get());
458 PyObject* tmp_obj = PyNumber_Absolute(
a.Get());
466 inline std::pair<CObject, CObject> coerce(
const CObject&
a,
const CObject&
b)
472 if(PyNumber_Coerce(&p1, &p2) == -1) {
473 throw CArithmeticError(
"PyNumber_Coerce");
481 PyObject* tmp_obj = PyNumber_Add(
a.Get(),
b.Get());
490 PyObject* tmp_obj = PyNumber_Subtract(
a.Get(),
b.Get());
499 PyObject* tmp_obj = PyNumber_Multiply(
a.Get(),
b.Get());
508 PyObject* tmp_obj = PyNumber_TrueDivide(
a.Get(),
b.Get());
517 PyObject* tmp_obj = PyNumber_Remainder(
a.Get(),
b.Get());
530 PyObject* obj = PyObject_Type (
Get());
static bool HasExactSameType(PyObject *obj)
static bool HasSameType(PyObject *obj)
CNone & operator=(const CNone &obj)
CNone(const CObject &obj)
void SetAttr(const std::string &name, const CObject &value)
bool IsObjectType(const CType &t) const
void DelItem(const CObject &key)
CObject(void)
* Generic operations on objects */
CType GetType(void) const
void Set(PyObject *obj, EOwnership ownership=eAcquireOwnership)
Not exception-safe this time.
CObject(PyObject *obj, EOwnership ownership=eAcquireOwnership)
CObject & operator=(const CObject &obj)
PyTypeObject * GetObjType(void) const
bool operator<(const CObject &obj) const
PyObject * Get(void) const
CObject GetAttr(const std::string &name) const
bool operator>(const CObject &obj) const
bool IsNumeric(void) const
bool operator>=(const CObject &obj) const
CObject(const CObject &obj)
long GetHashValue(void) const
void DelAttr(const std::string &name)
CObject GetItem(const CObject &key) const
bool HasAttr(const std::string &name) const
bool operator!=(const CObject &obj) const
bool operator==(const CObject &obj) const
bool operator<=(const CObject &obj) const
bool IsSequence(void) const
CType(PyObject *obj, EOwnership ownership=eAcquireOwnership)
static bool HasSameType(PyObject *obj)
CType & operator=(const CObject &obj)
static bool HasExactSameType(PyObject *obj)
CType(const CObject &obj)
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
const struct ncbi::grid::netcache::search::fields::KEY key
CObject operator+(const CObject &a)
CObject operator%(const CObject &a, const CObject &b)
PyObject * DecRefCount(PyObject *obj)
CObject operator*(const CObject &a, const CObject &b)
CObject abs(const CObject &a)
PyObject * IncRefCount(PyObject *obj)
bool operator==(const CObject &l, const CExtType &r)
CObject operator-(const CObject &a)
CObject operator/(const CObject &a, const CObject &b)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)