ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [08/50] ignite git commit: IGNITE-2223: Reading of decimal value is implemented.
Date Mon, 25 Jan 2016 11:55:10 GMT
IGNITE-2223: Reading of decimal value is implemented.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7e32752f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7e32752f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7e32752f

Branch: refs/heads/ignite-1786
Commit: 7e32752feba55e6c8e88fe915c57ad22c4791e23
Parents: e5a2bfb
Author: isapego <isapego@gridgain.com>
Authored: Mon Jan 11 21:29:28 2016 +0300
Committer: isapego <isapego@gridgain.com>
Committed: Mon Jan 11 21:29:28 2016 +0300

----------------------------------------------------------------------
 .../odbc-driver/include/ignite/odbc/utility.h   | 10 +++++++++
 .../cpp/odbc/odbc-driver/src/utility.cpp        | 23 ++++++++++++++++++++
 2 files changed, 33 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7e32752f/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/utility.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/utility.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/utility.h
index ddb7e51..dbaefc9 100644
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/utility.h
+++ b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/utility.h
@@ -32,6 +32,8 @@
 #include "ignite/impl/binary/binary_reader_impl.h"
 #include "ignite/impl/binary/binary_writer_impl.h"
 
+#include "ignite/odbc/decimal.h"
+
 #ifdef ODBC_DEBUG
 
 extern FILE* log_file;
@@ -148,6 +150,14 @@ namespace ignite
         void WriteString(ignite::impl::binary::BinaryWriterImpl& writer, const std::string&
str);
 
         /**
+         * Read decimal value using reader.
+         *
+         * @param reader Reader.
+         * @param decimal Decimal value.
+         */
+        void ReadDecimal(ignite::impl::binary::BinaryReaderImpl& reader, Decimal&
decimal);
+
+        /**
          * Convert SQL string buffer to std::string.
          *
          * @param sqlStr SQL string buffer.

http://git-wip-us.apache.org/repos/asf/ignite/blob/7e32752f/modules/platforms/cpp/odbc/odbc-driver/src/utility.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/utility.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/utility.cpp
index 05347d8..3d30d43 100644
--- a/modules/platforms/cpp/odbc/odbc-driver/src/utility.cpp
+++ b/modules/platforms/cpp/odbc/odbc-driver/src/utility.cpp
@@ -15,6 +15,8 @@
  * limitations under the License.
  */
 
+#include <cassert>
+
 #include "ignite/odbc/utility.h"
 #include "ignite/odbc/system/odbc_constants.h"
 
@@ -59,6 +61,27 @@ namespace ignite
             writer.WriteString(str.data(), static_cast<int32_t>(str.size()));
         }
 
+        void ReadDecimal(ignite::impl::binary::BinaryReaderImpl& reader, Decimal&
decimal)
+        {
+            int8_t hdr = reader.ReadInt8();
+
+            assert(hdr == ignite::impl::binary::IGNITE_TYPE_DECIMAL);
+
+            int32_t scale = reader.ReadInt32();
+
+            int32_t len = reader.ReadInt32();
+
+            std::vector<int8_t> mag;
+
+            mag.resize(len);
+
+            reader.ReadInt8Array(mag.data(), mag.size());
+
+            Decimal res(scale, mag.data(), mag.size());
+
+            swap(decimal, res);
+        }
+
         std::string SqlStringToString(const unsigned char* sqlStr, int32_t sqlStrLen)
         {
             std::string res;


Mime
View raw message