📄 occiobjects.h
字号:
template <class T>
void Ref<T>::unmarkDelete ()
{
rimplPtr->unmarkDelete();
}
template <class T>
void Ref<T>::setNull()
{
rimplPtr->setNull();
}
template <class T>
bool Ref<T>::isNull() const
{
return rimplPtr->isNull();
}
template <class T>
void Ref<T>::clear ()
{
rimplPtr->clear();
}
template <class T>
bool Ref<T>::isClear() const
{
return rimplPtr->isClear();
}
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 ));
}
template <class T>
void Ref<T>::destroy()
{
rimplPtr->destroy();
}
/*---------------------------------------------------------------------------
PROTOTYPES USED BY FUNCTION TEMPLATES
---------------------------------------------------------------------------*/
void getVectorOfOCIRefs( const AnyData &any,
OCCI_STD_NAMESPACE::vector<void *> &vect);
void getVectorOfPObjects( const AnyData &any,
OCCI_STD_NAMESPACE::vector< PObject* > &vect) ;
void setVectorOfOCIRefs( AnyData &any,
const OCCI_STD_NAMESPACE::vector<void *> &vect,
const OCCI_STD_NAMESPACE::vector< OCIInd> &vec_ind) ;
void setVectorOfPObjects( AnyData &any,
const OCCI_STD_NAMESPACE::vector< PObject* > &vect) ;
/*---------------------------------------------------------------------------
EXPORT 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.
*/
#ifdef WIN32COMMON
// and other platforms that do not support
// partial function template specialization
template <class T>
void getVector(const AnyData &any, OCCI_STD_NAMESPACE::vector<T> &vect)
{
OCCI_STD_NAMESPACE::vector< PObject *> vec_pobj;
getVectorOfPObjects( any, vec_pobj);
vect.clear();
unsigned int size= vec_pobj.size();
vect.reserve( size );
for( unsigned int i=0; i< size; i++)
vect.push_back( (T)vec_pobj[i] );
}
#else
template <class T>
void getVector(const AnyData &any, OCCI_STD_NAMESPACE::vector<T*> &vect)
{
OCCI_STD_NAMESPACE::vector< PObject *> vec_pobj;
getVectorOfPObjects( any, vec_pobj);
vect.clear();
unsigned int size= vec_pobj.size();
vect.reserve( size );
for( unsigned int i=0; i< size; i++)
vect.push_back( (T*)vec_pobj[i] );
}
#endif /* end of #ifdef WIN32COMMON */
/*------------------- getVector for Ref<T>----------------------------*/
/*
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.
*/
#ifndef WIN32COMMON
template <class T>
void getVector(const AnyData &any,OCCI_STD_NAMESPACE::vector< Ref<T> > &vect)
{
OCCI_STD_NAMESPACE::vector< void *> vec_ref;
getVectorOfOCIRefs( any, vec_ref);
vect.clear();
unsigned int size = vec_ref.size();
vect.reserve( size );
const Connection *sess = any.getConnection();
for (unsigned int i=0; i< 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));
}
}
#endif /* end of #ifndef WIN32COMMON */
/*-----------------------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).
*/
#ifdef WIN32COMMON
// and other platforms that do not support
// partial function template specialization
template <class T>
void setVector(AnyData &any, const OCCI_STD_NAMESPACE::vector<T> &vect)
{
OCCI_STD_NAMESPACE::vector< PObject *> vec_pobj;
unsigned int size= vect.size();
vec_pobj.reserve( size );
for( unsigned int i=0; i< size; i++)
vec_pobj.push_back( vect[i] );
setVectorOfPObjects( any, vec_pobj);
}
#else
template <class T>
void setVector(AnyData &any, const OCCI_STD_NAMESPACE::vector<T*> &vect)
{
OCCI_STD_NAMESPACE::vector< PObject *> vec_pobj;
unsigned int size= vect.size();
vec_pobj.reserve( size );
for( unsigned int i=0; i< size; i++)
vec_pobj.push_back( vect[i] );
setVectorOfPObjects( any, vec_pobj);
}
#endif /* end of #ifdef WIN32COMMON */
/*-----------------------setVector for Ref<T>--------------------------*/
/*
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).
*/
#ifndef WIN32COMMON
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;
unsigned int size= vect.size();
vec_ref.reserve( size );
vec_ind.reserve( size );
for( unsigned 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);
}
setVectorOfOCIRefs( any, vec_ref, vec_ind);
}
#endif /* end of #ifndef WIN32COMMON */
// Platform independent get/setVectorOfRefs method added
// get(set)Vector of Ref<T> and get(set)VectorOfRefs are identical
// in functionality.
/*------------------- getVectorOfRefs for Ref<T>----------------------------*/
/*
NAME
getVectorOfRefs - 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 getVectorOfRefs(const AnyData &any,OCCI_STD_NAMESPACE::vector< Ref<T> > &vect)
{
OCCI_STD_NAMESPACE::vector< void *> vec_ref;
getVectorOfOCIRefs( any, vec_ref);
vect.clear();
unsigned int size = vec_ref.size();
vect.reserve( size );
const Connection *sess = any.getConnection();
for (unsigned int i=0; i< 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));
}
}
/*-----------------------setVectorOfRefs for Ref<T>--------------------------*/
/*
NAME
setVectorOfRefs - 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 setVectorOfRefs(AnyData &any, const OCCI_STD_NAMESPACE::vector< Ref<T> > &vect)
{
OCCI_STD_NAMESPACE::vector< void *> vec_ref;
OCCI_STD_NAMESPACE::vector<OCIInd> vec_ind;
unsigned int size= vect.size();
vec_ref.reserve( size );
vec_ind.reserve( size );
for( unsigned 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);
}
setVectorOfOCIRefs( any, vec_ref, vec_ind);
}
/*---------------------------------------------------------------------------
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 + -