OCILIB (C and C++ Driver for Oracle)  4.9.0
Open source and cross platform Oracle Driver delivering efficient access to Oracle databases.
Loading...
Searching...
No Matches
ocilib::Vector Class Reference

Object identifying the SQL data type VECTOR. More...

#include <types.hpp>

Inherits ocilib::core::HandleHolder< OCI_Vector * >, and ocilib::core::Streamable.

Public Types

enum  VectorFormatValues {
  Flex = OCI_VEC_FLEX , Int8 = OCI_VEC_INT8 , Float32 = OCI_VEC_FLOAT32 , Float64 = OCI_VEC_FLOAT64 ,
  Binary = OCI_VEC_BINARY
}
 Vector Format types enumerated values. More...
 
typedef core::Enum< VectorFormatValuesVectorFormat
 Type of Format.
 

Public Member Functions

 Vector ()
 Create an empty null Vector instance.
 
 Vector (const Connection &connection)
 Parametrized constructor.
 
template<class T , typename core::SupportedVectorNumeric< T >::Type::type * = nullptr>
void Set (T *values, unsigned int size)
 Set the Vector content from a raw array of values.
 
template<class T , typename core::SupportedVectorNumeric< T >::Type::type * = nullptr>
void Get (T *values)
 Fills the given raw array with the Vector content.
 
template<class T , typename core::SupportedVectorNumeric< T >::Type::type * = nullptr>
void Set (const std::vector< T > &values)
 Set the Vector content from a std::vector<T>
 
template<class T , typename core::SupportedVectorNumeric< T >::Type::type * = nullptr>
std::vector< T > Get ()
 Returns the Vector content as a std::vector<T>
 
unsigned int GetDimensionCount ()
 Return the dimension count of the vector.
 
VectorFormat GetFormat ()
 Return the format of the vector.
 
void FromString (const ostring &str, VectorFormat format, unsigned int dimensions)
 Assign to the Vector object the value provided by the given string.
 
ostring ToString () const override
 return a string representation of the current Vector
 

Detailed Description

Object identifying the SQL data type VECTOR.

This class wraps the OCILIB object handle OCI_Vector and its related methods

Definition at line 5174 of file types.hpp.

Member Typedef Documentation

◆ VectorFormat

Type of Format.

Possible values are Vector::VectorFormatValues

Definition at line 5206 of file types.hpp.

Member Enumeration Documentation

◆ VectorFormatValues

Vector Format types enumerated values.

Enumerator
Flex 

Flexible format

Int8 

8-bit integer format

Float32 

32-bit floating point format

Float64 

64-bit floating point format

Binary 

Binary format

Definition at line 5185 of file types.hpp.

Constructor & Destructor Documentation

◆ Vector() [1/2]

ocilib::Vector::Vector ( )
inline

Create an empty null Vector instance.

Definition at line 41 of file Vector.hpp.

◆ Vector() [2/2]

ocilib::Vector::Vector ( const Connection connection)
inline

Parametrized constructor.

Parameters
connection- Parent connection
Note
  • The Vector object must not be accessed anymore once the parent connection object gets out of scope

Definition at line 46 of file Vector.hpp.

References ocilib::core::Check(), and OCI_VectorCreate().

Member Function Documentation

◆ Set() [1/2]

template<class T , typename core::SupportedVectorNumeric< T >::Type::type * >
void ocilib::Vector::Set ( T *  values,
unsigned int  size 
)

Set the Vector content from a raw array of values.

Parameters
values- values to set
size- number of element in the input buffer array

Definition at line 61 of file Vector.hpp.

References ocilib::core::Check(), and OCI_VectorSetValues().

Referenced by Set().

◆ Get() [1/2]

template<class T , typename core::SupportedVectorNumeric< T >::Type::type * >
void ocilib::Vector::Get ( T *  values)

Fills the given raw array with the Vector content.

Parameters
values- input array buffer to fill
Warning
The input buffer must be large enough to receive the values. Use GetDimensionCount() to know the required number of elements.
T Type must match the format of the Vector current content :
  • VectorFormat::Int8 => char
  • VectorFormat::Float32 => float
  • VectorFormat::Float64 => double
  • VectorFormat::Binary => unsigned char

Definition at line 67 of file Vector.hpp.

References ocilib::core::Check(), and OCI_VectorGetValues().

◆ Set() [2/2]

template<class T , typename core::SupportedVectorNumeric< T >::Type::type * >
void ocilib::Vector::Set ( const std::vector< T > &  values)

Set the Vector content from a std::vector<T>

Parameters
values- values to set

Definition at line 73 of file Vector.hpp.

References Set().

◆ Get() [2/2]

template<class T , typename core::SupportedVectorNumeric< T >::Type::type * >
std::vector< T > ocilib::Vector::Get

Returns the Vector content as a std::vector<T>

Warning
T Type must match the format of the Vector current content :
  • VectorFormat::Int8 => char
  • VectorFormat::Float32 => float
  • VectorFormat::Float64 => double
  • VectorFormat::Binary => unsigned char

Definition at line 79 of file Vector.hpp.

References Get(), and GetDimensionCount().

Referenced by Get().

◆ GetDimensionCount()

unsigned int ocilib::Vector::GetDimensionCount ( )
inline

Return the dimension count of the vector.

Definition at line 89 of file Vector.hpp.

References ocilib::core::Check(), and OCI_VectorGetInfo().

Referenced by Get().

◆ GetFormat()

Vector::VectorFormat ocilib::Vector::GetFormat ( )
inline

Return the format of the vector.

Definition at line 99 of file Vector.hpp.

References ocilib::core::Check(), and OCI_VectorGetInfo().

◆ FromString()

void ocilib::Vector::FromString ( const ostring str,
VectorFormat  format,
unsigned int  dimensions 
)
inline

Assign to the Vector object the value provided by the given string.

Parameters
str- textual representation of the vector
format- format of the vector contained in the input string
dimensions- number of dimensions of the vector contained in the input string

Definition at line 109 of file Vector.hpp.

References ocilib::core::Check(), and OCI_VectorFromText().

◆ ToString()

ostring ocilib::Vector::ToString ( ) const
inlineoverridevirtual

return a string representation of the current Vector

Implements ocilib::core::Streamable.

Definition at line 114 of file Vector.hpp.

References ocilib::core::Check(), and OCI_VectorToText().