Commit ab0fd9e3 authored by msobczak's avatar msobczak

Change in the directory structure.

parent e9e3a9f3
# The following variable is specific to this backend and its correct
# values might depend on your environment - feel free to set it accordingly.
EMPTYINCLUDEDIR =
# The rest of the Makefile is indepentent of the target environment.
COMPILER = g++
CXXFLAGS = -Wall -pedantic -Wno-long-long
CXXFLAGSSO = ${CXXFLAGS} -fPIC
INCLUDEDIRS = -I../../core ${EMPTYINCLUDEDIR}
OBJECTS = blob.o factory.o row-id.o session.o standard-into-type.o \
standard-use-type.o statement.o vector-into-type.o vector-use-type.o
OBJECTSSO = blob-s.o factory-s.o row-id-s.o session-s.o \
standard-into-type-s.o standard-use-type-s.o statement-s.o \
vector-into-type-s.o vector-use-type-s.o
libsoci-empty.a : ${OBJECTS}
ar rv $@ $?
rm *.o
blob.o : blob.cpp
${COMPILER} -c $? ${CXXFLAGS} ${INCLUDEDIRS}
factory.o : factory.cpp
${COMPILER} -c $? ${CXXFLAGS} ${INCLUDEDIRS}
row-id.o : row-id.cpp
${COMPILER} -c $? ${CXXFLAGS} ${INCLUDEDIRS}
session.o : session.cpp
${COMPILER} -c $? ${CXXFLAGS} ${INCLUDEDIRS}
standard-into-type.o : standard-into-type.cpp
${COMPILER} -c $? ${CXXFLAGS} ${INCLUDEDIRS}
standard-use-type.o : standard-use-type.cpp
${COMPILER} -c $? ${CXXFLAGS} ${INCLUDEDIRS}
statement.o : statement.cpp
${COMPILER} -c $? ${CXXFLAGS} ${INCLUDEDIRS}
vector-into-type.o : vector-into-type.cpp
${COMPILER} -c $? ${CXXFLAGS} ${INCLUDEDIRS}
vector-use-type.o : vector-use-type.cpp
${COMPILER} -c $? ${CXXFLAGS} ${INCLUDEDIRS}
shared : ${OBJECTSSO}
${COMPILER} -shared -o libsoci-empty.so ${OBJECTSSO}
rm *.o
blob-s.o : blob.cpp
${COMPILER} -c -o $@ $? ${CXXFLAGSSO} ${INCLUDEDIRS}
factory-s.o : factory.cpp
${COMPILER} -c -o $@ $? ${CXXFLAGSSO} ${INCLUDEDIRS}
row-id-s.o : row-id.cpp
${COMPILER} -c -o $@ $? ${CXXFLAGSSO} ${INCLUDEDIRS}
session-s.o : session.cpp
${COMPILER} -c -o $@ $? ${CXXFLAGSSO} ${INCLUDEDIRS}
standard-into-type-s.o : standard-into-type.cpp
${COMPILER} -c -o $@ $? ${CXXFLAGSSO} ${INCLUDEDIRS}
standard-use-type-s.o : standard-use-type.cpp
${COMPILER} -c -o $@ $? ${CXXFLAGSSO} ${INCLUDEDIRS}
statement-s.o : statement.cpp
${COMPILER} -c -o $@ $? ${CXXFLAGSSO} ${INCLUDEDIRS}
vector-into-type-s.o : vector-into-type.cpp
${COMPILER} -c -o $@ $? ${CXXFLAGSSO} ${INCLUDEDIRS}
vector-use-type-s.o : vector-use-type.cpp
${COMPILER} -c -o $@ $? ${CXXFLAGSSO} ${INCLUDEDIRS}
clean :
rm -f libsoci-empty.a libsoci-empty.so
//
// Copyright (C) 2004-2006 Maciej Sobczak, Stephen Hutton
// 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.h"
#include "soci-empty.h"
#ifdef _MSC_VER
#pragma warning(disable:4355)
#endif
using namespace SOCI;
using namespace SOCI::details;
EmptyBLOBBackEnd::EmptyBLOBBackEnd(EmptySessionBackEnd &session)
: session_(session)
{
// ...
}
EmptyBLOBBackEnd::~EmptyBLOBBackEnd()
{
// ...
}
std::size_t EmptyBLOBBackEnd::getLen()
{
// ...
return 0;
}
std::size_t EmptyBLOBBackEnd::read(
std::size_t /* offset */, char * /* buf */, std::size_t /* toRead */)
{
// ...
return 0;
}
std::size_t EmptyBLOBBackEnd::write(
std::size_t /* offset */, char const * /* buf */,
std::size_t /* toWrite */)
{
// ...
return 0;
}
std::size_t EmptyBLOBBackEnd::append(
char const * /* buf */, std::size_t /* toWrite */)
{
// ...
return 0;
}
void EmptyBLOBBackEnd::trim(std::size_t /* newLen */)
{
// ...
}
//
// Copyright (C) 2004-2006 Maciej Sobczak, Stephen Hutton
// 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.h"
#include "soci-empty.h"
#ifdef _MSC_VER
#pragma warning(disable:4355)
#endif
using namespace SOCI;
using namespace SOCI::details;
// concrete factory for Empty concrete strategies
EmptySessionBackEnd * EmptyBackEndFactory::makeSession(
std::string const &connectString) const
{
return new EmptySessionBackEnd(connectString);
}
EmptyBackEndFactory const SOCI::empty;
//
// Copyright (C) 2004-2006 Maciej Sobczak, Stephen Hutton
// 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.h"
#include "soci-empty.h"
#ifdef _MSC_VER
#pragma warning(disable:4355)
#endif
using namespace SOCI;
using namespace SOCI::details;
EmptyRowIDBackEnd::EmptyRowIDBackEnd(EmptySessionBackEnd & /* session */)
{
// ...
}
EmptyRowIDBackEnd::~EmptyRowIDBackEnd()
{
// ...
}
//
// Copyright (C) 2004-2006 Maciej Sobczak, Stephen Hutton
// 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.h"
#include "soci-empty.h"
#ifdef _MSC_VER
#pragma warning(disable:4355)
#endif
using namespace SOCI;
using namespace SOCI::details;
EmptySessionBackEnd::EmptySessionBackEnd(
std::string const & /* connectString */)
{
// ...
}
EmptySessionBackEnd::~EmptySessionBackEnd()
{
cleanUp();
}
void EmptySessionBackEnd::begin()
{
// ...
}
void EmptySessionBackEnd::commit()
{
// ...
}
void EmptySessionBackEnd::rollback()
{
// ...
}
void EmptySessionBackEnd::cleanUp()
{
// ...
}
EmptyStatementBackEnd * EmptySessionBackEnd::makeStatementBackEnd()
{
return new EmptyStatementBackEnd(*this);
}
EmptyRowIDBackEnd * EmptySessionBackEnd::makeRowIDBackEnd()
{
return new EmptyRowIDBackEnd(*this);
}
EmptyBLOBBackEnd * EmptySessionBackEnd::makeBLOBBackEnd()
{
return new EmptyBLOBBackEnd(*this);
}
//
// Copyright (C) 2004-2006 Maciej Sobczak, Stephen Hutton
// 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)
//
#ifndef SOCI_EMPTY_H_INCLUDED
#define SOCI_EMPTY_H_INCLUDED
#include "soci-backend.h"
namespace SOCI
{
struct EmptyStatementBackEnd;
struct EmptyStandardIntoTypeBackEnd : details::StandardIntoTypeBackEnd
{
EmptyStandardIntoTypeBackEnd(EmptyStatementBackEnd &st)
: statement_(st) {}
virtual void defineByPos(int &position,
void *data, details::eExchangeType type);
virtual void preFetch();
virtual void postFetch(bool gotData, bool calledFromFetch,
eIndicator *ind);
virtual void cleanUp();
EmptyStatementBackEnd &statement_;
};
struct EmptyVectorIntoTypeBackEnd : details::VectorIntoTypeBackEnd
{
EmptyVectorIntoTypeBackEnd(EmptyStatementBackEnd &st)
: statement_(st) {}
virtual void defineByPos(int &position,
void *data, details::eExchangeType type);
virtual void preFetch();
virtual void postFetch(bool gotData, eIndicator *ind);
virtual void resize(std::size_t sz);
virtual std::size_t size();
virtual void cleanUp();
EmptyStatementBackEnd &statement_;
};
struct EmptyStandardUseTypeBackEnd : details::StandardUseTypeBackEnd
{
EmptyStandardUseTypeBackEnd(EmptyStatementBackEnd &st)
: statement_(st) {}
virtual void bindByPos(int &position,
void *data, details::eExchangeType type);
virtual void bindByName(std::string const &name,
void *data, details::eExchangeType type);
virtual void preUse(eIndicator const *ind);
virtual void postUse(bool gotData, eIndicator *ind);
virtual void cleanUp();
EmptyStatementBackEnd &statement_;
};
struct EmptyVectorUseTypeBackEnd : details::VectorUseTypeBackEnd
{
EmptyVectorUseTypeBackEnd(EmptyStatementBackEnd &st)
: statement_(st) {}
virtual void bindByPos(int &position,
void *data, details::eExchangeType type);
virtual void bindByName(std::string const &name,
void *data, details::eExchangeType type);
virtual void preUse(eIndicator const *ind);
virtual std::size_t size();
virtual void cleanUp();
EmptyStatementBackEnd &statement_;
};
struct EmptySessionBackEnd;
struct EmptyStatementBackEnd : details::StatementBackEnd
{
EmptyStatementBackEnd(EmptySessionBackEnd &session);
virtual void alloc();
virtual void cleanUp();
virtual void prepare(std::string const &query);
virtual execFetchResult execute(int number);
virtual execFetchResult fetch(int number);
virtual int getNumberOfRows();
virtual std::string rewriteForProcedureCall(std::string const &query);
virtual int prepareForDescribe();
virtual void describeColumn(int colNum, eDataType &dtype,
std::string &columnName);
virtual EmptyStandardIntoTypeBackEnd * makeIntoTypeBackEnd();
virtual EmptyStandardUseTypeBackEnd * makeUseTypeBackEnd();
virtual EmptyVectorIntoTypeBackEnd * makeVectorIntoTypeBackEnd();
virtual EmptyVectorUseTypeBackEnd * makeVectorUseTypeBackEnd();
EmptySessionBackEnd &session_;
};
struct EmptyRowIDBackEnd : details::RowIDBackEnd
{
EmptyRowIDBackEnd(EmptySessionBackEnd &session);
~EmptyRowIDBackEnd();
};
struct EmptyBLOBBackEnd : details::BLOBBackEnd
{
EmptyBLOBBackEnd(EmptySessionBackEnd &session);
~EmptyBLOBBackEnd();
virtual std::size_t getLen();
virtual std::size_t read(std::size_t offset, char *buf,
std::size_t toRead);
virtual std::size_t write(std::size_t offset, char const *buf,
std::size_t toWrite);
virtual std::size_t append(char const *buf, std::size_t toWrite);
virtual void trim(std::size_t newLen);
EmptySessionBackEnd &session_;
};
struct EmptySessionBackEnd : details::SessionBackEnd
{
EmptySessionBackEnd(std::string const &connectString);
~EmptySessionBackEnd();
virtual void begin();
virtual void commit();
virtual void rollback();
void cleanUp();
virtual EmptyStatementBackEnd * makeStatementBackEnd();
virtual EmptyRowIDBackEnd * makeRowIDBackEnd();
virtual EmptyBLOBBackEnd * makeBLOBBackEnd();
};
struct EmptyBackEndFactory : BackEndFactory
{
virtual EmptySessionBackEnd * makeSession(
std::string const &connectString) const;
};
extern EmptyBackEndFactory const empty;
} // namespace SOCI
#endif // SOCI_EMPTY_H_INCLUDED
//
// Copyright (C) 2004-2006 Maciej Sobczak, Stephen Hutton
// 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.h"
#include "soci-empty.h"
#ifdef _MSC_VER
#pragma warning(disable:4355)
#endif
using namespace SOCI;
using namespace SOCI::details;
void EmptyStandardIntoTypeBackEnd::defineByPos(
int & /* position */, void * /* data */, eExchangeType /* type */)
{
// ...
}
void EmptyStandardIntoTypeBackEnd::preFetch()
{
// ...
}
void EmptyStandardIntoTypeBackEnd::postFetch(
bool /* gotData */, bool /* calledFromFetch */, eIndicator * /* ind */)
{
// ...
}
void EmptyStandardIntoTypeBackEnd::cleanUp()
{
// ...
}
//
// Copyright (C) 2004-2006 Maciej Sobczak, Stephen Hutton
// 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.h"
#include "soci-empty.h"
#ifdef _MSC_VER
#pragma warning(disable:4355)
#endif
using namespace SOCI;
using namespace SOCI::details;
void EmptyStandardUseTypeBackEnd::bindByPos(
int & /* position */, void * /* data */, eExchangeType /* type */)
{
// ...
}
void EmptyStandardUseTypeBackEnd::bindByName(
std::string const & /* name */, void * /* data */,
eExchangeType /* type */)
{
// ...
}
void EmptyStandardUseTypeBackEnd::preUse(eIndicator const * /* ind */)
{
// ...
}
void EmptyStandardUseTypeBackEnd::postUse(
bool /* gotData */, eIndicator * /* ind */)
{
// ...
}
void EmptyStandardUseTypeBackEnd::cleanUp()
{
// ...
}
//
// Copyright (C) 2004-2006 Maciej Sobczak, Stephen Hutton
// 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.h"
#include "soci-empty.h"
#ifdef _MSC_VER
#pragma warning(disable:4355)
#endif
using namespace SOCI;
using namespace SOCI::details;
EmptyStatementBackEnd::EmptyStatementBackEnd(EmptySessionBackEnd &session)
: session_(session)
{
}
void EmptyStatementBackEnd::alloc()
{
// ...
}
void EmptyStatementBackEnd::cleanUp()
{
// ...
}
void EmptyStatementBackEnd::prepare(std::string const & /* query */)
{
// ...
}
StatementBackEnd::execFetchResult
EmptyStatementBackEnd::execute(int /* number */)
{
// ...
return eSuccess;
}
StatementBackEnd::execFetchResult
EmptyStatementBackEnd::fetch(int /* number */)
{
// ...
return eSuccess;
}
int EmptyStatementBackEnd::getNumberOfRows()
{
// ...
return 1;
}
std::string EmptyStatementBackEnd::rewriteForProcedureCall(
std::string const &query)
{
return query;
}
int EmptyStatementBackEnd::prepareForDescribe()
{
// ...
return 0;
}
void EmptyStatementBackEnd::describeColumn(int /* colNum */,
eDataType & /* type */, std::string & /* columnName */)
{
// ...
}
EmptyStandardIntoTypeBackEnd * EmptyStatementBackEnd::makeIntoTypeBackEnd()
{
return new EmptyStandardIntoTypeBackEnd(*this);
}
EmptyStandardUseTypeBackEnd * EmptyStatementBackEnd::makeUseTypeBackEnd()
{
return new EmptyStandardUseTypeBackEnd(*this);
}
EmptyVectorIntoTypeBackEnd *
EmptyStatementBackEnd::makeVectorIntoTypeBackEnd()
{
return new EmptyVectorIntoTypeBackEnd(*this);
}
EmptyVectorUseTypeBackEnd * EmptyStatementBackEnd::makeVectorUseTypeBackEnd()
{
return new EmptyVectorUseTypeBackEnd(*this);
}
COMPILER = g++
CXXFLAGS = -Wall -pedantic -Wno-long-long
INCLUDEDIRS = -I.. -I../../../core
LIBDIRS = -L.. -L../../../core
LIBS = -lsoci-core -lsoci-empty
test-empty : test-empty.cpp
${COMPILER} -o $@ $? ${CXXFLAGS} ${INCLUDEDIRS} ${LIBDIRS} ${LIBS}
clean :
rm -f test-empty
//
// Copyright (C) 2004-2006 Maciej Sobczak, Stephen Hutton
// 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.h"
#include "soci-empty.h"
#include <iostream>
#include <string>
#include <cassert>
#include <ctime>
using namespace SOCI;
std::string connectString;
BackEndFactory const &backEnd = empty;
// NOTE:
// This file is supposed to serve two purposes:
// 1. To be a starting point for implementing new tests (for new backends).
// 2. To exercise (at least some of) the syntax and try the SOCI library
// against different compilers, even in those environments where there
// is no database. SOCI uses advanced template techniques which are known
// to cause problems on different versions of popular compilers, and this
// test is handy to verify that the code is accepted by as many compilers
// as possible.
//
// Both of these purposes mean that the actual code here is meaningless
// from the database-development point of view. For new tests, you may wish
// to remove this code and keep only the general structure of this file.
struct Person
{
int id;
std::string firstName;
std::string lastName;
};
namespace SOCI
{
template<> struct TypeConversion<Person>
{
typedef Row base_type;
static Person from(Row& /* r */)
{
Person p;
return p;
}
};
}
void test1()
{
{
Session sql(backEnd, connectString);
sql << "Do what I want.";
sql << "Do what I want " << 123 << " times.";
std::string query = "some query";
sql << query;
int i = 7;
sql << "insert", use(i);
sql << "select", into(i);
eIndicator ind = eOK;
sql << "insert", use(i, ind);
sql << "select", into(i, ind);
std::vector<int> numbers(100);
sql << "insert", use(numbers);
sql << "select", into(numbers);
std::vector<eIndicator> inds(100);
sql << "insert", use(numbers, inds);
sql << "select", into(numbers, inds);
{
Statement st = (sql.prepare << "select", into(i));
st.execute();
st.fetch();
}
{
Statement st = (sql.prepare << "select", into(i, ind));
}
{
Statement st = (sql.prepare << "select", into(numbers));
}
{
Statement st = (sql.prepare << "select", into(numbers, inds));
}
{
Statement st = (sql.prepare << "insert", use(i));
}