Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
831f01b7
Kaydet (Commit)
831f01b7
authored
Eyl 19, 2013
tarafından
Andrzej J.R. Hunt
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Move type conversion into template.`
Change-Id: I7b646673eacf2abbac8a2bcfa744f840ff344c84
üst
79f1c6e5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
43 deletions
+32
-43
ResultSet.cxx
connectivity/source/drivers/firebird/ResultSet.cxx
+28
-36
ResultSet.hxx
connectivity/source/drivers/firebird/ResultSet.hxx
+4
-7
No files found.
connectivity/source/drivers/firebird/ResultSet.cxx
Dosyayı görüntüle @
831f01b7
...
@@ -368,13 +368,21 @@ bool OResultSet::isNull(const sal_Int32 nColumnIndex)
...
@@ -368,13 +368,21 @@ bool OResultSet::isNull(const sal_Int32 nColumnIndex)
return
false
;
return
false
;
}
}
ORowSetValue
OResultSet
::
retrieveConvertibleValue
(
const
sal_Int32
nColumnIndex
)
template
<
typename
T
>
T
OResultSet
::
retrieveValue
(
const
sal_Int32
nColumnIndex
,
const
ISC_SHORT
nType
)
{
{
MutexGuard
aGuard
(
m_rMutex
);
if
((
m_bWasNull
=
isNull
(
nColumnIndex
)))
checkDisposed
(
OResultSet_BASE
::
rBHelper
.
bDisposed
);
return
T
(
);
checkColumnIndex
(
nColumnIndex
);
if
((
m_pSqlda
->
sqlvar
[
nColumnIndex
-
1
].
sqltype
&
~
1
)
==
nType
)
checkRowIndex
();
return
*
((
T
*
)
m_pSqlda
->
sqlvar
[
nColumnIndex
-
1
].
sqldata
);
else
return
retrieveValue
<
ORowSetValue
>
(
nColumnIndex
,
0
);
}
template
<>
ORowSetValue
OResultSet
::
retrieveValue
(
const
sal_Int32
nColumnIndex
,
const
ISC_SHORT
/*nType*/
)
{
// See http://wiki.openoffice.org/wiki/Documentation/DevGuide/Database/Using_the_getXXX_Methods
// See http://wiki.openoffice.org/wiki/Documentation/DevGuide/Database/Using_the_getXXX_Methods
// (bottom of page) for a chart of possible conversions, we should allow all
// (bottom of page) for a chart of possible conversions, we should allow all
// of these -- Blob/Clob will probably need some specialist handling especially
// of these -- Blob/Clob will probably need some specialist handling especially
...
@@ -399,39 +407,25 @@ ORowSetValue OResultSet::retrieveConvertibleValue(const sal_Int32 nColumnIndex)
...
@@ -399,39 +407,25 @@ ORowSetValue OResultSet::retrieveConvertibleValue(const sal_Int32 nColumnIndex)
return
getFloat
(
nColumnIndex
);
return
getFloat
(
nColumnIndex
);
case
SQL_TIMESTAMP
:
case
SQL_TIMESTAMP
:
return
getTimestamp
(
nColumnIndex
);
return
getTimestamp
(
nColumnIndex
);
// case SQL_BLOB:
// return DataType::BLOB;
// case SQL_ARRAY:
// return DataType::ARRAY;
case
SQL_TYPE_TIME
:
case
SQL_TYPE_TIME
:
return
getTime
(
nColumnIndex
);
return
getTime
(
nColumnIndex
);
case
SQL_TYPE_DATE
:
case
SQL_TYPE_DATE
:
return
getTime
(
nColumnIndex
);
return
getTime
(
nColumnIndex
);
case
SQL_INT64
:
case
SQL_INT64
:
return
getLong
(
nColumnIndex
);
return
getLong
(
nColumnIndex
);
case
SQL_BLOB
:
case
SQL_NULL
:
case
SQL_NULL
:
assert
(
false
);
// We shouldn't really be returning this ever since
case
SQL_QUAD
:
// detection is separate.
case
SQL_ARRAY
:
// case SQL_QUAD: // Is a "Blob ID" according to the docs
// TODO: these are all invalid conversions, so maybe we should
// return 0; // TODO: verify
// throw an exception?
return
ORowSetValue
();
default
:
default
:
assert
(
false
);
assert
(
false
);
return
ORowSetValue
();
return
ORowSetValue
();
}
}
}
}
template
<
typename
T
>
T
OResultSet
::
retrieveValue
(
const
sal_Int32
nColumnIndex
,
const
ISC_SHORT
nType
)
{
if
((
m_bWasNull
=
isNull
(
nColumnIndex
)))
return
T
();
if
((
m_pSqlda
->
sqlvar
[
nColumnIndex
-
1
].
sqltype
&
~
1
)
==
nType
)
return
*
((
T
*
)
m_pSqlda
->
sqlvar
[
nColumnIndex
-
1
].
sqldata
);
else
return
retrieveConvertibleValue
(
nColumnIndex
);
}
template
<>
template
<>
Date
OResultSet
::
retrieveValue
(
const
sal_Int32
nColumnIndex
,
const
ISC_SHORT
/*nType*/
)
Date
OResultSet
::
retrieveValue
(
const
sal_Int32
nColumnIndex
,
const
ISC_SHORT
/*nType*/
)
{
{
...
@@ -446,7 +440,7 @@ Date OResultSet::retrieveValue(const sal_Int32 nColumnIndex, const ISC_SHORT /*n
...
@@ -446,7 +440,7 @@ Date OResultSet::retrieveValue(const sal_Int32 nColumnIndex, const ISC_SHORT /*n
}
}
else
else
{
{
return
retrieve
ConvertibleValue
(
nColumnIndex
);
return
retrieve
Value
<
ORowSetValue
>
(
nColumnIndex
,
0
);
}
}
}
}
...
@@ -466,7 +460,7 @@ Time OResultSet::retrieveValue(const sal_Int32 nColumnIndex, const ISC_SHORT /*n
...
@@ -466,7 +460,7 @@ Time OResultSet::retrieveValue(const sal_Int32 nColumnIndex, const ISC_SHORT /*n
}
}
else
else
{
{
return
retrieve
ConvertibleValue
(
nColumnIndex
);
return
retrieve
Value
<
ORowSetValue
>
(
nColumnIndex
,
0
);
}
}
}
}
...
@@ -487,16 +481,13 @@ DateTime OResultSet::retrieveValue(const sal_Int32 nColumnIndex, const ISC_SHORT
...
@@ -487,16 +481,13 @@ DateTime OResultSet::retrieveValue(const sal_Int32 nColumnIndex, const ISC_SHORT
}
}
else
else
{
{
return
retrieve
ConvertibleValue
(
nColumnIndex
);
return
retrieve
Value
<
ORowSetValue
>
(
nColumnIndex
,
0
);
}
}
}
}
template
<>
template
<>
OUString
OResultSet
::
retrieveValue
(
const
sal_Int32
nColumnIndex
,
const
ISC_SHORT
/*nType*/
)
OUString
OResultSet
::
retrieveValue
(
const
sal_Int32
nColumnIndex
,
const
ISC_SHORT
/*nType*/
)
{
{
if
((
m_bWasNull
=
isNull
(
nColumnIndex
)))
return
OUString
();
// &~1 to remove the "can contain NULL" indicator
// &~1 to remove the "can contain NULL" indicator
int
aSqlType
=
m_pSqlda
->
sqlvar
[
nColumnIndex
-
1
].
sqltype
&
~
1
;
int
aSqlType
=
m_pSqlda
->
sqlvar
[
nColumnIndex
-
1
].
sqltype
&
~
1
;
if
(
aSqlType
==
SQL_TEXT
)
if
(
aSqlType
==
SQL_TEXT
)
...
@@ -516,7 +507,7 @@ OUString OResultSet::retrieveValue(const sal_Int32 nColumnIndex, const ISC_SHORT
...
@@ -516,7 +507,7 @@ OUString OResultSet::retrieveValue(const sal_Int32 nColumnIndex, const ISC_SHORT
}
}
else
else
{
{
return
retrieve
ConvertibleValue
(
nColumnIndex
);
return
retrieve
Value
<
ORowSetValue
>
(
nColumnIndex
,
0
);
}
}
}
}
...
@@ -524,8 +515,6 @@ template <>
...
@@ -524,8 +515,6 @@ template <>
ISC_QUAD
*
OResultSet
::
retrieveValue
(
const
sal_Int32
nColumnIndex
,
const
ISC_SHORT
nType
)
ISC_QUAD
*
OResultSet
::
retrieveValue
(
const
sal_Int32
nColumnIndex
,
const
ISC_SHORT
nType
)
{
{
// TODO: this is probably wrong
// TODO: this is probably wrong
if
((
m_bWasNull
=
isNull
(
nColumnIndex
)))
return
0
;
if
((
m_pSqlda
->
sqlvar
[
nColumnIndex
-
1
].
sqltype
&
~
1
)
==
nType
)
if
((
m_pSqlda
->
sqlvar
[
nColumnIndex
-
1
].
sqltype
&
~
1
)
==
nType
)
return
(
ISC_QUAD
*
)
m_pSqlda
->
sqlvar
[
nColumnIndex
-
1
].
sqldata
;
return
(
ISC_QUAD
*
)
m_pSqlda
->
sqlvar
[
nColumnIndex
-
1
].
sqldata
;
else
else
...
@@ -541,6 +530,9 @@ T OResultSet::safelyRetrieveValue(const sal_Int32 nColumnIndex, const ISC_SHORT
...
@@ -541,6 +530,9 @@ T OResultSet::safelyRetrieveValue(const sal_Int32 nColumnIndex, const ISC_SHORT
checkColumnIndex
(
nColumnIndex
);
checkColumnIndex
(
nColumnIndex
);
checkRowIndex
();
checkRowIndex
();
if
((
m_bWasNull
=
isNull
(
nColumnIndex
)))
return
T
();
return
retrieveValue
<
T
>
(
nColumnIndex
,
nType
);
return
retrieveValue
<
T
>
(
nColumnIndex
,
nType
);
}
}
...
@@ -558,14 +550,14 @@ sal_Bool SAL_CALL OResultSet::getBoolean(sal_Int32 nColumnIndex)
...
@@ -558,14 +550,14 @@ sal_Bool SAL_CALL OResultSet::getBoolean(sal_Int32 nColumnIndex)
throw
(
SQLException
,
RuntimeException
)
throw
(
SQLException
,
RuntimeException
)
{
{
// Not a native firebird type hence we always have to convert.
// Not a native firebird type hence we always have to convert.
return
retrieveConvertibleValue
(
nColumnIndex
);
return
safelyRetrieveValue
<
ORowSetValue
>
(
nColumnIndex
,
0
);
}
}
sal_Int8
SAL_CALL
OResultSet
::
getByte
(
sal_Int32
nColumnIndex
)
sal_Int8
SAL_CALL
OResultSet
::
getByte
(
sal_Int32
nColumnIndex
)
throw
(
SQLException
,
RuntimeException
)
throw
(
SQLException
,
RuntimeException
)
{
{
// Not a native firebird type hence we always have to convert.
// Not a native firebird type hence we always have to convert.
return
retrieveConvertibleValue
(
nColumnIndex
);
return
safelyRetrieveValue
<
ORowSetValue
>
(
nColumnIndex
,
0
);
}
}
Sequence
<
sal_Int8
>
SAL_CALL
OResultSet
::
getBytes
(
sal_Int32
columnIndex
)
Sequence
<
sal_Int8
>
SAL_CALL
OResultSet
::
getBytes
(
sal_Int32
columnIndex
)
...
...
connectivity/source/drivers/firebird/ResultSet.hxx
Dosyayı görüntüle @
831f01b7
...
@@ -94,13 +94,6 @@ namespace connectivity
...
@@ -94,13 +94,6 @@ namespace connectivity
bool
isNull
(
const
sal_Int32
nColumnIndex
);
bool
isNull
(
const
sal_Int32
nColumnIndex
);
/**
* Retrieves a value to an ORowSetValue allowing for conversion
* at will. Should only be used if conversion is needed to avoid
* any performance hit otherwise.
*/
ORowSetValue
retrieveConvertibleValue
(
const
sal_Int32
nColumnIndex
);
template
<
typename
T
>
T
retrieveValue
(
const
sal_Int32
nColumnIndex
,
template
<
typename
T
>
T
retrieveValue
(
const
sal_Int32
nColumnIndex
,
const
ISC_SHORT
nType
);
const
ISC_SHORT
nType
);
...
@@ -207,6 +200,10 @@ namespace connectivity
...
@@ -207,6 +200,10 @@ namespace connectivity
OResultSet
::
retrieveValue
(
OResultSet
::
retrieveValue
(
const
sal_Int32
nColumnIndex
,
const
sal_Int32
nColumnIndex
,
const
ISC_SHORT
nType
);
const
ISC_SHORT
nType
);
template
<>
::
connectivity
::
ORowSetValue
OResultSet
::
retrieveValue
(
const
sal_Int32
nColumnIndex
,
const
ISC_SHORT
nType
);
template
<>
::
com
::
sun
::
star
::
util
::
Time
template
<>
::
com
::
sun
::
star
::
util
::
Time
OResultSet
::
retrieveValue
(
OResultSet
::
retrieveValue
(
const
sal_Int32
nColumnIndex
,
const
sal_Int32
nColumnIndex
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment