1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: FValue.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
35 #include "connectivity/FValue.hxx"
36 #include "connectivity/CommonTools.hxx"
37 #include <connectivity/dbconversion.hxx>
38 #include <cppuhelper/extract.hxx>
39 #include <com/sun/star/io/XInputStream.hpp>
40 #include <rtl/ustrbuf.hxx>
41 #include <rtl/logfile.hxx>
43 using namespace connectivity
;
44 using namespace dbtools
;
45 using namespace ::com::sun::star::sdbc
;
46 using namespace ::com::sun::star::uno
;
47 using namespace ::com::sun::star::util
;
48 using namespace ::com::sun::star::io
;
51 static sal_Bool
isStorageCompatible(sal_Int32 _eType1
, sal_Int32 _eType2
)
53 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::isStorageCompatible" );
54 sal_Bool bIsCompatible
= sal_True
;
56 if (_eType1
!= _eType2
)
58 RTL_LOGFILE_CONTEXT_TRACE( aLogger
, "ORowSetValue::isStorageCompatible _eType1 != _eType2" );
62 case DataType::VARCHAR
:
63 case DataType::DECIMAL
:
64 case DataType::NUMERIC
:
65 case DataType::LONGVARCHAR
:
66 bIsCompatible
= (DataType::CHAR
== _eType2
)
67 || (DataType::VARCHAR
== _eType2
)
68 || (DataType::DECIMAL
== _eType2
)
69 || (DataType::NUMERIC
== _eType2
)
70 || (DataType::LONGVARCHAR
== _eType2
);
73 case DataType::DOUBLE
:
75 bIsCompatible
= (DataType::DOUBLE
== _eType2
)
76 || (DataType::REAL
== _eType2
);
79 case DataType::BINARY
:
80 case DataType::VARBINARY
:
81 case DataType::LONGVARBINARY
:
82 bIsCompatible
= (DataType::BINARY
== _eType2
)
83 || (DataType::VARBINARY
== _eType2
)
84 || (DataType::LONGVARBINARY
== _eType2
);
87 case DataType::INTEGER
:
88 bIsCompatible
= (DataType::SMALLINT
== _eType2
)
89 || (DataType::TINYINT
== _eType2
)
90 || (DataType::BIT
== _eType2
)
91 || (DataType::BOOLEAN
== _eType2
);
93 case DataType::SMALLINT
:
94 bIsCompatible
= (DataType::TINYINT
== _eType2
)
95 || (DataType::BIT
== _eType2
)
96 || (DataType::BOOLEAN
== _eType2
);
98 case DataType::TINYINT
:
99 bIsCompatible
= (DataType::BIT
== _eType2
)
100 || (DataType::BOOLEAN
== _eType2
);
105 case DataType::OBJECT
:
106 bIsCompatible
= (DataType::BLOB
== _eType2
)
107 || (DataType::CLOB
== _eType2
)
108 || (DataType::OBJECT
== _eType2
);
112 bIsCompatible
= sal_False
;
115 return bIsCompatible
;
119 // -----------------------------------------------------------------------------
123 #include <rtl/string.h>
127 struct AllocationType
129 const sal_Char
* pName
;
130 sal_Int32 nAllocatedUnits
;
132 AllocationType( ) : pName( NULL
), nAllocatedUnits( 0 ) { }
135 // =============================================================================
136 class AllocationTracer
139 typedef ::std::vector
< AllocationType
> AllocationState
;
140 static AllocationState s_aAllocated
;
141 static ::osl::Mutex s_aMutex
;
144 static void registerUnit( const sal_Char
* _pName
);
145 static void revokeUnit( const sal_Char
* _pName
);
148 static AllocationState::iterator
getLocation( const sal_Char
* _pName
);
151 // =============================================================================
152 AllocationTracer::AllocationState::iterator
AllocationTracer::getLocation( const sal_Char
* _pName
)
154 AllocationState::iterator aLookFor
= s_aAllocated
.begin();
156 aLookFor
!= s_aAllocated
.end();
160 if ( 0 == rtl_str_compare( aLookFor
->pName
, _pName
) )
165 s_aAllocated
.push_back( AllocationType() );
166 aLookFor
= s_aAllocated
.end(); --aLookFor
;
167 aLookFor
->pName
= _pName
; // note that this assumes that _pName is a constant string ....
171 // =============================================================================
172 AllocationTracer::AllocationState
AllocationTracer::s_aAllocated
;
173 ::osl::Mutex
AllocationTracer::s_aMutex
;
175 // =============================================================================
176 void AllocationTracer::registerUnit( const sal_Char
* _pName
)
178 ::osl::MutexGuard
aGuard( s_aMutex
);
180 AllocationState::iterator aPos
= getLocation( _pName
);
181 ++aPos
->nAllocatedUnits
;
184 // =============================================================================
185 void AllocationTracer::revokeUnit( const sal_Char
* _pName
)
187 ::osl::MutexGuard
aGuard( s_aMutex
);
189 AllocationState::iterator aPos
= getLocation( _pName
);
190 --aPos
->nAllocatedUnits
;
193 #define TRACE_ALLOC( type ) tracing::AllocationTracer::registerUnit( #type );
194 #define TRACE_FREE( type ) tracing::AllocationTracer::revokeUnit( #type );
197 #define TRACE_ALLOC( type )
198 #define TRACE_FREE( type )
201 // -----------------------------------------------------------------------------
202 void ORowSetValue::setTypeKind(sal_Int32 _eType
)
204 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::setTypeKind" );
205 if ( !m_bNull
&& !isStorageCompatible(_eType
, m_eTypeKind
) )
209 case DataType::VARCHAR
:
211 case DataType::DECIMAL
:
212 case DataType::NUMERIC
:
213 case DataType::LONGVARCHAR
:
214 (*this) = getString();
216 case DataType::BIGINT
:
220 case DataType::FLOAT
:
221 (*this) = getFloat();
223 case DataType::DOUBLE
:
225 (*this) = getDouble();
227 case DataType::TINYINT
:
230 case DataType::SMALLINT
:
231 (*this) = getInt16();
233 case DataType::INTEGER
:
234 (*this) = getInt32();
237 case DataType::BOOLEAN
:
246 case DataType::TIMESTAMP
:
247 (*this) = getDateTime();
249 case DataType::BINARY
:
250 case DataType::VARBINARY
:
251 case DataType::LONGVARBINARY
:
252 (*this) = getSequence();
256 case DataType::OBJECT
:
260 OSL_ENSURE(0,"ORowSetValue:operator==(): UNSPUPPORTED TYPE!");
264 m_eTypeKind
= _eType
;
267 // -----------------------------------------------------------------------------
268 void ORowSetValue::free()
270 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::free" );
276 case DataType::VARCHAR
:
277 case DataType::DECIMAL
:
278 case DataType::NUMERIC
:
279 case DataType::LONGVARCHAR
:
280 OSL_ENSURE(m_aValue
.m_pString
,"String pointer is null!");
281 rtl_uString_release(m_aValue
.m_pString
);
282 m_aValue
.m_pString
= NULL
;
284 case DataType::INTEGER
:
287 delete (sal_Int64
*)m_aValue
.m_pValue
;
288 TRACE_FREE( sal_Int64
)
289 m_aValue
.m_pValue
= NULL
;
292 case DataType::BIGINT
:
295 delete (sal_Int64
*)m_aValue
.m_pValue
;
296 TRACE_FREE( sal_Int64
)
297 m_aValue
.m_pValue
= NULL
;
301 OSL_ENSURE(m_aValue
.m_pString
,"String pointer is null!");
302 rtl_uString_release(m_aValue
.m_pString
);
303 m_aValue
.m_pString
= NULL
;
306 case DataType::FLOAT
:
307 delete (float*)m_aValue
.m_pValue
;
309 m_aValue
.m_pValue
= NULL
;
311 case DataType::DOUBLE
:
313 delete (double*)m_aValue
.m_pValue
;
315 m_aValue
.m_pValue
= NULL
;
318 delete (::com::sun::star::util::Date
*)m_aValue
.m_pValue
;
320 m_aValue
.m_pValue
= NULL
;
323 delete (::com::sun::star::util::Time
*)m_aValue
.m_pValue
;
325 m_aValue
.m_pValue
= NULL
;
327 case DataType::TIMESTAMP
:
328 delete (::com::sun::star::util::DateTime
*)m_aValue
.m_pValue
;
329 TRACE_FREE( DateTime
)
330 m_aValue
.m_pValue
= NULL
;
332 case DataType::BINARY
:
333 case DataType::VARBINARY
:
334 case DataType::LONGVARBINARY
:
335 delete (Sequence
<sal_Int8
>*)m_aValue
.m_pValue
;
336 TRACE_FREE( Sequence_sal_Int8
)
337 m_aValue
.m_pValue
= NULL
;
341 case DataType::OBJECT
:
342 delete (Any
*)m_aValue
.m_pValue
;
344 m_aValue
.m_pValue
= NULL
;
351 // -----------------------------------------------------------------------------
352 ORowSetValue
& ORowSetValue::operator=(const ORowSetValue
& _rRH
)
357 if ( m_eTypeKind
!= _rRH
.m_eTypeKind
|| (_rRH
.m_bNull
&& !m_bNull
) || m_bSigned
!= _rRH
.m_bSigned
)
360 m_bBound
= _rRH
.m_bBound
;
361 m_eTypeKind
= _rRH
.m_eTypeKind
;
362 m_bSigned
= _rRH
.m_bSigned
;
364 if(m_bNull
&& !_rRH
.m_bNull
)
366 switch(_rRH
.m_eTypeKind
)
369 case DataType::VARCHAR
:
370 case DataType::DECIMAL
:
371 case DataType::NUMERIC
:
372 case DataType::LONGVARCHAR
:
373 rtl_uString_acquire(_rRH
.m_aValue
.m_pString
);
374 m_aValue
.m_pString
= _rRH
.m_aValue
.m_pString
;
376 case DataType::BIGINT
:
377 if ( _rRH
.m_bSigned
)
379 m_aValue
.m_pValue
= new sal_Int64(*(sal_Int64
*)_rRH
.m_aValue
.m_pValue
);
380 TRACE_ALLOC( sal_Int64
)
384 rtl_uString_acquire(_rRH
.m_aValue
.m_pString
);
385 m_aValue
.m_pString
= _rRH
.m_aValue
.m_pString
;
388 case DataType::FLOAT
:
389 m_aValue
.m_pValue
= new float(*(float*)_rRH
.m_aValue
.m_pValue
);
392 case DataType::DOUBLE
:
394 m_aValue
.m_pValue
= new double(*(double*)_rRH
.m_aValue
.m_pValue
);
395 TRACE_ALLOC( double )
398 m_aValue
.m_pValue
= new Date(*(Date
*)_rRH
.m_aValue
.m_pValue
);
402 m_aValue
.m_pValue
= new Time(*(Time
*)_rRH
.m_aValue
.m_pValue
);
405 case DataType::TIMESTAMP
:
406 m_aValue
.m_pValue
= new DateTime(*(DateTime
*)_rRH
.m_aValue
.m_pValue
);
407 TRACE_ALLOC( DateTime
)
409 case DataType::BINARY
:
410 case DataType::VARBINARY
:
411 case DataType::LONGVARBINARY
:
412 m_aValue
.m_pValue
= new Sequence
<sal_Int8
>(*(Sequence
<sal_Int8
>*)_rRH
.m_aValue
.m_pValue
);
413 TRACE_ALLOC( Sequence_sal_Int8
)
416 case DataType::BOOLEAN
:
417 m_aValue
.m_bBool
= _rRH
.m_aValue
.m_bBool
;
419 case DataType::TINYINT
:
420 if ( _rRH
.m_bSigned
)
421 m_aValue
.m_nInt8
= _rRH
.m_aValue
.m_nInt8
;
423 m_aValue
.m_nInt16
= _rRH
.m_aValue
.m_nInt16
;
425 case DataType::SMALLINT
:
426 if ( _rRH
.m_bSigned
)
427 m_aValue
.m_nInt16
= _rRH
.m_aValue
.m_nInt16
;
429 m_aValue
.m_nInt32
= _rRH
.m_aValue
.m_nInt32
;
431 case DataType::INTEGER
:
432 if ( _rRH
.m_bSigned
)
433 m_aValue
.m_nInt32
= _rRH
.m_aValue
.m_nInt32
;
436 m_aValue
.m_pValue
= new sal_Int64(*(sal_Int64
*)_rRH
.m_aValue
.m_pValue
);
437 TRACE_ALLOC( sal_Int64
)
441 m_aValue
.m_pValue
= new Any(*(Any
*)_rRH
.m_aValue
.m_pValue
);
445 else if(!_rRH
.m_bNull
)
447 switch(_rRH
.m_eTypeKind
)
450 case DataType::VARCHAR
:
451 case DataType::DECIMAL
:
452 case DataType::NUMERIC
:
453 case DataType::LONGVARCHAR
:
454 (*this) = ::rtl::OUString(_rRH
.m_aValue
.m_pString
);
456 case DataType::BIGINT
:
457 if ( _rRH
.m_bSigned
)
458 (*this) = *(sal_Int64
*)_rRH
.m_aValue
.m_pValue
;
460 (*this) = ::rtl::OUString(_rRH
.m_aValue
.m_pString
);
462 case DataType::FLOAT
:
463 (*this) = *(float*)_rRH
.m_aValue
.m_pValue
;
465 case DataType::DOUBLE
:
467 (*this) = *(double*)_rRH
.m_aValue
.m_pValue
;
470 (*this) = *(Date
*)_rRH
.m_aValue
.m_pValue
;
473 (*this) = *(Time
*)_rRH
.m_aValue
.m_pValue
;
475 case DataType::TIMESTAMP
:
476 (*this) = *(DateTime
*)_rRH
.m_aValue
.m_pValue
;
478 case DataType::BINARY
:
479 case DataType::VARBINARY
:
480 case DataType::LONGVARBINARY
:
481 (*this) = *(Sequence
<sal_Int8
>*)_rRH
.m_aValue
.m_pValue
;
484 case DataType::BOOLEAN
:
485 m_aValue
.m_bBool
= _rRH
.m_aValue
.m_bBool
;
487 case DataType::TINYINT
:
488 if ( _rRH
.m_bSigned
)
489 m_aValue
.m_nInt8
= _rRH
.m_aValue
.m_nInt8
;
491 m_aValue
.m_nInt16
= _rRH
.m_aValue
.m_nInt16
;
493 case DataType::SMALLINT
:
494 if ( _rRH
.m_bSigned
)
495 m_aValue
.m_nInt16
= _rRH
.m_aValue
.m_nInt16
;
497 m_aValue
.m_nInt32
= _rRH
.m_aValue
.m_nInt32
;
499 case DataType::INTEGER
:
500 if ( _rRH
.m_bSigned
)
501 m_aValue
.m_nInt32
= _rRH
.m_aValue
.m_nInt32
;
503 *static_cast<sal_Int64
*>(m_aValue
.m_pValue
) = *(sal_Int64
*)_rRH
.m_aValue
.m_pValue
;
506 (*(Any
*)m_aValue
.m_pValue
) = (*(Any
*)_rRH
.m_aValue
.m_pValue
);
510 m_bNull
= _rRH
.m_bNull
;
512 m_eTypeKind
= _rRH
.m_eTypeKind
;
516 // -------------------------------------------------------------------------
518 ORowSetValue
& ORowSetValue::operator=(const Date
& _rRH
)
520 if(m_eTypeKind
!= DataType::DATE
)
525 m_aValue
.m_pValue
= new Date(_rRH
);
527 m_eTypeKind
= DataType::DATE
;
531 *(Date
*)m_aValue
.m_pValue
= _rRH
;
535 // -------------------------------------------------------------------------
536 ORowSetValue
& ORowSetValue::operator=(const Time
& _rRH
)
538 if(m_eTypeKind
!= DataType::TIME
)
543 m_aValue
.m_pValue
= new Time(_rRH
);
545 m_eTypeKind
= DataType::TIME
;
549 *(Time
*)m_aValue
.m_pValue
= _rRH
;
553 // -------------------------------------------------------------------------
554 ORowSetValue
& ORowSetValue::operator=(const DateTime
& _rRH
)
556 if(m_eTypeKind
!= DataType::TIMESTAMP
)
560 m_aValue
.m_pValue
= new DateTime(_rRH
);
561 TRACE_ALLOC( DateTime
)
562 m_eTypeKind
= DataType::TIMESTAMP
;
566 *(DateTime
*)m_aValue
.m_pValue
= _rRH
;
570 // -------------------------------------------------------------------------
572 ORowSetValue
& ORowSetValue::operator=(const ::rtl::OUString
& _rRH
)
574 if(m_eTypeKind
!= DataType::VARCHAR
|| m_aValue
.m_pString
!= _rRH
.pData
)
579 m_aValue
.m_pString
= _rRH
.pData
;
580 rtl_uString_acquire(m_aValue
.m_pString
);
581 m_eTypeKind
= DataType::VARCHAR
;
586 // -------------------------------------------------------------------------
588 ORowSetValue
& ORowSetValue::operator=(const double& _rRH
)
590 if( !isStorageCompatible(m_eTypeKind
,DataType::DOUBLE
) )
595 m_aValue
.m_pValue
= new double(_rRH
);
596 TRACE_ALLOC( double )
597 m_eTypeKind
= DataType::DOUBLE
;
601 *(double*)m_aValue
.m_pValue
= _rRH
;
605 // -----------------------------------------------------------------------------
606 ORowSetValue
& ORowSetValue::operator=(const float& _rRH
)
608 if(m_eTypeKind
!= DataType::FLOAT
)
613 m_aValue
.m_pValue
= new float(_rRH
);
615 m_eTypeKind
= DataType::FLOAT
;
619 *(float*)m_aValue
.m_pValue
= _rRH
;
623 // -------------------------------------------------------------------------
625 ORowSetValue
& ORowSetValue::operator=(const sal_Int8
& _rRH
)
627 if(m_eTypeKind
!= DataType::TINYINT
)
630 m_aValue
.m_nInt8
= _rRH
;
631 m_eTypeKind
= DataType::TINYINT
;
635 // -------------------------------------------------------------------------
637 ORowSetValue
& ORowSetValue::operator=(const sal_Int16
& _rRH
)
639 if(m_eTypeKind
!= DataType::SMALLINT
)
642 m_aValue
.m_nInt16
= _rRH
;
643 m_eTypeKind
= DataType::SMALLINT
;
648 // -------------------------------------------------------------------------
650 ORowSetValue
& ORowSetValue::operator=(const sal_Int32
& _rRH
)
652 if(m_eTypeKind
!= DataType::INTEGER
)
656 m_aValue
.m_nInt32
= _rRH
;
661 m_aValue
.m_pValue
= new sal_Int64(_rRH
);
662 TRACE_ALLOC( sal_Int64
)
665 *static_cast<sal_Int64
*>(m_aValue
.m_pValue
) = static_cast<sal_Int64
>(_rRH
);
668 m_eTypeKind
= DataType::INTEGER
;
673 // -------------------------------------------------------------------------
675 ORowSetValue
& ORowSetValue::operator=(const sal_Bool _rRH
)
677 if(m_eTypeKind
!= DataType::BIT
&& DataType::BOOLEAN
!= m_eTypeKind
)
680 m_aValue
.m_bBool
= _rRH
;
681 m_eTypeKind
= DataType::BIT
;
686 // -------------------------------------------------------------------------
687 ORowSetValue
& ORowSetValue::operator=(const sal_Int64
& _rRH
)
689 if ( DataType::BIGINT
!= m_eTypeKind
|| !m_bSigned
)
696 m_aValue
.m_pValue
= new sal_Int64(_rRH
);
697 TRACE_ALLOC( sal_Int64
)
700 *static_cast<sal_Int64
*>(m_aValue
.m_pValue
) = _rRH
;
704 ::rtl::OUString aVal
= ::rtl::OUString::valueOf(_rRH
);
705 m_aValue
.m_pString
= aVal
.pData
;
706 rtl_uString_acquire(m_aValue
.m_pString
);
709 m_eTypeKind
= DataType::BIGINT
;
714 // -------------------------------------------------------------------------
715 ORowSetValue
& ORowSetValue::operator=(const Sequence
<sal_Int8
>& _rRH
)
717 if (!isStorageCompatible(DataType::LONGVARBINARY
,m_eTypeKind
))
722 m_aValue
.m_pValue
= new Sequence
<sal_Int8
>(_rRH
);
723 TRACE_ALLOC( Sequence_sal_Int8
)
726 *static_cast< Sequence
< sal_Int8
>* >(m_aValue
.m_pValue
) = _rRH
;
728 m_eTypeKind
= DataType::LONGVARBINARY
;
733 // -------------------------------------------------------------------------
734 ORowSetValue
& ORowSetValue::operator=(const Any
& _rAny
)
736 if (!isStorageCompatible(DataType::OBJECT
,m_eTypeKind
))
741 m_aValue
.m_pValue
= new Any(_rAny
);
745 *static_cast<Any
*>(m_aValue
.m_pValue
) = _rAny
;
747 m_eTypeKind
= DataType::OBJECT
;
752 // -------------------------------------------------------------------------
754 sal_Bool
operator==(const Date
& _rLH
,const Date
& _rRH
)
756 return _rLH
.Day
== _rRH
.Day
&& _rLH
.Month
== _rRH
.Month
&& _rLH
.Year
== _rRH
.Year
;
758 // -------------------------------------------------------------------------
760 sal_Bool
operator==(const Time
& _rLH
,const Time
& _rRH
)
762 return _rLH
.Minutes
== _rRH
.Minutes
&& _rLH
.Hours
== _rRH
.Hours
&& _rLH
.Seconds
== _rRH
.Seconds
&& _rLH
.HundredthSeconds
== _rRH
.HundredthSeconds
;
764 // -------------------------------------------------------------------------
766 sal_Bool
operator==(const DateTime
& _rLH
,const DateTime
& _rRH
)
768 return _rLH
.Day
== _rRH
.Day
&& _rLH
.Month
== _rRH
.Month
&& _rLH
.Year
== _rRH
.Year
&&
769 _rLH
.Minutes
== _rRH
.Minutes
&& _rLH
.Hours
== _rRH
.Hours
&& _rLH
.Seconds
== _rRH
.Seconds
&& _rLH
.HundredthSeconds
== _rRH
.HundredthSeconds
;
771 // -------------------------------------------------------------------------
773 bool ORowSetValue::operator==(const ORowSetValue
& _rRH
) const
775 if(m_eTypeKind
!= _rRH
.m_eTypeKind
)
777 if ( m_bSigned
!= _rRH
.m_bSigned
)
779 if(m_bNull
!= _rRH
.isNull())
781 if(m_bNull
&& _rRH
.isNull())
785 OSL_ENSURE(!m_bNull
,"SHould not be null!");
788 case DataType::VARCHAR
:
790 case DataType::DECIMAL
:
791 case DataType::NUMERIC
:
792 case DataType::LONGVARCHAR
:
794 ::rtl::OUString
aVal1(m_aValue
.m_pString
);
795 ::rtl::OUString
aVal2(_rRH
.m_aValue
.m_pString
);
796 bRet
= aVal1
== aVal2
;
800 case DataType::FLOAT
:
801 bRet
= *(float*)m_aValue
.m_pValue
== *(float*)_rRH
.m_aValue
.m_pValue
;
803 case DataType::DOUBLE
:
805 bRet
= *(double*)m_aValue
.m_pValue
== *(double*)_rRH
.m_aValue
.m_pValue
;
807 case DataType::TINYINT
:
808 bRet
= m_bSigned
? ( m_aValue
.m_nInt8
== _rRH
.m_aValue
.m_nInt8
) : (m_aValue
.m_nInt16
== _rRH
.m_aValue
.m_nInt16
);
810 case DataType::SMALLINT
:
811 bRet
= m_bSigned
? ( m_aValue
.m_nInt16
== _rRH
.m_aValue
.m_nInt16
) : (m_aValue
.m_nInt32
== _rRH
.m_aValue
.m_nInt32
);
813 case DataType::INTEGER
:
814 bRet
= m_bSigned
? ( m_aValue
.m_nInt32
== _rRH
.m_aValue
.m_nInt32
) : (*(sal_Int64
*)m_aValue
.m_pValue
== *(sal_Int64
*)_rRH
.m_aValue
.m_pValue
);
816 case DataType::BIGINT
:
818 bRet
= *(sal_Int64
*)m_aValue
.m_pValue
== *(sal_Int64
*)_rRH
.m_aValue
.m_pValue
;
821 ::rtl::OUString
aVal1(m_aValue
.m_pString
);
822 ::rtl::OUString
aVal2(_rRH
.m_aValue
.m_pString
);
823 bRet
= aVal1
== aVal2
;
827 case DataType::BOOLEAN
:
828 bRet
= m_aValue
.m_bBool
== _rRH
.m_aValue
.m_bBool
;
831 bRet
= *(Date
*)m_aValue
.m_pValue
== *(Date
*)_rRH
.m_aValue
.m_pValue
;
834 bRet
= *(Time
*)m_aValue
.m_pValue
== *(Time
*)_rRH
.m_aValue
.m_pValue
;
836 case DataType::TIMESTAMP
:
837 bRet
= *(DateTime
*)m_aValue
.m_pValue
== *(DateTime
*)_rRH
.m_aValue
.m_pValue
;
839 case DataType::BINARY
:
840 case DataType::VARBINARY
:
841 case DataType::LONGVARBINARY
:
846 case DataType::OBJECT
:
850 OSL_ENSURE(0,"ORowSetValue::operator==(): UNSPUPPORTED TYPE!");
854 // -------------------------------------------------------------------------
855 Any
ORowSetValue::makeAny() const
857 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::makeAny" );
859 if(isBound() && !isNull())
861 switch(getTypeKind())
864 case DataType::VARCHAR
:
865 case DataType::DECIMAL
:
866 case DataType::NUMERIC
:
867 case DataType::LONGVARCHAR
:
868 OSL_ENSURE(m_aValue
.m_pString
,"Value is null!");
869 rValue
<<= (::rtl::OUString
)m_aValue
.m_pString
;
871 case DataType::BIGINT
:
874 OSL_ENSURE(m_aValue
.m_pValue
,"Value is null!");
875 rValue
<<= *(sal_Int64
*)m_aValue
.m_pValue
;
879 OSL_ENSURE(m_aValue
.m_pString
,"Value is null!");
880 rValue
<<= (::rtl::OUString
)m_aValue
.m_pString
;
883 case DataType::FLOAT
:
884 OSL_ENSURE(m_aValue
.m_pValue
,"Value is null!");
885 rValue
<<= *(float*)m_aValue
.m_pValue
;
887 case DataType::DOUBLE
:
889 OSL_ENSURE(m_aValue
.m_pValue
,"Value is null!");
890 rValue
<<= *(double*)m_aValue
.m_pValue
;
893 OSL_ENSURE(m_aValue
.m_pValue
,"Value is null!");
894 rValue
<<= *(Date
*)m_aValue
.m_pValue
;
897 OSL_ENSURE(m_aValue
.m_pValue
,"Value is null!");
898 rValue
<<= *(Time
*)m_aValue
.m_pValue
;
900 case DataType::TIMESTAMP
:
901 OSL_ENSURE(m_aValue
.m_pValue
,"Value is null!");
902 rValue
<<= *(DateTime
*)m_aValue
.m_pValue
;
904 case DataType::BINARY
:
905 case DataType::VARBINARY
:
906 case DataType::LONGVARBINARY
:
907 OSL_ENSURE(m_aValue
.m_pValue
,"Value is null!");
908 rValue
<<= *(Sequence
<sal_Int8
>*)m_aValue
.m_pValue
;
912 case DataType::OBJECT
:
916 case DataType::BOOLEAN
:
917 rValue
.setValue( &m_aValue
.m_bBool
, ::getCppuBooleanType() );
919 case DataType::TINYINT
:
921 rValue
<<= m_aValue
.m_nInt8
;
923 rValue
<<= m_aValue
.m_nInt16
;
925 case DataType::SMALLINT
:
927 rValue
<<= m_aValue
.m_nInt16
;
929 rValue
<<= m_aValue
.m_nInt32
;
931 case DataType::INTEGER
:
933 rValue
<<= m_aValue
.m_nInt32
;
936 OSL_ENSURE(m_aValue
.m_pValue
,"Value is null!");
937 rValue
<<= *(sal_Int64
*)m_aValue
.m_pValue
;
941 OSL_ENSURE(0,"ORowSetValue::makeAny(): UNSPUPPORTED TYPE!");
946 // -------------------------------------------------------------------------
947 ::rtl::OUString
ORowSetValue::getString( ) const
949 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getString" );
950 ::rtl::OUString aRet
;
953 switch(getTypeKind())
956 case DataType::VARCHAR
:
957 case DataType::DECIMAL
:
958 case DataType::NUMERIC
:
959 case DataType::LONGVARCHAR
:
960 aRet
= m_aValue
.m_pString
;
962 case DataType::BIGINT
:
964 aRet
= ::rtl::OUString::valueOf((sal_Int64
)*this);
966 aRet
= m_aValue
.m_pString
;
968 case DataType::FLOAT
:
969 aRet
= ::rtl::OUString::valueOf((float)*this);
971 case DataType::DOUBLE
:
973 aRet
= ::rtl::OUString::valueOf((double)*this);
976 aRet
= connectivity::toDateString(*this);
979 aRet
= connectivity::toTimeString(*this);
981 case DataType::TIMESTAMP
:
982 aRet
= connectivity::toDateTimeString(*this);
984 case DataType::BINARY
:
985 case DataType::VARBINARY
:
986 case DataType::LONGVARBINARY
:
988 ::rtl::OUStringBuffer sVal
= ::rtl::OUString::createFromAscii("0x");
989 Sequence
<sal_Int8
> aSeq(getSequence());
990 const sal_Int8
* pBegin
= aSeq
.getConstArray();
991 const sal_Int8
* pEnd
= pBegin
+ aSeq
.getLength();
992 for(;pBegin
!= pEnd
;++pBegin
)
993 sVal
.append((sal_Int32
)*pBegin
,16);
994 aRet
= sVal
.makeStringAndClear();
998 case DataType::BOOLEAN
:
999 aRet
= ::rtl::OUString::valueOf((sal_Int32
)(sal_Bool
)*this);
1001 case DataType::TINYINT
:
1003 aRet
= ::rtl::OUString::valueOf((sal_Int32
)(sal_Int8
)*this);
1005 aRet
= ::rtl::OUString::valueOf((sal_Int32
)(sal_Int16
)*this);
1007 case DataType::SMALLINT
:
1009 aRet
= ::rtl::OUString::valueOf((sal_Int32
)(sal_Int16
)*this);
1011 aRet
= ::rtl::OUString::valueOf((sal_Int32
)*this);
1013 case DataType::INTEGER
:
1015 aRet
= ::rtl::OUString::valueOf((sal_Int32
)*this);
1017 aRet
= ::rtl::OUString::valueOf((sal_Int64
)*this);
1023 // -------------------------------------------------------------------------
1024 sal_Bool
ORowSetValue::getBool() const
1026 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getBool" );
1027 sal_Bool bRet
= sal_False
;
1030 switch(getTypeKind())
1032 case DataType::CHAR
:
1033 case DataType::VARCHAR
:
1034 case DataType::LONGVARCHAR
:
1036 const ::rtl::OUString
sValue(m_aValue
.m_pString
);
1037 const static ::rtl::OUString
s_sTrue(RTL_CONSTASCII_USTRINGPARAM("true"));
1038 const static ::rtl::OUString
s_sFalse(RTL_CONSTASCII_USTRINGPARAM("false"));
1039 if ( sValue
.equalsIgnoreAsciiCase(s_sTrue
) )
1044 else if ( sValue
.equalsIgnoreAsciiCase(s_sFalse
) )
1051 case DataType::DECIMAL
:
1052 case DataType::NUMERIC
:
1054 bRet
= ::rtl::OUString(m_aValue
.m_pString
).toInt32() != 0;
1056 case DataType::BIGINT
:
1058 bRet
= *(sal_Int64
*)m_aValue
.m_pValue
!= 0;
1060 bRet
= ::rtl::OUString(m_aValue
.m_pString
).toInt64() != 0;
1062 case DataType::FLOAT
:
1063 bRet
= *(float*)m_aValue
.m_pValue
!= 0.0;
1065 case DataType::DOUBLE
:
1066 case DataType::REAL
:
1067 bRet
= *(double*)m_aValue
.m_pValue
!= 0.0;
1069 case DataType::DATE
:
1070 case DataType::TIME
:
1071 case DataType::TIMESTAMP
:
1072 case DataType::BINARY
:
1073 case DataType::VARBINARY
:
1074 case DataType::LONGVARBINARY
:
1075 OSL_ASSERT(!"getBool() for this type is not allowed!");
1078 case DataType::BOOLEAN
:
1079 bRet
= m_aValue
.m_bBool
;
1081 case DataType::TINYINT
:
1082 bRet
= m_bSigned
? (m_aValue
.m_nInt8
!= 0) : (m_aValue
.m_nInt16
!= 0);
1084 case DataType::SMALLINT
:
1085 bRet
= m_bSigned
? (m_aValue
.m_nInt16
!= 0) : (m_aValue
.m_nInt32
!= 0);
1087 case DataType::INTEGER
:
1088 bRet
= m_bSigned
? (m_aValue
.m_nInt32
!= 0) : (*static_cast<sal_Int64
*>(m_aValue
.m_pValue
) != sal_Int64(0));
1094 // -------------------------------------------------------------------------
1095 sal_Int8
ORowSetValue::getInt8() const
1097 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getInt8" );
1103 switch(getTypeKind())
1105 case DataType::CHAR
:
1106 case DataType::VARCHAR
:
1107 case DataType::DECIMAL
:
1108 case DataType::NUMERIC
:
1109 case DataType::LONGVARCHAR
:
1110 nRet
= sal_Int8(::rtl::OUString(m_aValue
.m_pString
).toInt32());
1112 case DataType::BIGINT
:
1114 nRet
= sal_Int8(*(sal_Int64
*)m_aValue
.m_pValue
);
1116 nRet
= sal_Int8(::rtl::OUString(m_aValue
.m_pString
).toInt32());
1118 case DataType::FLOAT
:
1119 nRet
= sal_Int8(*(float*)m_aValue
.m_pValue
);
1121 case DataType::DOUBLE
:
1122 case DataType::REAL
:
1123 nRet
= sal_Int8(*(double*)m_aValue
.m_pValue
);
1125 case DataType::DATE
:
1126 case DataType::TIME
:
1127 case DataType::TIMESTAMP
:
1128 case DataType::BINARY
:
1129 case DataType::VARBINARY
:
1130 case DataType::LONGVARBINARY
:
1131 OSL_ASSERT(!"getInt8() for this type is not allowed!");
1134 case DataType::BOOLEAN
:
1135 nRet
= m_aValue
.m_bBool
;
1137 case DataType::TINYINT
:
1139 nRet
= m_aValue
.m_nInt8
;
1141 nRet
= static_cast<sal_Int8
>(m_aValue
.m_nInt16
);
1143 case DataType::SMALLINT
:
1145 nRet
= static_cast<sal_Int8
>(m_aValue
.m_nInt16
);
1147 nRet
= static_cast<sal_Int8
>(m_aValue
.m_nInt32
);
1149 case DataType::INTEGER
:
1151 nRet
= static_cast<sal_Int8
>(m_aValue
.m_nInt32
);
1153 nRet
= static_cast<sal_Int8
>(*static_cast<sal_Int64
*>(m_aValue
.m_pValue
));
1159 // -------------------------------------------------------------------------
1160 sal_Int16
ORowSetValue::getInt16() const
1162 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getInt16" );
1168 switch(getTypeKind())
1170 case DataType::CHAR
:
1171 case DataType::VARCHAR
:
1172 case DataType::DECIMAL
:
1173 case DataType::NUMERIC
:
1174 case DataType::LONGVARCHAR
:
1175 nRet
= sal_Int16(::rtl::OUString(m_aValue
.m_pString
).toInt32());
1177 case DataType::BIGINT
:
1179 nRet
= sal_Int16(*(sal_Int64
*)m_aValue
.m_pValue
);
1181 nRet
= sal_Int16(::rtl::OUString(m_aValue
.m_pString
).toInt32());
1183 case DataType::FLOAT
:
1184 nRet
= sal_Int16(*(float*)m_aValue
.m_pValue
);
1186 case DataType::DOUBLE
:
1187 case DataType::REAL
:
1188 nRet
= sal_Int16(*(double*)m_aValue
.m_pValue
);
1190 case DataType::DATE
:
1191 case DataType::TIME
:
1192 case DataType::TIMESTAMP
:
1193 case DataType::BINARY
:
1194 case DataType::VARBINARY
:
1195 case DataType::LONGVARBINARY
:
1196 OSL_ASSERT(!"getInt16() for this type is not allowed!");
1199 case DataType::BOOLEAN
:
1200 nRet
= m_aValue
.m_bBool
;
1202 case DataType::TINYINT
:
1204 nRet
= m_aValue
.m_nInt8
;
1206 nRet
= m_aValue
.m_nInt16
;
1208 case DataType::SMALLINT
:
1210 nRet
= m_aValue
.m_nInt16
;
1212 nRet
= static_cast<sal_Int16
>(m_aValue
.m_nInt32
);
1214 case DataType::INTEGER
:
1216 nRet
= static_cast<sal_Int16
>(m_aValue
.m_nInt32
);
1218 nRet
= static_cast<sal_Int16
>(*static_cast<sal_Int64
*>(m_aValue
.m_pValue
));
1224 // -------------------------------------------------------------------------
1225 sal_Int32
ORowSetValue::getInt32() const
1227 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getInt32" );
1231 switch(getTypeKind())
1233 case DataType::CHAR
:
1234 case DataType::VARCHAR
:
1235 case DataType::DECIMAL
:
1236 case DataType::NUMERIC
:
1237 case DataType::LONGVARCHAR
:
1238 nRet
= ::rtl::OUString(m_aValue
.m_pString
).toInt32();
1240 case DataType::BIGINT
:
1242 nRet
= sal_Int32(*(sal_Int64
*)m_aValue
.m_pValue
);
1244 nRet
= ::rtl::OUString(m_aValue
.m_pString
).toInt32();
1246 case DataType::FLOAT
:
1247 nRet
= sal_Int32(*(float*)m_aValue
.m_pValue
);
1249 case DataType::DOUBLE
:
1250 case DataType::REAL
:
1251 nRet
= sal_Int32(*(double*)m_aValue
.m_pValue
);
1253 case DataType::DATE
:
1254 nRet
= dbtools::DBTypeConversion::toDays(*(::com::sun::star::util::Date
*)m_aValue
.m_pValue
);
1256 case DataType::TIME
:
1257 case DataType::TIMESTAMP
:
1258 case DataType::BINARY
:
1259 case DataType::VARBINARY
:
1260 case DataType::LONGVARBINARY
:
1261 OSL_ASSERT(!"getInt32() for this type is not allowed!");
1264 case DataType::BOOLEAN
:
1265 nRet
= m_aValue
.m_bBool
;
1267 case DataType::TINYINT
:
1269 nRet
= m_aValue
.m_nInt8
;
1271 nRet
= m_aValue
.m_nInt16
;
1273 case DataType::SMALLINT
:
1275 nRet
= m_aValue
.m_nInt16
;
1277 nRet
= m_aValue
.m_nInt32
;
1279 case DataType::INTEGER
:
1281 nRet
= m_aValue
.m_nInt32
;
1283 nRet
= static_cast<sal_Int32
>(*static_cast<sal_Int64
*>(m_aValue
.m_pValue
));
1289 // -------------------------------------------------------------------------
1290 sal_Int64
ORowSetValue::getLong() const
1292 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getLong" );
1296 switch(getTypeKind())
1298 case DataType::CHAR
:
1299 case DataType::VARCHAR
:
1300 case DataType::DECIMAL
:
1301 case DataType::NUMERIC
:
1302 case DataType::LONGVARCHAR
:
1303 nRet
= ::rtl::OUString(m_aValue
.m_pString
).toInt64();
1305 case DataType::BIGINT
:
1307 nRet
= *(sal_Int64
*)m_aValue
.m_pValue
;
1309 nRet
= ::rtl::OUString(m_aValue
.m_pString
).toInt64();
1311 case DataType::FLOAT
:
1312 nRet
= sal_Int64(*(float*)m_aValue
.m_pValue
);
1314 case DataType::DOUBLE
:
1315 case DataType::REAL
:
1316 nRet
= sal_Int64(*(double*)m_aValue
.m_pValue
);
1318 case DataType::DATE
:
1319 nRet
= dbtools::DBTypeConversion::toDays(*(::com::sun::star::util::Date
*)m_aValue
.m_pValue
);
1321 case DataType::TIME
:
1322 case DataType::TIMESTAMP
:
1323 case DataType::BINARY
:
1324 case DataType::VARBINARY
:
1325 case DataType::LONGVARBINARY
:
1326 OSL_ASSERT(!"getInt32() for this type is not allowed!");
1329 case DataType::BOOLEAN
:
1330 nRet
= m_aValue
.m_bBool
;
1332 case DataType::TINYINT
:
1334 nRet
= m_aValue
.m_nInt8
;
1336 nRet
= m_aValue
.m_nInt16
;
1338 case DataType::SMALLINT
:
1340 nRet
= m_aValue
.m_nInt16
;
1342 nRet
= m_aValue
.m_nInt32
;
1344 case DataType::INTEGER
:
1346 nRet
= m_aValue
.m_nInt32
;
1348 nRet
= *(sal_Int64
*)m_aValue
.m_pValue
;
1354 // -------------------------------------------------------------------------
1355 float ORowSetValue::getFloat() const
1357 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getFloat" );
1361 switch(getTypeKind())
1363 case DataType::CHAR
:
1364 case DataType::VARCHAR
:
1365 case DataType::DECIMAL
:
1366 case DataType::NUMERIC
:
1367 case DataType::LONGVARCHAR
:
1368 nRet
= ::rtl::OUString(m_aValue
.m_pString
).toFloat();
1370 case DataType::BIGINT
:
1372 nRet
= float(*(sal_Int64
*)m_aValue
.m_pValue
);
1374 nRet
= ::rtl::OUString(m_aValue
.m_pString
).toFloat();
1376 case DataType::FLOAT
:
1377 nRet
= *(float*)m_aValue
.m_pValue
;
1379 case DataType::DOUBLE
:
1380 case DataType::REAL
:
1381 nRet
= (float)*(double*)m_aValue
.m_pValue
;
1383 case DataType::DATE
:
1384 nRet
= (float)dbtools::DBTypeConversion::toDouble(*(::com::sun::star::util::Date
*)m_aValue
.m_pValue
);
1386 case DataType::TIME
:
1387 nRet
= (float)dbtools::DBTypeConversion::toDouble(*(::com::sun::star::util::Time
*)m_aValue
.m_pValue
);
1389 case DataType::TIMESTAMP
:
1390 nRet
= (float)dbtools::DBTypeConversion::toDouble(*(::com::sun::star::util::DateTime
*)m_aValue
.m_pValue
);
1392 case DataType::BINARY
:
1393 case DataType::VARBINARY
:
1394 case DataType::LONGVARBINARY
:
1395 OSL_ASSERT(!"getDouble() for this type is not allowed!");
1398 case DataType::BOOLEAN
:
1399 nRet
= m_aValue
.m_bBool
;
1401 case DataType::TINYINT
:
1403 nRet
= m_aValue
.m_nInt8
;
1405 nRet
= m_aValue
.m_nInt16
;
1407 case DataType::SMALLINT
:
1409 nRet
= m_aValue
.m_nInt16
;
1411 nRet
= (float)m_aValue
.m_nInt32
;
1413 case DataType::INTEGER
:
1415 nRet
= (float)m_aValue
.m_nInt32
;
1417 nRet
= float(*(sal_Int64
*)m_aValue
.m_pValue
);
1423 // -------------------------------------------------------------------------
1424 double ORowSetValue::getDouble() const
1426 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getDouble" );
1432 switch(getTypeKind())
1434 case DataType::CHAR
:
1435 case DataType::VARCHAR
:
1436 case DataType::DECIMAL
:
1437 case DataType::NUMERIC
:
1438 case DataType::LONGVARCHAR
:
1439 nRet
= ::rtl::OUString(m_aValue
.m_pString
).toDouble();
1441 case DataType::BIGINT
:
1443 nRet
= double(*(sal_Int64
*)m_aValue
.m_pValue
);
1445 nRet
= ::rtl::OUString(m_aValue
.m_pString
).toDouble();
1447 case DataType::FLOAT
:
1448 nRet
= *(float*)m_aValue
.m_pValue
;
1450 case DataType::DOUBLE
:
1451 case DataType::REAL
:
1452 nRet
= *(double*)m_aValue
.m_pValue
;
1454 case DataType::DATE
:
1455 nRet
= dbtools::DBTypeConversion::toDouble(*(::com::sun::star::util::Date
*)m_aValue
.m_pValue
);
1457 case DataType::TIME
:
1458 nRet
= dbtools::DBTypeConversion::toDouble(*(::com::sun::star::util::Time
*)m_aValue
.m_pValue
);
1460 case DataType::TIMESTAMP
:
1461 nRet
= dbtools::DBTypeConversion::toDouble(*(::com::sun::star::util::DateTime
*)m_aValue
.m_pValue
);
1463 case DataType::BINARY
:
1464 case DataType::VARBINARY
:
1465 case DataType::LONGVARBINARY
:
1466 OSL_ASSERT(!"getDouble() for this type is not allowed!");
1469 case DataType::BOOLEAN
:
1470 nRet
= m_aValue
.m_bBool
;
1472 case DataType::TINYINT
:
1474 nRet
= m_aValue
.m_nInt8
;
1476 nRet
= m_aValue
.m_nInt16
;
1478 case DataType::SMALLINT
:
1480 nRet
= m_aValue
.m_nInt16
;
1482 nRet
= m_aValue
.m_nInt32
;
1484 case DataType::INTEGER
:
1486 nRet
= m_aValue
.m_nInt32
;
1488 nRet
= double(*(sal_Int64
*)m_aValue
.m_pValue
);
1494 // -------------------------------------------------------------------------
1495 void ORowSetValue::setFromDouble(const double& _rVal
,sal_Int32 _nDatatype
)
1497 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::setFromDouble" );
1500 m_bNull
= sal_False
;
1503 case DataType::CHAR
:
1504 case DataType::VARCHAR
:
1505 case DataType::DECIMAL
:
1506 case DataType::NUMERIC
:
1507 case DataType::LONGVARCHAR
:
1509 ::rtl::OUString aVal
= ::rtl::OUString::valueOf(_rVal
);
1510 m_aValue
.m_pString
= aVal
.pData
;
1511 rtl_uString_acquire(m_aValue
.m_pString
);
1514 case DataType::BIGINT
:
1517 m_aValue
.m_pValue
= new sal_Int64((sal_Int64
)_rVal
);
1518 TRACE_ALLOC( sal_Int64
)
1522 ::rtl::OUString aVal
= ::rtl::OUString::valueOf(_rVal
);
1523 m_aValue
.m_pString
= aVal
.pData
;
1524 rtl_uString_acquire(m_aValue
.m_pString
);
1527 case DataType::FLOAT
:
1528 m_aValue
.m_pValue
= new float((float)_rVal
);
1529 TRACE_ALLOC( float )
1531 case DataType::DOUBLE
:
1532 case DataType::REAL
:
1533 m_aValue
.m_pValue
= new double(_rVal
);
1534 TRACE_ALLOC( double )
1536 case DataType::DATE
:
1537 m_aValue
.m_pValue
= new Date(dbtools::DBTypeConversion::toDate(_rVal
));
1540 case DataType::TIME
:
1541 m_aValue
.m_pValue
= new Time(dbtools::DBTypeConversion::toTime(_rVal
));
1544 case DataType::TIMESTAMP
:
1545 m_aValue
.m_pValue
= new DateTime(dbtools::DBTypeConversion::toDateTime(_rVal
));
1546 TRACE_ALLOC( DateTime
)
1548 case DataType::BINARY
:
1549 case DataType::VARBINARY
:
1550 case DataType::LONGVARBINARY
:
1551 OSL_ASSERT(!"setFromDouble() for this type is not allowed!");
1554 case DataType::BOOLEAN
:
1555 m_aValue
.m_bBool
= _rVal
!= 0.0;
1557 case DataType::TINYINT
:
1559 m_aValue
.m_nInt8
= sal_Int8(_rVal
);
1561 m_aValue
.m_nInt16
= sal_Int16(_rVal
);
1563 case DataType::SMALLINT
:
1565 m_aValue
.m_nInt16
= sal_Int16(_rVal
);
1567 m_aValue
.m_nInt32
= sal_Int32(_rVal
);
1569 case DataType::INTEGER
:
1571 m_aValue
.m_nInt32
= sal_Int32(_rVal
);
1574 m_aValue
.m_pValue
= new sal_Int64((sal_Int64
)_rVal
);
1575 TRACE_ALLOC( sal_Int64
)
1579 m_eTypeKind
= _nDatatype
;
1581 // -----------------------------------------------------------------------------
1582 Sequence
<sal_Int8
> ORowSetValue::getSequence() const
1584 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getSequence" );
1585 Sequence
<sal_Int8
> aSeq
;
1590 case DataType::OBJECT
:
1591 case DataType::CLOB
:
1592 case DataType::BLOB
:
1594 Reference
<XInputStream
> xStream
;
1595 Any aValue
= getAny();
1596 if(aValue
.hasValue())
1600 xStream
->readBytes(aSeq
,xStream
->available());
1604 case DataType::VARCHAR
:
1605 case DataType::LONGVARCHAR
:
1607 ::rtl::OUString
sVal(m_aValue
.m_pString
);
1608 aSeq
= Sequence
<sal_Int8
>(reinterpret_cast<const sal_Int8
*>(sVal
.getStr()),sizeof(sal_Unicode
)*sVal
.getLength());
1611 case DataType::BINARY
:
1612 case DataType::VARBINARY
:
1613 case DataType::LONGVARBINARY
:
1614 aSeq
= *static_cast< Sequence
<sal_Int8
>*>(m_aValue
.m_pValue
);
1623 // -----------------------------------------------------------------------------
1624 ::com::sun::star::util::Date
ORowSetValue::getDate() const
1626 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getDate" );
1627 ::com::sun::star::util::Date aValue
;
1632 case DataType::CHAR
:
1633 case DataType::VARCHAR
:
1634 case DataType::LONGVARCHAR
:
1635 aValue
= DBTypeConversion::toDate(getString());
1637 case DataType::DECIMAL
:
1638 case DataType::NUMERIC
:
1639 aValue
= DBTypeConversion::toDate((double)*this);
1641 case DataType::FLOAT
:
1642 case DataType::DOUBLE
:
1643 case DataType::REAL
:
1644 aValue
= DBTypeConversion::toDate((double)*this);
1647 case DataType::DATE
:
1648 aValue
= *static_cast< ::com::sun::star::util::Date
*>(m_aValue
.m_pValue
);
1650 case DataType::TIMESTAMP
:
1652 ::com::sun::star::util::DateTime
* pDateTime
= static_cast< ::com::sun::star::util::DateTime
*>(m_aValue
.m_pValue
);
1653 aValue
.Day
= pDateTime
->Day
;
1654 aValue
.Month
= pDateTime
->Month
;
1655 aValue
.Year
= pDateTime
->Year
;
1662 // -----------------------------------------------------------------------------
1663 ::com::sun::star::util::Time
ORowSetValue::getTime() const
1665 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getTime" );
1666 ::com::sun::star::util::Time aValue
;
1671 case DataType::CHAR
:
1672 case DataType::VARCHAR
:
1673 case DataType::LONGVARCHAR
:
1674 aValue
= DBTypeConversion::toTime(getString());
1676 case DataType::DECIMAL
:
1677 case DataType::NUMERIC
:
1678 aValue
= DBTypeConversion::toTime((double)*this);
1680 case DataType::FLOAT
:
1681 case DataType::DOUBLE
:
1682 case DataType::REAL
:
1683 aValue
= DBTypeConversion::toTime((double)*this);
1685 case DataType::TIMESTAMP
:
1687 ::com::sun::star::util::DateTime
* pDateTime
= static_cast< ::com::sun::star::util::DateTime
*>(m_aValue
.m_pValue
);
1688 aValue
.HundredthSeconds
= pDateTime
->HundredthSeconds
;
1689 aValue
.Seconds
= pDateTime
->Seconds
;
1690 aValue
.Minutes
= pDateTime
->Minutes
;
1691 aValue
.Hours
= pDateTime
->Hours
;
1694 case DataType::TIME
:
1695 aValue
= *static_cast< ::com::sun::star::util::Time
*>(m_aValue
.m_pValue
);
1700 // -----------------------------------------------------------------------------
1701 ::com::sun::star::util::DateTime
ORowSetValue::getDateTime() const
1703 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getDateTime" );
1704 ::com::sun::star::util::DateTime aValue
;
1709 case DataType::CHAR
:
1710 case DataType::VARCHAR
:
1711 case DataType::LONGVARCHAR
:
1712 aValue
= DBTypeConversion::toDateTime(getString());
1714 case DataType::DECIMAL
:
1715 case DataType::NUMERIC
:
1716 aValue
= DBTypeConversion::toDateTime((double)*this);
1718 case DataType::FLOAT
:
1719 case DataType::DOUBLE
:
1720 case DataType::REAL
:
1721 aValue
= DBTypeConversion::toDateTime((double)*this);
1723 case DataType::DATE
:
1725 ::com::sun::star::util::Date
* pDate
= static_cast< ::com::sun::star::util::Date
*>(m_aValue
.m_pValue
);
1726 aValue
.Day
= pDate
->Day
;
1727 aValue
.Month
= pDate
->Month
;
1728 aValue
.Year
= pDate
->Year
;
1731 case DataType::TIME
:
1733 ::com::sun::star::util::Time
* pTime
= static_cast< ::com::sun::star::util::Time
*>(m_aValue
.m_pValue
);
1734 aValue
.HundredthSeconds
= pTime
->HundredthSeconds
;
1735 aValue
.Seconds
= pTime
->Seconds
;
1736 aValue
.Minutes
= pTime
->Minutes
;
1737 aValue
.Hours
= pTime
->Hours
;
1740 case DataType::TIMESTAMP
:
1741 aValue
= *static_cast< ::com::sun::star::util::DateTime
*>(m_aValue
.m_pValue
);
1747 // -----------------------------------------------------------------------------
1748 void ORowSetValue::setSigned(sal_Bool _bMod
)
1750 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::setSigned" );
1751 if ( m_bSigned
!= _bMod
)
1756 sal_Int32 nType
= m_eTypeKind
;
1759 case DataType::BIGINT
:
1760 if ( m_bSigned
) // now we are signed, so we were unsigned and need to call getString()
1762 m_bSigned
= !m_bSigned
;
1763 const ::rtl::OUString sValue
= getString();
1765 m_bSigned
= !m_bSigned
;
1770 m_bSigned
= !m_bSigned
;
1771 const sal_Int64 nValue
= getLong();
1773 m_bSigned
= !m_bSigned
;
1777 case DataType::TINYINT
:
1779 (*this) = getInt8();
1782 m_bSigned
= !m_bSigned
;
1783 (*this) = getInt16();
1784 m_bSigned
= !m_bSigned
;
1787 case DataType::SMALLINT
:
1789 (*this) = getInt16();
1792 m_bSigned
= !m_bSigned
;
1793 (*this) = getInt32();
1794 m_bSigned
= !m_bSigned
;
1797 case DataType::INTEGER
:
1799 (*this) = getInt32();
1802 m_bSigned
= !m_bSigned
;
1803 (*this) = getLong();
1804 m_bSigned
= !m_bSigned
;
1808 m_eTypeKind
= nType
;
1812 // -----------------------------------------------------------------------------
1813 void ORowSetValue::fill(sal_Int32 _nPos
,
1815 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XRow
>& _xRow
)
1817 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::fill (1)" );
1818 fill(_nPos
,_nType
,sal_True
,_xRow
);
1821 // -----------------------------------------------------------------------------
1822 void ORowSetValue::fill(sal_Int32 _nPos
,
1824 sal_Bool _bNullable
,
1825 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XRow
>& _xRow
)
1827 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::fill (2)" );
1828 sal_Bool bReadData
= sal_True
;
1831 case DataType::CHAR
:
1832 case DataType::VARCHAR
:
1833 case DataType::DECIMAL
:
1834 case DataType::NUMERIC
:
1835 case DataType::LONGVARCHAR
:
1836 (*this) = _xRow
->getString(_nPos
);
1838 case DataType::BIGINT
:
1840 (*this) = _xRow
->getLong(_nPos
);
1842 (*this) = _xRow
->getString(_nPos
);
1844 case DataType::FLOAT
:
1845 (*this) = _xRow
->getFloat(_nPos
);
1847 case DataType::DOUBLE
:
1848 case DataType::REAL
:
1849 (*this) = _xRow
->getDouble(_nPos
);
1851 case DataType::DATE
:
1852 (*this) = _xRow
->getDate(_nPos
);
1854 case DataType::TIME
:
1855 (*this) = _xRow
->getTime(_nPos
);
1857 case DataType::TIMESTAMP
:
1858 (*this) = _xRow
->getTimestamp(_nPos
);
1860 case DataType::BINARY
:
1861 case DataType::VARBINARY
:
1862 case DataType::LONGVARBINARY
:
1863 (*this) = _xRow
->getBytes(_nPos
);
1866 case DataType::BOOLEAN
:
1867 (*this) = _xRow
->getBoolean(_nPos
);
1869 case DataType::TINYINT
:
1871 (*this) = _xRow
->getByte(_nPos
);
1873 (*this) = _xRow
->getShort(_nPos
);
1875 case DataType::SMALLINT
:
1877 (*this) = _xRow
->getShort(_nPos
);
1879 (*this) = _xRow
->getInt(_nPos
);
1881 case DataType::INTEGER
:
1883 (*this) = _xRow
->getInt(_nPos
);
1885 (*this) = _xRow
->getLong(_nPos
);
1887 case DataType::CLOB
:
1888 (*this) = ::com::sun::star::uno::makeAny(_xRow
->getCharacterStream(_nPos
));
1889 setTypeKind(DataType::CLOB
);
1891 case DataType::BLOB
:
1892 (*this) = ::com::sun::star::uno::makeAny(_xRow
->getBinaryStream(_nPos
));
1893 setTypeKind(DataType::BLOB
);
1896 OSL_ENSURE( false, "ORowSetValue::fill: unsupported type!" );
1900 if ( bReadData
&& _bNullable
&& _xRow
->wasNull() )
1902 setTypeKind(_nType
);
1904 // -----------------------------------------------------------------------------
1905 void ORowSetValue::fill(const Any
& _rValue
)
1907 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::fill (3)" );
1908 switch (_rValue
.getValueType().getTypeClass())
1910 case TypeClass_VOID
:
1913 case TypeClass_BOOLEAN
:
1915 sal_Bool
bValue( sal_False
);
1920 case TypeClass_CHAR
:
1922 sal_Unicode
aDummy(0);
1924 (*this) = ::rtl::OUString(aDummy
);
1927 case TypeClass_STRING
:
1929 ::rtl::OUString sDummy
;
1934 case TypeClass_FLOAT
:
1941 case TypeClass_DOUBLE
:
1948 case TypeClass_BYTE
:
1955 case TypeClass_SHORT
:
1962 case TypeClass_LONG
:
1969 case TypeClass_UNSIGNED_SHORT
:
1971 sal_uInt16
nValue(0);
1973 (*this) = static_cast<sal_Int32
>(nValue
);
1974 setSigned(sal_False
);
1977 case TypeClass_HYPER
:
1979 sal_Int64
nValue(0);
1984 case TypeClass_UNSIGNED_HYPER
:
1986 sal_uInt64
nValue(0);
1988 (*this) = static_cast<sal_Int64
>(nValue
);
1989 setSigned(sal_False
);
1992 case TypeClass_UNSIGNED_LONG
:
1994 sal_uInt32
nValue(0);
1996 (*this) = static_cast<sal_Int64
>(nValue
);
1997 setSigned(sal_False
);
2000 case TypeClass_ENUM
:
2002 sal_Int32
enumValue( 0 );
2003 ::cppu::enum2int( enumValue
, _rValue
);
2004 (*this) = enumValue
;
2008 case TypeClass_SEQUENCE
:
2010 Sequence
<sal_Int8
> aDummy
;
2011 if ( _rValue
>>= aDummy
)
2014 OSL_ENSURE( false, "ORowSetValue::fill: unsupported sequence type!" );
2018 case TypeClass_STRUCT
:
2020 ::com::sun::star::util::Date aDate
;
2021 ::com::sun::star::util::Time aTime
;
2022 ::com::sun::star::util::DateTime aDateTime
;
2023 if ( _rValue
>>= aDate
)
2027 else if ( _rValue
>>= aTime
)
2031 else if ( _rValue
>>= aDateTime
)
2033 (*this) = aDateTime
;
2036 OSL_ENSURE( false, "ORowSetValue::fill: unsupported structure!" );
2042 OSL_ENSURE(0,"Unknown type");