1// PyRowRef.h -- 2// $Id: PyRowRef.h 1230 2007-03-09 15:58:53Z jcw $ 3// This is part of MetaKit, see http://www.equi4.com/metakit.html 4// Copyright (C) 1999-2004 Gordon McMillan and Jean-Claude Wippler. 5// 6// RowRef class header 7 8#if !defined INCLUDE_PYROWREF_H 9#define INCLUDE_PYROWREF_H 10 11#include <mk4.h> 12#include "PyHead.h" 13#include <PWOSequence.h> 14#include "PyView.h" 15#include "PyProperty.h" 16 17#define PyRowRef_Check(ob) ((ob)->ob_type == &PyRowReftype) 18#define PyRORowRef_Check(ob) ((ob)->ob_type == &PyRORowReftype) 19#define PyGenericRowRef_Check(ob) (PyRowRef_Check(ob) || PyRORowRef_Check(ob)) 20 21extern PyTypeObject PyRowReftype; 22extern PyTypeObject PyRORowReftype; 23 24class PyRowRef: public PyHead, public c4_RowRef { 25 public: 26 //PyRowRef(); 27 PyRowRef(const c4_RowRef &o, int immutable = 0); 28 //PyRowRef(c4_Row row); 29 ~PyRowRef() { 30 c4_Cursor c = &(*(c4_RowRef*)this); 31 c._seq->DecRef(); 32 } 33 PyProperty *getProperty(char *nm) { 34 c4_View cntr = Container(); 35 int ndx = cntr.FindPropIndexByName(nm); 36 if (ndx > - 1) { 37 return new PyProperty(cntr.NthProperty(ndx)); 38 } 39 return 0; 40 }; 41 42 PyObject *getPropertyValue(char *nm) { 43 PyProperty *prop = getProperty(nm); 44 if (prop) { 45 PyObject *result = asPython(*prop); 46 Py_DECREF(prop); 47 return result; 48 } 49 return 0; 50 }; 51 52 static void setFromPython(const c4_RowRef &row, const c4_Property &prop, 53 PyObject *val); 54 static void setDefault(const c4_RowRef &row, const c4_Property &prop); 55 PyObject *asPython(const c4_Property &prop); 56}; 57 58#endif 59