📄 occiobjects.h
字号:
template <class T>Ref<T>::Ref(const Connection *sessp, OCIRef *tref, bool copy) { objptr = (T*)0; rimplPtr = new RefImpl(sessp, tref, copy); }template <class T> Ref<T>::~Ref() { // if exception is thrown , destruction cannot be // complete , hence not thrown try { rimplPtr->unpin((PObject *)objptr); } catch (SQLException &) { } delete rimplPtr; } template <class T> bool Ref<T>::isNull() const { return (rimplPtr->isNull());} template <class T> Ref<T>& Ref<T>::operator=(const Ref<T> &src) { if (&src == this) return *this; else { objptr = (T *)rimplPtr->assignRef((PObject *)objptr, (PObject *)src.objptr, src.rimplPtr); return *this; }}template <class T> Ref<T>& Ref<T>::operator=(const T *obj) { if (objptr == obj) return *this; else objptr = (T *)rimplPtr->assignObj((PObject *)objptr, (PObject *)obj); return *this;} template <class T> T* Ref<T>::operator->() { if (objptr == NULL) objptr = (T *)(rimplPtr->pin()); return objptr;} template <class T> T* Ref<T>::ptr() { if (objptr == NULL) objptr = (T *)(rimplPtr->pin()); return objptr;}template <class T> T& Ref<T>::operator * () { if (objptr == NULL) objptr = (T *)(rimplPtr->pin()); return (T &)(*objptr);}template <class T>const T* Ref<T>::operator->() const{ if (objptr == NULL) { const T *temp = (const T *)(rimplPtr->pin()); return temp; } return ((const T *)objptr);}template <class T>const T* Ref<T>::ptr() const{ if (objptr == NULL) { const T *temp = (const T *)(rimplPtr->pin()); return temp; } return ((const T *)objptr);}template <class T>const T& Ref<T>::operator * () const{ if (objptr == NULL) { const T *temp = (const T *)(rimplPtr->pin()); return ((*temp)); } return (*objptr);}template <class T> void Ref<T>::markDelete () { rimplPtr->markDelete();}template <class T> void Ref<T>::unmarkDelete () { rimplPtr->unmarkDelete();}template <class T> void Ref<T>::clear () { rimplPtr->clear(); /* if obj ptr is not null, then object un pin and then nullify */ if (objptr) rimplPtr->unpin((PObject *)objptr); objptr = NULL;}template <class T> void Ref<T>::setPrefetch (const OCCI_STD_NAMESPACE::string &typeName,unsigned int depth) { rimplPtr->setPrefetch(typeName,depth);}template <class T> void Ref<T>::setPrefetch (unsigned int depth) { rimplPtr->setPrefetch(depth);} template <class T> void Ref<T>::setLock (LockOptions lckOption){ rimplPtr->setLock(lckOption);}template <class T> OCIRef* Ref<T>::getRef() const{ return (rimplPtr->getRef());}template<class T>const Connection* Ref<T>::getConnection () const { return (rimplPtr->getConnection());} template <class T> Ref<T>::operator RefAny () const{ if (isNull()) return RefAny(); return (RefAny(rimplPtr->getConnection(), rimplPtr->getRef())); }template <class T>bool Ref<T>::operator ==(const Ref<T> &ref) const{ return ( (*rimplPtr) == (*(ref.rimplPtr)) );} template <class T>bool Ref<T>::operator !=(const Ref<T> &ref) const{ return ( !((*rimplPtr) == (*(ref.rimplPtr))) );}template <class T>bool Ref<T>::operator == (const RefAny & refAnyR) const{ return ( (*rimplPtr) == refAnyR );} template <class T>bool Ref<T>::operator != (const RefAny & refAnyR) const{ return ( !((*rimplPtr) == refAnyR ));} /************* get and set vector of anydata (templated functions) **********/ /*------------------- getVector for POBject----------------------------*//* NAME getVector - overloaded function. Retrieves the attribute in the current position as a vector of PObject PARAMETERS any - AnyData vect- reference to vector of PObject (OUT parameter). DESCRIPTION Retrieves the attribute in the current position as a vector of PObject The attribute at the current position should be a collection type (varray or nested table). The SQL type of the elements in the collection should be compatible with PObject RETURNS nothing NOTES compatible SQL types : user defined types (SQLT_NTY) etc.*/ template <class T> void getVector(AnyData &any, OCCI_STD_NAMESPACE::vector<T*> &vect) { OCCI_STD_NAMESPACE::vector< PObject *> vec_pobj; getVector( any, vec_pobj, OCCIPOBJECT); vect.clear(); int size= vec_pobj.size(); for( int i=0; i< size; i++) vect.push_back( (T*)vec_pobj[i] ); } template <class T> void getVector(AnyData &any, OCCI_STD_NAMESPACE::vector< Ref<T> > &vect) { OCCI_STD_NAMESPACE::vector< void *> vec_ref; getVector( any, vec_ref, OCCIREF); vect.clear(); const Connection *sess = any.getConnection(); for (int i=0; i<vec_ref.size(); i++) { if (vec_ref[i] == (OCIRef *)0) vect.push_back(Ref<T>()); // pushing a default-constructed Ref else vect.push_back(Ref<T>(sess, (OCIRef *)vec_ref[i], FALSE)); } } /*-----------------------setVector for PObject--------------------------*//* NAME setVector - overloaded function. sets the attribute in the current position of anydata with the vector elements. PARAMETERS none. DESCRIPTION sets the attribute in the current position in anydata with the vector elements. The attribute in the current position of anydata should be a collection type. If the collection type is a varray, the input vector size should be equal to the size of the varray. Also the SQL type of the collection's elements should be compatible with PObject. RETURNS nothing. NOTES compatible SQL types : SQLT_NTY (user defined types).*/ template <class T> void setVector(AnyData &any, const OCCI_STD_NAMESPACE::vector<T*> &vect) { OCCI_STD_NAMESPACE::vector< PObject *> vec_pobj; int size= vect.size(); for( int i=0; i< size; i++) vec_pobj.push_back( vect[i] ); setVector( any, vec_pobj); } template <class T> void setVector(AnyData &any, const OCCI_STD_NAMESPACE::vector< Ref<T> > &vect) { OCCI_STD_NAMESPACE::vector< void *> vec_ref; OCCI_STD_NAMESPACE::vector<OCIInd> vec_ind; int size= vect.size(); for( int i=0; i< size; i++) { vec_ref.push_back( vect[i].getRef() ); vec_ind.push_back(vect[i].isNull() ? OCI_IND_NULL : OCI_IND_NOTNULL); } setVector( any, vec_ref, vec_ind); } /*--------------------------------------------------------------------------- EXPORT FUNCTIONS ---------------------------------------------------------------------------*//*--------------------------------------------------------------------------- INTERNAL FUNCTIONS ---------------------------------------------------------------------------*/} /* end of namespace occi */} /* end of namespace oracle */#endif /* OCCIOBJECTS_ORACLE */#endif /* _olint */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -