Ejemplo n.º 1
0
        void WriteDecimal(ignite::impl::binary::BinaryWriterImpl& writer, const common::Decimal& decimal)
        {
            writer.WriteInt8(ignite::impl::binary::IGNITE_TYPE_DECIMAL);

            const common::BigInteger &unscaled = decimal.GetUnscaledValue();

            int32_t signFlag = unscaled.GetSign() == -1 ? 0x80000000 : 0;

            writer.WriteInt32(decimal.GetScale() | signFlag);

            common::FixedSizeArray<int8_t> magnitude;

            unscaled.MagnitudeToBytes(magnitude);

            writer.WriteInt32(magnitude.GetSize());

            impl::binary::BinaryUtils::WriteInt8Array(writer.GetStream(), magnitude.GetData(), magnitude.GetSize());
        }
Ejemplo n.º 2
0
            void Parameter::Write(ignite::impl::binary::BinaryWriterImpl& writer) const
            {
                switch (sqlType)
                {
                    case SQL_CHAR:
                    case SQL_VARCHAR:
                    case SQL_LONGVARCHAR:
                    {
                        utility::WriteString(writer, buffer.GetString(columnSize));
                        break;
                    }

                    case SQL_SMALLINT:
                    {
                        writer.WriteInt16(buffer.GetInt16());
                        break;
                    }

                    case SQL_INTEGER:
                    {
                        writer.WriteInt32(buffer.GetInt32());
                        break;
                    }

                    case SQL_FLOAT:
                    {
                        writer.WriteFloat(buffer.GetFloat());
                        break;
                    }

                    case SQL_DOUBLE:
                    {
                        writer.WriteDouble(buffer.GetDouble());
                        break;
                    }

                    case SQL_TINYINT:
                    {
                        writer.WriteInt8(buffer.GetInt8());
                        break;
                    }

                    case SQL_BIT:
                    {
                        writer.WriteBool(buffer.GetInt8() != 0);
                        break;
                    }

                    case SQL_BIGINT:
                    {
                        writer.WriteInt64(buffer.GetInt64());
                        break;
                    }

                    case SQL_DATE:
                    {
                        writer.WriteDate(buffer.GetDate());
                        break;
                    }

                    case SQL_TIMESTAMP:
                    {
                        writer.WriteTimestamp(buffer.GetTimestamp());
                        break;
                    }

                    case SQL_BINARY:
                    case SQL_VARBINARY:
                    case SQL_LONGVARBINARY:
                    {
                        writer.WriteInt8Array(reinterpret_cast<const int8_t*>(buffer.GetData()),
                                              static_cast<int32_t>(buffer.GetSize()));
                        break;
                    }

                    case SQL_GUID:
                    {
                        writer.WriteGuid(buffer.GetGuid());

                        break;
                    }

                    case SQL_DECIMAL:
                    {
                        //TODO: Add Decimal type support.
                        break;
                    }

                    default:
                        break;
                }
            }
Ejemplo n.º 3
0
 void WriteString(ignite::impl::binary::BinaryWriterImpl& writer, const std::string & str)
 {
     writer.WriteString(str.data(), static_cast<int32_t>(str.size()));
 }