Hi,

I don't really know how to branch and submit my changes through git,
if you could guide me I would be very happy.

Please find attached the file for the sqlite3 backend.
it works so far.

best regards,
Sylvain
//
// Copyright (C) 2004-2006 Maciej Sobczak, Stephen Hutton, David Courtney
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//

#include <soci-platform.h>
#include "soci-sqlite3.h"
#include "rowid.h"
#include "common.h"
#include "blob.h"
// std
#include <cstdlib>
#include <ctime>
#include <string>

using namespace soci;
using namespace soci::details;
using namespace soci::details::sqlite3;

void sqlite3_standard_into_type_backend::define_by_pos(int & position, void * data,
                                                       exchange_type type)
{
    data_ = data;
    type_ = type;
    position_ = position++;
}

void sqlite3_standard_into_type_backend::pre_fetch()
{
    // ...
}

void sqlite3_standard_into_type_backend::post_fetch(bool gotData,
                                               bool calledFromFetch,
                                               indicator * ind)
{
    if (calledFromFetch == true && gotData == false)
    {
        // this is a normal end-of-rowset condition,
        // no need to do anything (fetch() will return false)
        return;
    }

    // sqlite columns start at 0
    int const pos = position_ - 1;

    if (gotData)
    {
        // first, deal with indicators
        if (sqlite3_column_type(statement_.stmt_, pos) == SQLITE_NULL)
        {
            if (ind == NULL)
            {
                throw soci_error(
                    "Null value fetched and no indicator defined.");
            }

            *ind = i_null;
            return;
        }
        else
        {
            if (ind != NULL)
            {
                *ind = i_ok;
            }
        }

        switch (type_)
        {
        case x_char:
            {
                const char *val = reinterpret_cast<const char*>(sqlite3_column_text(statement_.stmt_,pos));
                char *dest = static_cast<char*>(data_);
                *dest = *val;
            }
            break;
        case x_stdstring:
            {
                const char *val = reinterpret_cast<const char*>(sqlite3_column_text(statement_.stmt_,pos));
                std::string *dest = static_cast<std::string *>(data_);
                dest->assign(val);
            }
            break;
        case x_short:
            {
                int val = sqlite3_column_int(statement_.stmt_,pos);
                short *dest = static_cast<short*>(data_);
                *dest = static_cast<short>(val);
            }
            break;
        case x_integer:
            {
                int val = sqlite3_column_int(statement_.stmt_,pos);
                int *dest = static_cast<int*>(data_);
                *dest = val;
            }
            break;
        case x_unsigned_long:
            {
                int val = sqlite3_column_int(statement_.stmt_,pos);
                unsigned long* dest = static_cast<unsigned long*>(data_);
                *dest = static_cast<unsigned long>(val);
            }
            break;
        case x_long_long:
            {
                long long val = sqlite3_column_int64(statement_.stmt_,pos);
                long long* dest = static_cast<long long*>(data_);
                *dest = val;
            }
            break;
        case x_unsigned_long_long:
            {
                long long val = sqlite3_column_int64(statement_.stmt_,pos);
                unsigned long long* dest = static_cast<unsigned long long*>(data_);
                *dest = static_cast<unsigned long long>(val);
            }
            break;
        case x_double:
            {
                double val = sqlite3_column_double(statement_.stmt_,pos);
                double *dest = static_cast<double*>(data_);
                *dest = val;
            }
            break;
        case x_stdtm:
            {
                const char *val = reinterpret_cast<const char*>(sqlite3_column_text(statement_.stmt_,pos));
                // attempt to parse the string and convert to std::tm
                std::tm *dest = static_cast<std::tm *>(data_);
                parse_std_tm(val, *dest);
            }
            break;
        case x_rowid:
            {
                long long val = sqlite3_column_int64(statement_.stmt_,pos);
                // RowID is internally identical to unsigned long
                rowid *rid = static_cast<rowid*>(data_);
                sqlite3_rowid_backend *rbe = static_cast<sqlite3_rowid_backend *>(rid->get_backend());
                rbe->value_ = static_cast<unsigned long>(val);
            }
            break;
        case x_blob:
            {
                blob *b = static_cast<blob *>(data_);
                sqlite3_blob_backend *bbe =
                    static_cast<sqlite3_blob_backend *>(b->get_backend());

                const char *buf = reinterpret_cast<const char*>(sqlite3_column_blob(
                    statement_.stmt_,
                    pos));

                int len = sqlite3_column_bytes(statement_.stmt_, pos);
                bbe->set_data(buf, len);
            }
            break;
        default:
            throw soci_error("Into element used with non-supported type.");
        }
    }
}

void sqlite3_standard_into_type_backend::clean_up()
{
    // ...
}
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users

Reply via email to