data housekeeping

- removed naked pointers from Data interfaces
- fixed GH #82: name conflict in Data::Keywords::bind
- fixed GH #157: MySQL: cannot bind to 'long' data type on
Windows/Visual C++
- fixed GH #158: MySQL: MYSQL_BIND 'is_unsigned' member is not set
This commit is contained in:
Aleksandar Fabijanic
2013-04-28 12:34:07 -05:00
parent c6207985d8
commit a50823c5a8
34 changed files with 669 additions and 597 deletions

View File

@@ -74,6 +74,8 @@ class Data_API AbstractBinder
/// Interface for Binding data types to placeholders.
{
public:
typedef SharedPtr<AbstractBinder> Ptr;
enum Direction
/// Binding direction for a parameter.
{

View File

@@ -55,10 +55,13 @@ namespace Poco {
namespace Data {
class Data_API AbstractBinding: public Poco::RefCountedObject
class Data_API AbstractBinding
/// AbstractBinding connects a value with a placeholder via an AbstractBinder interface.
{
public:
typedef SharedPtr<AbstractBinding> Ptr;
typedef AbstractBinder::Ptr BinderPtr;
enum Direction
{
PD_IN = AbstractBinder::PD_IN,
@@ -72,10 +75,10 @@ public:
virtual ~AbstractBinding();
/// Destroys the AbstractBinding.
void setBinder(AbstractBinder* pBinder);
void setBinder(BinderPtr pBinder);
/// Sets the object used for binding; object does NOT take ownership of the pointer.
AbstractBinder* getBinder() const;
BinderPtr getBinder() const;
/// Returns the AbstractBinder used for binding data.
virtual std::size_t numOfColumnsHandled() const = 0;
@@ -112,23 +115,22 @@ public:
/// Returns the size of the bulk binding.
private:
AbstractBinder* _pBinder;
std::string _name;
Direction _direction;
Poco::UInt32 _bulkSize;
BinderPtr _pBinder;
std::string _name;
Direction _direction;
Poco::UInt32 _bulkSize;
};
typedef Poco::AutoPtr<AbstractBinding> AbstractBindingPtr;
typedef std::vector<AbstractBindingPtr> AbstractBindingVec;
typedef std::deque<AbstractBindingPtr> AbstractBindingDeq;
typedef std::list<AbstractBindingPtr> AbstractBindingLst;
typedef std::vector<AbstractBinding::Ptr> AbstractBindingVec;
typedef std::deque<AbstractBinding::Ptr> AbstractBindingDeq;
typedef std::list<AbstractBinding::Ptr> AbstractBindingLst;
//
// inlines
//
inline AbstractBinder* AbstractBinding::getBinder() const
inline AbstractBinder::Ptr AbstractBinding::getBinder() const
{
return _pBinder;
}

View File

@@ -59,11 +59,15 @@ class AbstractPreparation;
class AbstractPreparator;
class Data_API AbstractExtraction: public Poco::RefCountedObject
class Data_API AbstractExtraction
/// AbstractExtraction is the interface class that connects output positions to concrete values
/// retrieved via an AbstractExtractor.
{
public:
typedef SharedPtr<AbstractExtraction> Ptr;
typedef SharedPtr<AbstractExtractor> ExtractorPtr;
typedef SharedPtr<AbstractPreparator> PreparatorPtr;
AbstractExtraction(Poco::UInt32 limit = Limit::LIMIT_UNLIMITED,
Poco::UInt32 position = 0, bool bulk = false);
/// Creates the AbstractExtraction. A limit value equal to EXTRACT_UNLIMITED (0xffffffffu)
@@ -73,10 +77,10 @@ public:
virtual ~AbstractExtraction();
/// Destroys the AbstractExtraction.
void setExtractor(AbstractExtractor* pExtractor);
void setExtractor(ExtractorPtr pExtractor);
/// Sets the class used for extracting the data. Does not take ownership of the pointer.
AbstractExtractor* getExtractor() const;
ExtractorPtr getExtractor() const;
/// Retrieves the extractor object
Poco::UInt32 position() const;
@@ -109,8 +113,9 @@ public:
virtual bool canExtract() const;
/// Returns true. Implementations should override it for different behavior.
virtual AbstractPreparation* createPreparation(AbstractPreparator* pPrep, std::size_t pos) = 0;
/// Creates a Preparation object for the extracting object
virtual AbstractPreparation* createPreparation(PreparatorPtr& pPrep, std::size_t pos) = 0;
/// Creates a Preparation object for the extracting object. The returned pointer points to
/// a preparation object allocated on the heap; caller must take ownership of it.
void setLimit(Poco::UInt32 limit);
/// Sets the limit.
@@ -161,34 +166,33 @@ public:
/// - getEmptyStringIsNull() returns true
private:
AbstractExtractor* _pExtractor;
Poco::UInt32 _limit;
Poco::UInt32 _position;
bool _bulk;
bool _emptyStringIsNull;
bool _forceEmptyString;
ExtractorPtr _pExtractor;
Poco::UInt32 _limit;
Poco::UInt32 _position;
bool _bulk;
bool _emptyStringIsNull;
bool _forceEmptyString;
};
typedef Poco::AutoPtr<AbstractExtraction> AbstractExtractionPtr;
typedef std::vector<AbstractExtractionPtr> AbstractExtractionVec;
typedef std::vector<AbstractExtractionVec> AbstractExtractionVecVec;
typedef std::deque<AbstractExtractionPtr> AbstractExtractionDeq;
typedef std::vector<AbstractExtractionDeq> AbstractExtractionDeqVec;
typedef std::list<AbstractExtractionPtr> AbstractExtractionLst;
typedef std::vector<AbstractExtractionLst> AbstractExtractionLstVec;
typedef std::vector<AbstractExtraction::Ptr> AbstractExtractionVec;
typedef std::vector<AbstractExtractionVec> AbstractExtractionVecVec;
typedef std::deque<AbstractExtraction::Ptr> AbstractExtractionDeq;
typedef std::vector<AbstractExtractionDeq> AbstractExtractionDeqVec;
typedef std::list<AbstractExtraction::Ptr> AbstractExtractionLst;
typedef std::vector<AbstractExtractionLst> AbstractExtractionLstVec;
//
// inlines
//
inline void AbstractExtraction::setExtractor(AbstractExtractor* pExtractor)
inline void AbstractExtraction::setExtractor(ExtractorPtr pExtractor)
{
_pExtractor = pExtractor;
}
inline AbstractExtractor* AbstractExtraction::getExtractor() const
inline AbstractExtraction::ExtractorPtr AbstractExtraction::getExtractor() const
{
return _pExtractor;
}

View File

@@ -72,6 +72,8 @@ class Data_API AbstractExtractor
/// If an extractor receives null it is not allowed to change val!
{
public:
typedef SharedPtr<AbstractExtractor> Ptr;
AbstractExtractor();
/// Creates the AbstractExtractor.

View File

@@ -41,6 +41,8 @@
#include "Poco/Data/Data.h"
#include "Poco/Data/AbstractPreparator.h"
#include "Poco/SharedPtr.h"
#include <cstddef>
@@ -48,14 +50,14 @@ namespace Poco {
namespace Data {
class AbstractPreparator;
class Data_API AbstractPreparation
/// Interface for calling the appropriate AbstractPreparator method
{
public:
AbstractPreparation(AbstractPreparator* pPreparator);
typedef SharedPtr<AbstractPreparation> Ptr;
typedef AbstractPreparator::Ptr PreparatorPtr;
AbstractPreparation(PreparatorPtr pPreparator);
/// Creates the AbstractPreparation.
virtual ~AbstractPreparation();
@@ -65,17 +67,17 @@ public:
/// Preparations data.
protected:
AbstractPreparator* preparation();
PreparatorPtr preparation();
/// Returns the preparation object
AbstractPreparator* _pPreparator;
PreparatorPtr _pPreparator;
};
//
// inlines
//
inline AbstractPreparator* AbstractPreparation::preparation()
inline AbstractPreparation::PreparatorPtr AbstractPreparation::preparation()
{
return _pPreparator;
}

View File

@@ -78,6 +78,8 @@ class Data_API AbstractPreparator: public Poco::RefCountedObject
/// after SQL execution (e.g. SQLite) do not need this functionality at all.
{
public:
typedef SharedPtr<AbstractPreparator> Ptr;
AbstractPreparator(Poco::UInt32 length = 1u);
/// Creates the AbstractPreparator.

View File

@@ -73,6 +73,10 @@ class Binding: public AbstractBinding
/// function. An attempt to pass a constant by reference shall result in compile-time error.
{
public:
typedef typename T ValType;
typedef Binding<ValType> Type;
typedef SharedPtr<Type> Ptr;
explicit Binding(T& val,
const std::string& name = "",
Direction direction = PD_IN):
@@ -106,7 +110,7 @@ public:
void bind(std::size_t pos)
{
poco_assert_dbg(getBinder() != 0);
poco_assert_dbg(!getBinder().isNull());
TypeHandler<T>::bind(pos, _val, getBinder(), getDirection());
_bound = true;
}
@@ -114,8 +118,8 @@ public:
void reset ()
{
_bound = false;
AbstractBinder* pBinder = getBinder();
poco_check_ptr (pBinder);
AbstractBinder::Ptr pBinder = getBinder();
poco_assert_dbg (!pBinder.isNull());
pBinder->reset();
}
@@ -136,10 +140,13 @@ class CopyBinding: public AbstractBinding
/// is passed to binding, the storage it refers to must be valid at the statement execution time.
/// To pass a copy of a variable, constant or string literal, use utility function bind().
/// Variables can be passed as either copies or references (i.e. using either use() or bind()).
/// Constants, however, can only be passed as copies. this is best achieved using bind() utility
/// function. An attempt to pass a constant by reference shall result in compile-time error.
{
public:
typedef typename T ValType;
typedef SharedPtr<ValType> ValPtr;
typedef CopyBinding<ValType> Type;
typedef SharedPtr<Type> Ptr;
explicit CopyBinding(T& val,
const std::string& name = "",
Direction direction = PD_IN):
@@ -173,7 +180,7 @@ public:
void bind(std::size_t pos)
{
poco_assert_dbg(getBinder() != 0);
poco_assert_dbg(!getBinder().isNull());
TypeHandler<T>::bind(pos, *_pVal, getBinder(), getDirection());
_bound = true;
}
@@ -181,15 +188,15 @@ public:
void reset ()
{
_bound = false;
AbstractBinder* pBinder = getBinder();
poco_check_ptr (pBinder);
AbstractBinder::Ptr pBinder = getBinder();
poco_assert_dbg (!pBinder.isNull());
pBinder->reset();
}
private:
typedef typename TypeWrapper<T>::TYPE ValueType;
SharedPtr<ValueType> _pVal;
bool _bound;
//typedef typename TypeWrapper<T>::TYPE ValueType;
ValPtr _pVal;
bool _bound;
};
@@ -198,6 +205,11 @@ class Binding<const char*>: public AbstractBinding
/// Binding const char* specialization wraps char pointer into string.
{
public:
typedef const char* ValType;
typedef SharedPtr<ValType> ValPtr;
typedef Binding<const char*> Type;
typedef SharedPtr<Type> Ptr;
explicit Binding(const char* pVal,
const std::string& name = "",
Direction direction = PD_IN):
@@ -230,7 +242,7 @@ public:
void bind(std::size_t pos)
{
poco_assert_dbg(getBinder() != 0);
poco_assert_dbg(!getBinder().isNull());
TypeHandler<std::string>::bind(pos, _val, getBinder(), getDirection());
_bound = true;
}
@@ -238,8 +250,8 @@ public:
void reset ()
{
_bound = false;
AbstractBinder* pBinder = getBinder();
poco_check_ptr (pBinder);
AbstractBinder::Ptr pBinder = getBinder();
poco_assert_dbg (!pBinder.isNull());
pBinder->reset();
}
@@ -255,6 +267,11 @@ class CopyBinding<const char*>: public AbstractBinding
/// Binding const char* specialization wraps char pointer into string.
{
public:
typedef const char* ValType;
typedef SharedPtr<ValType> ValPtr;
typedef CopyBinding<const char*> Type;
typedef SharedPtr<Type> Ptr;
explicit CopyBinding(const char* pVal,
const std::string& name = "",
Direction direction = PD_IN):
@@ -287,7 +304,7 @@ public:
void bind(std::size_t pos)
{
poco_assert_dbg(getBinder() != 0);
poco_assert_dbg(!getBinder().isNull());
TypeHandler<std::string>::bind(pos, _val, getBinder(), getDirection());
_bound = true;
}
@@ -295,8 +312,8 @@ public:
void reset ()
{
_bound = false;
AbstractBinder* pBinder = getBinder();
poco_check_ptr (pBinder);
AbstractBinder::Ptr pBinder = getBinder();
poco_assert_dbg (!pBinder.isNull());
pBinder->reset();
}
@@ -311,6 +328,11 @@ class Binding<std::vector<T> >: public AbstractBinding
/// Specialization for std::vector.
{
public:
typedef std::vector<T> ValType;
typedef SharedPtr<ValType> ValPtr;
typedef SharedPtr<Binding<ValType> > Ptr;
typedef typename ValType::const_iterator Iterator;
explicit Binding(std::vector<T>& val,
const std::string& name = "",
Direction direction = PD_IN):
@@ -347,7 +369,7 @@ public:
void bind(std::size_t pos)
{
poco_assert_dbg(getBinder() != 0);
poco_assert_dbg(!getBinder().isNull());
poco_assert_dbg(canBind());
TypeHandler<T>::bind(pos, *_begin, getBinder(), getDirection());
@@ -361,12 +383,9 @@ public:
}
private:
typedef std::vector<T> Type;
typedef typename Type::const_iterator Iterator;
const Type& _val;
Iterator _begin;
Iterator _end;
const ValType& _val;
Iterator _begin;
Iterator _end;
};
@@ -375,6 +394,12 @@ class CopyBinding<std::vector<T> >: public AbstractBinding
/// Specialization for std::vector.
{
public:
typedef std::vector<T> ValType;
typedef SharedPtr<ValType> ValPtr;
typedef SharedPtr<CopyBinding<ValType> > Ptr;
typedef typename ValType::const_iterator Iterator;
explicit CopyBinding(std::vector<T>& val,
const std::string& name = "",
Direction direction = PD_IN):
@@ -411,7 +436,7 @@ public:
void bind(std::size_t pos)
{
poco_assert_dbg(getBinder() != 0);
poco_assert_dbg(!getBinder().isNull());
poco_assert_dbg(canBind());
TypeHandler<T>::bind(pos, *_begin, getBinder(), getDirection());
@@ -425,13 +450,9 @@ public:
}
private:
typedef std::vector<T> Type;
typedef SharedPtr<Type> TypePtr;
typedef typename Type::const_iterator Iterator;
TypePtr _pVal;
Iterator _begin;
Iterator _end;
ValPtr _pVal;
Iterator _begin;
Iterator _end;
};
@@ -451,6 +472,11 @@ class Binding<std::vector<bool> >: public AbstractBinding
/// Only IN binding is supported.
{
public:
typedef std::vector<bool> ValType;
typedef SharedPtr<ValType> ValPtr;
typedef SharedPtr<Binding<ValType> > Ptr;
typedef ValType::const_iterator Iterator;
explicit Binding(const std::vector<bool>& val,
const std::string& name = "",
Direction direction = PD_IN):
@@ -491,7 +517,7 @@ public:
void bind(std::size_t pos)
{
poco_assert_dbg(getBinder() != 0);
poco_assert_dbg(!getBinder().isNull());
poco_assert_dbg(canBind());
TypeHandler<bool>::bind(pos, *_begin, getBinder(), getDirection());
++_begin;
@@ -528,6 +554,11 @@ class CopyBinding<std::vector<bool> >: public AbstractBinding
/// Only IN binding is supported.
{
public:
typedef std::vector<bool> ValType;
typedef SharedPtr<ValType> ValPtr;
typedef SharedPtr<CopyBinding<ValType> > Ptr;
typedef ValType::const_iterator Iterator;
explicit CopyBinding(const std::vector<bool>& val,
const std::string& name = "",
Direction direction = PD_IN):
@@ -568,11 +599,10 @@ public:
void bind(std::size_t pos)
{
poco_assert_dbg(getBinder() != 0);
poco_assert_dbg(!getBinder().isNull());
poco_assert_dbg(canBind());
TypeHandler<bool>::bind(pos, *_begin, getBinder(), getDirection());
++_begin;
}
void reset()
@@ -593,6 +623,11 @@ class Binding<std::list<T> >: public AbstractBinding
/// Specialization for std::list.
{
public:
typedef std::list<T> ValType;
typedef SharedPtr<ValType> ValPtr;
typedef SharedPtr<Binding<ValType> > Ptr;
typedef typename ValType::const_iterator Iterator;
explicit Binding(std::list<T>& val,
const std::string& name = "",
Direction direction = PD_IN):
@@ -629,7 +664,7 @@ public:
void bind(std::size_t pos)
{
poco_assert_dbg(getBinder() != 0);
poco_assert_dbg(!getBinder().isNull());
poco_assert_dbg(canBind());
TypeHandler<T>::bind(pos, *_begin, getBinder(), getDirection());
++_begin;
@@ -642,12 +677,9 @@ public:
}
private:
typedef std::list<T> Type;
typedef typename Type::const_iterator Iterator;
const Type& _val;
Iterator _begin;
Iterator _end;
const ValType& _val;
Iterator _begin;
Iterator _end;
};
@@ -656,7 +688,12 @@ class CopyBinding<std::list<T> >: public AbstractBinding
/// Specialization for std::list.
{
public:
explicit CopyBinding(std::list<T>& val,
typedef typename std::list<T> ValType;
typedef SharedPtr<ValType> ValPtr;
typedef SharedPtr<CopyBinding<ValType> > Ptr;
typedef typename ValType::const_iterator Iterator;
explicit CopyBinding(ValType& val,
const std::string& name = "",
Direction direction = PD_IN):
AbstractBinding(name, direction),
@@ -692,7 +729,7 @@ public:
void bind(std::size_t pos)
{
poco_assert_dbg(getBinder() != 0);
poco_assert_dbg(!getBinder().isNull());
poco_assert_dbg(canBind());
TypeHandler<T>::bind(pos, *_begin, getBinder(), getDirection());
++_begin;
@@ -705,13 +742,9 @@ public:
}
private:
typedef std::list<T> Type;
typedef SharedPtr<Type> TypePtr;
typedef typename Type::const_iterator Iterator;
TypePtr _pVal;
Iterator _begin;
Iterator _end;
ValPtr _pVal;
Iterator _begin;
Iterator _end;
};
@@ -720,6 +753,11 @@ class Binding<std::deque<T> >: public AbstractBinding
/// Specialization for std::deque.
{
public:
typedef std::deque<T> ValType;
typedef SharedPtr<ValType> ValPtr;
typedef SharedPtr<Binding<ValType> > Ptr;
typedef typename ValType::const_iterator Iterator;
explicit Binding(std::deque<T>& val,
const std::string& name = "",
Direction direction = PD_IN):
@@ -756,7 +794,7 @@ public:
void bind(std::size_t pos)
{
poco_assert_dbg(getBinder() != 0);
poco_assert_dbg(!getBinder().isNull());
poco_assert_dbg(canBind());
TypeHandler<T>::bind(pos, *_begin, getBinder(), getDirection());
++_begin;
@@ -769,12 +807,9 @@ public:
}
private:
typedef std::deque<T> Type;
typedef typename Type::const_iterator Iterator;
const Type& _val;
Iterator _begin;
Iterator _end;
const ValType& _val;
Iterator _begin;
Iterator _end;
};
@@ -783,6 +818,11 @@ class CopyBinding<std::deque<T> >: public AbstractBinding
/// Specialization for std::deque.
{
public:
typedef std::deque<T> ValType;
typedef SharedPtr<ValType> ValPtr;
typedef SharedPtr<CopyBinding<ValType> > Ptr;
typedef typename ValType::const_iterator Iterator;
explicit CopyBinding(std::deque<T>& val,
const std::string& name = "",
Direction direction = PD_IN):
@@ -819,7 +859,7 @@ public:
void bind(std::size_t pos)
{
poco_assert_dbg(getBinder() != 0);
poco_assert_dbg(!getBinder().isNull());
poco_assert_dbg(canBind());
TypeHandler<T>::bind(pos, *_begin, getBinder(), getDirection());
++_begin;
@@ -832,13 +872,9 @@ public:
}
private:
typedef std::deque<T> Type;
typedef SharedPtr<Type> TypePtr;
typedef typename Type::const_iterator Iterator;
TypePtr _pVal;
Iterator _begin;
Iterator _end;
ValPtr _pVal;
Iterator _begin;
Iterator _end;
};
@@ -847,6 +883,11 @@ class Binding<std::set<T> >: public AbstractBinding
/// Specialization for std::set.
{
public:
typedef std::set<T> ValType;
typedef SharedPtr<ValType> ValPtr;
typedef SharedPtr<Binding<ValType> > Ptr;
typedef typename ValType::const_iterator Iterator;
explicit Binding(std::set<T>& val,
const std::string& name = "",
Direction direction = PD_IN):
@@ -883,7 +924,7 @@ public:
void bind(std::size_t pos)
{
poco_assert_dbg(getBinder() != 0);
poco_assert_dbg(!getBinder().isNull());
poco_assert_dbg(canBind());
TypeHandler<T>::bind(pos, *_begin, getBinder(), getDirection());
++_begin;
@@ -896,12 +937,9 @@ public:
}
private:
typedef std::set<T> Type;
typedef typename Type::const_iterator Iterator;
const Type& _val;
Iterator _begin;
Iterator _end;
const ValType& _val;
Iterator _begin;
Iterator _end;
};
@@ -910,6 +948,11 @@ class CopyBinding<std::set<T> >: public AbstractBinding
/// Specialization for std::set.
{
public:
typedef std::set<T> ValType;
typedef SharedPtr<ValType> ValPtr;
typedef SharedPtr<CopyBinding<ValType> > Ptr;
typedef typename ValType::const_iterator Iterator;
explicit CopyBinding(std::set<T>& val,
const std::string& name = "",
Direction direction = PD_IN):
@@ -946,7 +989,7 @@ public:
void bind(std::size_t pos)
{
poco_assert_dbg(getBinder() != 0);
poco_assert_dbg(!getBinder().isNull());
poco_assert_dbg(canBind());
TypeHandler<T>::bind(pos, *_begin, getBinder(), getDirection());
++_begin;
@@ -959,13 +1002,9 @@ public:
}
private:
typedef std::set<T> Type;
typedef SharedPtr<Type> TypePtr;
typedef typename Type::const_iterator Iterator;
TypePtr _pVal;
Iterator _begin;
Iterator _end;
ValPtr _pVal;
Iterator _begin;
Iterator _end;
};
@@ -974,6 +1013,11 @@ class Binding<std::multiset<T> >: public AbstractBinding
/// Specialization for std::multiset.
{
public:
typedef std::multiset<T> ValType;
typedef SharedPtr<ValType> ValPtr;
typedef SharedPtr<Binding<ValType> > Ptr;
typedef typename ValType::const_iterator Iterator;
explicit Binding(std::multiset<T>& val,
const std::string& name = "",
Direction direction = PD_IN):
@@ -1010,7 +1054,7 @@ public:
void bind(std::size_t pos)
{
poco_assert_dbg(getBinder() != 0);
poco_assert_dbg(!getBinder().isNull());
poco_assert_dbg(canBind());
TypeHandler<T>::bind(pos, *_begin, getBinder(), getDirection());
++_begin;
@@ -1023,12 +1067,9 @@ public:
}
private:
typedef std::multiset<T> Type;
typedef typename Type::const_iterator Iterator;
const Type& _val;
Iterator _begin;
Iterator _end;
const ValType& _val;
Iterator _begin;
Iterator _end;
};
@@ -1037,6 +1078,11 @@ class CopyBinding<std::multiset<T> >: public AbstractBinding
/// Specialization for std::multiset.
{
public:
typedef std::multiset<T> ValType;
typedef SharedPtr<ValType> ValPtr;
typedef SharedPtr<CopyBinding<ValType> > Ptr;
typedef typename ValType::const_iterator Iterator;
explicit CopyBinding(std::multiset<T>& val,
const std::string& name = "",
Direction direction = PD_IN):
@@ -1073,7 +1119,7 @@ public:
void bind(std::size_t pos)
{
poco_assert_dbg(getBinder() != 0);
poco_assert_dbg(!getBinder().isNull());
poco_assert_dbg(canBind());
TypeHandler<T>::bind(pos, *_begin, getBinder(), getDirection());
++_begin;
@@ -1086,13 +1132,9 @@ public:
}
private:
typedef std::multiset<T> Type;
typedef SharedPtr<Type> TypePtr;
typedef typename Type::const_iterator Iterator;
TypePtr _pVal;
Iterator _begin;
Iterator _end;
ValPtr _pVal;
Iterator _begin;
Iterator _end;
};
@@ -1101,6 +1143,11 @@ class Binding<std::map<K, V> >: public AbstractBinding
/// Specialization for std::map.
{
public:
typedef std::map<K, V> ValType;
typedef SharedPtr<ValType> ValPtr;
typedef SharedPtr<Binding<ValType> > Ptr;
typedef typename ValType::const_iterator Iterator;
explicit Binding(std::map<K, V>& val,
const std::string& name = "",
Direction direction = PD_IN):
@@ -1137,7 +1184,7 @@ public:
void bind(std::size_t pos)
{
poco_assert_dbg(getBinder() != 0);
poco_assert_dbg(!getBinder().isNull());
poco_assert_dbg(canBind());
TypeHandler<V>::bind(pos, _begin->second, getBinder(), getDirection());
++_begin;
@@ -1150,12 +1197,9 @@ public:
}
private:
typedef std::map<K, V> Type;
typedef typename Type::const_iterator Iterator;
const Type& _val;
Iterator _begin;
Iterator _end;
const ValType& _val;
Iterator _begin;
Iterator _end;
};
@@ -1164,6 +1208,11 @@ class CopyBinding<std::map<K, V> >: public AbstractBinding
/// Specialization for std::map.
{
public:
typedef std::map<K, V> ValType;
typedef SharedPtr<ValType> ValPtr;
typedef SharedPtr<CopyBinding<ValType> > Ptr;
typedef typename ValType::const_iterator Iterator;
explicit CopyBinding(std::map<K, V>& val,
const std::string& name = "",
Direction direction = PD_IN):
@@ -1200,7 +1249,7 @@ public:
void bind(std::size_t pos)
{
poco_assert_dbg(getBinder() != 0);
poco_assert_dbg(!getBinder().isNull());
poco_assert_dbg(canBind());
TypeHandler<V>::bind(pos, _begin->second, getBinder(), getDirection());
++_begin;
@@ -1213,13 +1262,9 @@ public:
}
private:
typedef std::map<K, V> Type;
typedef SharedPtr<Type> TypePtr;
typedef typename Type::const_iterator Iterator;
TypePtr _pVal;
Iterator _begin;
Iterator _end;
ValPtr _pVal;
Iterator _begin;
Iterator _end;
};
@@ -1228,6 +1273,11 @@ class Binding<std::multimap<K, V> >: public AbstractBinding
/// Specialization for std::multimap.
{
public:
typedef std::multimap<K, V> ValType;
typedef SharedPtr<ValType> ValPtr;
typedef SharedPtr<Binding<ValType> > Ptr;
typedef typename ValType::const_iterator Iterator;
explicit Binding(std::multimap<K, V>& val,
const std::string& name = "",
Direction direction = PD_IN):
@@ -1264,7 +1314,7 @@ public:
void bind(std::size_t pos)
{
poco_assert_dbg(getBinder() != 0);
poco_assert_dbg(!getBinder().isNull());
poco_assert_dbg(canBind());
TypeHandler<V>::bind(pos, _begin->second, getBinder(), getDirection());
++_begin;
@@ -1277,12 +1327,9 @@ public:
}
private:
typedef std::multimap<K, V> Type;
typedef typename Type::const_iterator Iterator;
const Type& _val;
Iterator _begin;
Iterator _end;
const ValType& _val;
Iterator _begin;
Iterator _end;
};
@@ -1291,6 +1338,11 @@ class CopyBinding<std::multimap<K, V> >: public AbstractBinding
/// Specialization for std::multimap.
{
public:
typedef std::multimap<K, V> ValType;
typedef SharedPtr<ValType> ValPtr;
typedef SharedPtr<CopyBinding<ValType> > Ptr;
typedef typename ValType::const_iterator Iterator;
explicit CopyBinding(std::multimap<K, V>& val,
const std::string& name = "",
Direction direction = PD_IN):
@@ -1327,7 +1379,7 @@ public:
void bind(std::size_t pos)
{
poco_assert_dbg(getBinder() != 0);
poco_assert_dbg(!getBinder().isNull());
poco_assert_dbg(canBind());
TypeHandler<V>::bind(pos, _begin->second, getBinder(), getDirection());
++_begin;
@@ -1340,13 +1392,9 @@ public:
}
private:
typedef std::multimap<K, V> Type;
typedef SharedPtr<Type> TypePtr;
typedef typename Type::const_iterator Iterator;
TypePtr _pVal;
Iterator _begin;
Iterator _end;
ValPtr _pVal;
Iterator _begin;
Iterator _end;
};
@@ -1354,29 +1402,27 @@ namespace Keywords {
template <typename T>
inline Binding<T>* use(T& t, const std::string& name = "")
inline AbstractBinding::Ptr use(T& t, const std::string& name = "")
/// Convenience function for a more compact Binding creation.
{
// If this test fails with an error, you tried to pass a const ref value to use().
// Resolve this either by using bind (which will copy the value) or
// if you are sure that the const ref will still exist when execute is called
// (which can be much later!), then use the "useRef" keyword instead
// If this fails to compile, a const ref was passed to use().
// This can be resolved by either (a) using bind (which will copy the value),
// or (b) if the const ref is guaranteed to exist when execute is called
// (which can be much later!), by using the "useRef" keyword instead
poco_static_assert (!IsConst<T>::VALUE);
return new Binding<T>(t, name, AbstractBinding::PD_IN);
}
inline Binding<NullData>* use(const NullData& t, const std::string& name = "")
inline AbstractBinding::Ptr use(const NullData& t, const std::string& name = "")
/// NullData overload.
{
return new Binding<NullData>(const_cast<NullData&>(t), name, AbstractBinding::PD_IN);
}
template <typename T>
inline Binding<T>* useRef(T& t, const std::string& name = "")
inline AbstractBinding::Ptr useRef(T& t, const std::string& name = "")
/// Convenience function for a more compact Binding creation.
{
return new Binding<T>(t, name, AbstractBinding::PD_IN);
@@ -1384,14 +1430,14 @@ inline Binding<T>* useRef(T& t, const std::string& name = "")
template <typename T>
inline Binding<T>* in(T& t, const std::string& name = "")
inline AbstractBinding::Ptr in(T& t, const std::string& name = "")
/// Convenience function for a more compact Binding creation.
{
return use(t, name);
}
inline Binding<NullData>* in(const NullData& t, const std::string& name = "")
inline AbstractBinding::Ptr in(const NullData& t, const std::string& name = "")
/// NullData overload.
{
return use(t, name);
@@ -1399,7 +1445,7 @@ inline Binding<NullData>* in(const NullData& t, const std::string& name = "")
template <typename T>
inline Binding<T>* out(T& t)
inline AbstractBinding::Ptr out(T& t)
/// Convenience function for a more compact Binding creation.
{
poco_static_assert (!IsConst<T>::VALUE);
@@ -1408,7 +1454,7 @@ inline Binding<T>* out(T& t)
template <typename T>
inline Binding<T>* io(T& t)
inline AbstractBinding::Ptr io(T& t)
/// Convenience function for a more compact Binding creation.
{
poco_static_assert (!IsConst<T>::VALUE);
@@ -1445,7 +1491,7 @@ inline AbstractBindingVec& io(AbstractBindingVec& bv)
template <typename T>
inline CopyBinding<T>* bind(T t, const std::string& name)
inline AbstractBinding::Ptr bind(T t, const std::string& name)
/// Convenience function for a more compact Binding creation.
/// This funtion differs from use() in its value copy semantics.
{
@@ -1454,11 +1500,11 @@ inline CopyBinding<T>* bind(T t, const std::string& name)
template <typename T>
inline CopyBinding<T>* bind(T t)
inline AbstractBinding::Ptr bind(T t)
/// Convenience function for a more compact Binding creation.
/// This funtion differs from use() in its value copy semantics.
{
return bind(t, "");
return Poco::Data::Keywords::bind(t, "");
}

View File

@@ -93,7 +93,7 @@ public:
void bind(std::size_t pos)
{
poco_assert_dbg(getBinder() != 0);
poco_assert_dbg(!getBinder().isNull());
TypeHandler<T>::bind(pos, _val, getBinder(), getDirection());
_bound = true;
}
@@ -114,7 +114,7 @@ namespace Keywords {
template <typename T>
BulkBinding<std::vector<T> >* use(const std::vector<T>& t, BulkFnType, const std::string& name = "")
AbstractBinding::Ptr use(const std::vector<T>& t, BulkFnType, const std::string& name = "")
/// Convenience function for a more compact BulkBinding creation for std::vector.
{
return new BulkBinding<std::vector<T> >(t, static_cast<Poco::UInt32>(t.size()), name);
@@ -122,7 +122,7 @@ BulkBinding<std::vector<T> >* use(const std::vector<T>& t, BulkFnType, const std
template <typename T>
BulkBinding<std::vector<T> >* in(const std::vector<T>& t, BulkFnType, const std::string& name = "")
AbstractBinding::Ptr in(const std::vector<T>& t, BulkFnType, const std::string& name = "")
/// Convenience function for a more compact BulkBinding creation for std::vector.
{
return new BulkBinding<std::vector<T> >(t, static_cast<Poco::UInt32>(t.size()), name);
@@ -130,7 +130,7 @@ BulkBinding<std::vector<T> >* in(const std::vector<T>& t, BulkFnType, const std:
template <typename T>
BulkBinding<std::deque<T> >* use(const std::deque<T>& t, BulkFnType, const std::string& name = "")
AbstractBinding::Ptr use(const std::deque<T>& t, BulkFnType, const std::string& name = "")
/// Convenience function for a more compact BulkBinding creation for std::deque.
{
return new BulkBinding<std::deque<T> >(t, static_cast<Poco::UInt32>(t.size()), name);
@@ -138,7 +138,7 @@ BulkBinding<std::deque<T> >* use(const std::deque<T>& t, BulkFnType, const std::
template <typename T>
BulkBinding<std::deque<T> >* in(const std::deque<T>& t, BulkFnType, const std::string& name = "")
AbstractBinding::Ptr in(const std::deque<T>& t, BulkFnType, const std::string& name = "")
/// Convenience function for a more compact BulkBinding creation for std::deque.
{
return new BulkBinding<std::deque<T> >(t, static_cast<Poco::UInt32>(t.size()), name);
@@ -146,7 +146,7 @@ BulkBinding<std::deque<T> >* in(const std::deque<T>& t, BulkFnType, const std::s
template <typename T>
BulkBinding<std::list<T> >* use(const std::list<T>& t, BulkFnType, const std::string& name = "")
AbstractBinding::Ptr use(const std::list<T>& t, BulkFnType, const std::string& name = "")
/// Convenience function for a more compact BulkBinding creation for std::list.
{
return new BulkBinding<std::list<T> >(t, static_cast<Poco::UInt32>(t.size()), name);
@@ -154,7 +154,7 @@ BulkBinding<std::list<T> >* use(const std::list<T>& t, BulkFnType, const std::st
template <typename T>
BulkBinding<std::list<T> >* in(const std::list<T>& t, BulkFnType, const std::string& name = "")
AbstractBinding::Ptr in(const std::list<T>& t, BulkFnType, const std::string& name = "")
/// Convenience function for a more compact BulkBinding creation for std::list.
{
return new BulkBinding<std::list<T> >(t, static_cast<Poco::UInt32>(t.size()), name);

View File

@@ -128,7 +128,7 @@ public:
{
}
AbstractPreparation* createPreparation(AbstractPreparator* pPrep, std::size_t col)
AbstractPreparation* createPreparation(AbstractPreparator::Ptr& pPrep, std::size_t col)
{
Poco::UInt32 limit = getLimit();
if (limit != _rResult.size()) _rResult.resize(limit);
@@ -221,7 +221,7 @@ namespace Keywords {
template <typename T>
BulkExtraction<std::vector<T> >* into(std::vector<T>& t, const Bulk& bulk, const Position& pos = Position(0))
AbstractExtraction::Ptr into(std::vector<T>& t, const Bulk& bulk, const Position& pos = Position(0))
/// Convenience function to allow for a more compact creation of an extraction object
/// with std::vector bulk extraction support.
{
@@ -230,7 +230,7 @@ BulkExtraction<std::vector<T> >* into(std::vector<T>& t, const Bulk& bulk, const
template <typename T>
BulkExtraction<std::vector<T> >* into(std::vector<T>& t, BulkFnType, const Position& pos = Position(0))
AbstractExtraction::Ptr into(std::vector<T>& t, BulkFnType, const Position& pos = Position(0))
/// Convenience function to allow for a more compact creation of an extraction object
/// with std::vector bulk extraction support.
{
@@ -241,7 +241,7 @@ BulkExtraction<std::vector<T> >* into(std::vector<T>& t, BulkFnType, const Posit
template <typename T>
BulkExtraction<std::deque<T> >* into(std::deque<T>& t, const Bulk& bulk, const Position& pos = Position(0))
AbstractExtraction::Ptr into(std::deque<T>& t, const Bulk& bulk, const Position& pos = Position(0))
/// Convenience function to allow for a more compact creation of an extraction object
/// with std::deque bulk extraction support.
{
@@ -250,7 +250,7 @@ BulkExtraction<std::deque<T> >* into(std::deque<T>& t, const Bulk& bulk, const P
template <typename T>
BulkExtraction<std::deque<T> >* into(std::deque<T>& t, BulkFnType, const Position& pos = Position(0))
AbstractExtraction::Ptr into(std::deque<T>& t, BulkFnType, const Position& pos = Position(0))
/// Convenience function to allow for a more compact creation of an extraction object
/// with std::deque bulk extraction support.
{
@@ -261,7 +261,7 @@ BulkExtraction<std::deque<T> >* into(std::deque<T>& t, BulkFnType, const Positio
template <typename T>
BulkExtraction<std::list<T> >* into(std::list<T>& t, const Bulk& bulk, const Position& pos = Position(0))
AbstractExtraction::Ptr into(std::list<T>& t, const Bulk& bulk, const Position& pos = Position(0))
/// Convenience function to allow for a more compact creation of an extraction object
/// with std::list bulk extraction support.
{
@@ -270,7 +270,7 @@ BulkExtraction<std::list<T> >* into(std::list<T>& t, const Bulk& bulk, const Pos
template <typename T>
BulkExtraction<std::list<T> >* into(std::list<T>& t, BulkFnType, const Position& pos = Position(0))
AbstractExtraction::Ptr into(std::list<T>& t, BulkFnType, const Position& pos = Position(0))
/// Convenience function to allow for a more compact creation of an extraction object
/// with std::list bulk extraction support.
{

View File

@@ -130,7 +130,7 @@ public:
return !_extracted;
}
AbstractPreparation* createPreparation(AbstractPreparator* pPrep, std::size_t pos)
AbstractPreparation* createPreparation(AbstractPreparator::Ptr& pPrep, std::size_t pos)
{
return new Preparation<T>(pPrep, pos, _rResult);
}
@@ -204,7 +204,7 @@ public:
return 1u;
}
AbstractPreparation* createPreparation(AbstractPreparator* pPrep, std::size_t pos)
AbstractPreparation* createPreparation(AbstractPreparator::Ptr& pPrep, std::size_t pos)
{
return new Preparation<T>(pPrep, pos, _default);
}
@@ -285,7 +285,7 @@ public:
return 1u;
}
AbstractPreparation* createPreparation(AbstractPreparator* pPrep, std::size_t pos)
AbstractPreparation* createPreparation(AbstractPreparator::Ptr& pPrep, std::size_t pos)
{
return new Preparation<bool>(pPrep, pos, _default);
}
@@ -364,7 +364,7 @@ public:
return 1u;
}
AbstractPreparation* createPreparation(AbstractPreparator* pPrep, std::size_t pos)
AbstractPreparation* createPreparation(AbstractPreparator::Ptr& pPrep, std::size_t pos)
{
return new Preparation<T>(pPrep, pos, _default);
}
@@ -443,7 +443,7 @@ public:
return 1u;
}
AbstractPreparation* createPreparation(AbstractPreparator* pPrep, std::size_t pos)
AbstractPreparation* createPreparation(AbstractPreparator::Ptr& pPrep, std::size_t pos)
{
return new Preparation<T>(pPrep, pos, _default);
}
@@ -576,7 +576,7 @@ public:
return 1u;
}
AbstractPreparation* createPreparation(AbstractPreparator* pPrep, std::size_t pos)
AbstractPreparation* createPreparation(AbstractPreparator::Ptr& pPrep, std::size_t pos)
{
return new Preparation<T>(pPrep, pos, _default);
}
@@ -635,7 +635,7 @@ public:
return 1u;
}
AbstractPreparation* createPreparation(AbstractPreparator* pPrep, std::size_t pos)
AbstractPreparation* createPreparation(AbstractPreparator::Ptr& pPrep, std::size_t pos)
{
return new Preparation<T>(pPrep, pos, _default);
}
@@ -694,7 +694,7 @@ public:
return 1u;
}
AbstractPreparation* createPreparation(AbstractPreparator* pPrep, std::size_t pos)
AbstractPreparation* createPreparation(AbstractPreparator::Ptr& pPrep, std::size_t pos)
{
return new Preparation<V>(pPrep, pos, _default);
}
@@ -753,7 +753,7 @@ public:
return 1u;
}
AbstractPreparation* createPreparation(AbstractPreparator* pPrep, std::size_t pos)
AbstractPreparation* createPreparation(AbstractPreparator::Ptr& pPrep, std::size_t pos)
{
return new Preparation<V>(pPrep, pos, _default);
}
@@ -768,7 +768,7 @@ namespace Keywords {
template <typename T>
inline Extraction<T>* into(T& t)
inline AbstractExtraction::Ptr into(T& t)
/// Convenience function to allow for a more compact creation of an extraction object.
{
return new Extraction<T>(t);
@@ -776,7 +776,7 @@ inline Extraction<T>* into(T& t)
template <typename T>
inline Extraction<T>* into(T& t, const Position& pos)
inline AbstractExtraction::Ptr into(T& t, const Position& pos)
/// Convenience function to allow for a more compact creation of an extraction object
/// with multiple recordset support.
{
@@ -785,7 +785,7 @@ inline Extraction<T>* into(T& t, const Position& pos)
template <typename T>
inline Extraction<T>* into(T& t, const Position& pos, const T& def)
inline AbstractExtraction::Ptr into(T& t, const Position& pos, const T& def)
/// Convenience function to allow for a more compact creation of an extraction object
/// with multiple recordset support and the given default
{

View File

@@ -56,7 +56,7 @@ class Preparation: public AbstractPreparation
/// Class for calling the appropriate AbstractPreparator method.
{
public:
Preparation(AbstractPreparator* pPreparator, std::size_t pos, T& val):
Preparation(AbstractPreparator::Ptr& pPreparator, std::size_t pos, T& val):
AbstractPreparation(pPreparator),
_pos(pos),
_val(val)

View File

@@ -42,6 +42,7 @@
#include "Poco/Data/Data.h"
#include "Poco/Data/StatementImpl.h"
#include "Poco/Data/Binding.h"
#include "Poco/Data/Range.h"
#include "Poco/Data/Bulk.h"
#include "Poco/Data/Row.h"
@@ -82,8 +83,8 @@ class Data_API Statement
///
/// Once asyncronous, a statement can be reverted back to synchronous state in two ways:
///
/// 1) By calling setAsync(false)
/// 2) By means of 'sync' or 'reset' manipulators
/// 1) By calling setAsync(false)
/// 2) By means of 'sync' or 'reset' manipulators
///
/// See individual functions documentation for more details.
///
@@ -110,7 +111,7 @@ public:
STORAGE_UNKNOWN = StatementImpl::STORAGE_UNKNOWN_IMPL
};
Statement(StatementImpl* pImpl);
Statement(StatementImpl::Ptr pImpl);
/// Creates the Statement.
explicit Statement(Session& session);
@@ -153,19 +154,11 @@ public:
Statement& operator , (Manipulator manip);
/// Handles manipulators, such as now, async, etc.
Statement& operator , (AbstractBinding* bind);
Statement& operator , (AbstractBinding::Ptr pBind);
/// Registers the Binding with the Statement by calling addBind().
/// Statement takes the ownership of the bind in an AutoPtr.
/// To prevent bind destruction upon statement destruction, pass an
/// AutoPtr<AbstractBinding>::duplicate() to this function.
/// This function is primarily intended to be a destination for
/// use() and bind() utility functions return value, so it is
/// recommended to call addBind() directly instead.
Statement& addBind(AbstractBinding* pBind, bool duplicate = true);
Statement& addBind(AbstractBinding::Ptr pBind);
/// Registers a single binding with the statement.
/// To allow the binding to outlive the statement destruction,
/// duplicate must be true.
void removeBind(const std::string& name);
/// Removes the all the bindings with specified name from the statement.
@@ -173,20 +166,20 @@ public:
Statement& operator , (AbstractBindingVec& bindVec);
/// Registers the Binding vector with the Statement.
Statement& operator , (AbstractExtraction* extract);
template <typename C>
Statement& addBinding(C& bindingCont, bool reset)
/// Registers binding container with the Statement.
{
if (reset) _pImpl->resetBinding();
typename C::iterator itAB = bindingCont.begin();
typename C::iterator itABEnd = bindingCont.end();
for (; itAB != itABEnd; ++itAB) addBind(*itAB);
return *this;
}
Statement& operator , (AbstractExtraction::Ptr extract);
/// Registers objects used for extracting data with the Statement by
/// calling addExtract().
/// Statement takes the ownership of the extract in an AutoPtr.
/// To prevent extract destruction upon statement destruction, pass an
/// AutoPtr<AbstractExtraction>::duplicate() to this function.
/// This function is primarily intended to be a destination for
/// into() utility function return value, so it is recommended to call
/// addExtract() directly instead.
Statement& addExtract(AbstractExtraction* pExtract, bool duplicate = true);
/// Registers a single extraction with the statement.
/// To allow the extraction to outlive the statement destruction,
/// duplicate must be true.
Statement& operator , (AbstractExtractionVec& extVec);
/// Registers the extraction vector with the Statement.
@@ -195,17 +188,6 @@ public:
Statement& operator , (AbstractExtractionVecVec& extVecVec);
/// Registers the vector of extraction vectors with the Statement.
template <typename C>
Statement& addBinding(C& bindingCont, bool reset)
/// Registers binding container with the Statement.
{
if (reset) _pImpl->resetBinding();
typename C::iterator itAB = bindingCont.begin();
typename C::iterator itABEnd = bindingCont.end();
for (; itAB != itABEnd; ++itAB) addBind(itAB->duplicate());
return *this;
}
template <typename C>
Statement& addExtraction(C& val, bool reset)
/// Registers extraction container with the Statement.
@@ -213,7 +195,7 @@ public:
if (reset) _pImpl->resetExtraction();
typename C::iterator itAE = val.begin();
typename C::iterator itAEEnd = val.end();
for (; itAE != itAEEnd; ++itAE) addExtract(itAE->duplicate());
for (; itAE != itAEEnd; ++itAE) addExtract(*itAE);
return *this;
}
@@ -228,7 +210,9 @@ public:
return *this;
}
Statement& addExtract(AbstractExtraction::Ptr pExtract);
/// Registers a single extraction with the statement.
Statement& operator , (const Bulk& bulk);
/// Sets the bulk execution mode (both binding and extraction) for this
/// statement.Statement must not have any extractors or binders set at the
@@ -406,7 +390,7 @@ public:
/// Statement takes the ownership of the formatter.
protected:
typedef Poco::AutoPtr<StatementImpl> StatementImplPtr;
typedef StatementImpl::Ptr ImplPtr;
const AbstractExtractionVec& extractions() const;
/// Returns the extractions vector.
@@ -423,7 +407,7 @@ protected:
bool isBulkExtraction() const;
/// Returns true if this statement extracts data in bulk.
StatementImplPtr impl() const;
ImplPtr impl() const;
/// Returns pointer to statement implementation.
const RowFormatterPtr& getRowFormatter();
@@ -433,6 +417,7 @@ protected:
/// Returns the underlying session.
private:
const Result& doAsyncExec(bool reset = true);
/// Asynchronously executes the statement.
@@ -443,7 +428,7 @@ private:
return *this;
}
StatementImplPtr _pImpl;
StatementImpl::Ptr _pImpl;
// asynchronous execution related members
bool _async;
@@ -656,9 +641,9 @@ inline void Statement::removeBind(const std::string& name)
}
inline Statement& Statement::operator , (AbstractBinding* pBind)
inline Statement& Statement::operator , (AbstractBinding::Ptr pBind)
{
return addBind(pBind, false);
return addBind(pBind);
}
@@ -668,9 +653,9 @@ inline Statement& Statement::operator , (AbstractBindingVec& bindVec)
}
inline Statement& Statement::operator , (AbstractExtraction* pExtract)
inline Statement& Statement::operator , (AbstractExtraction::Ptr pExtract)
{
return addExtract(pExtract, false);
return addExtract(pExtract);
}
@@ -686,7 +671,7 @@ inline Statement& Statement::operator , (AbstractExtractionVecVec& extVecVec)
}
inline Statement::StatementImplPtr Statement::impl() const
inline Statement::ImplPtr Statement::impl() const
{
return _pImpl;
}

View File

@@ -50,7 +50,6 @@
#include "Poco/Data/BulkExtraction.h"
#include "Poco/Data/SessionImpl.h"
#include "Poco/RefCountedObject.h"
#include "Poco/AutoPtr.h"
#include "Poco/String.h"
#include "Poco/Format.h"
#include "Poco/Exception.h"
@@ -65,12 +64,14 @@ namespace Poco {
namespace Data {
class Data_API StatementImpl: public Poco::RefCountedObject
class Data_API StatementImpl
/// StatementImpl interface that subclasses must implement to define database dependent query execution.
///
/// StatementImpl's are noncopyable.
{
public:
typedef Poco::SharedPtr<StatementImpl> Ptr;
enum State
{
ST_INITIALIZED,
@@ -127,14 +128,14 @@ public:
_ostr << t;
}
void addBind(AbstractBinding* pBinding);
void addBind(AbstractBinding::Ptr pBinding);
/// Registers the Binding with the StatementImpl.
void removeBind(const std::string& name);
/// Unregisters all the bindings having specified name with the StatementImpl.
/// Bindings are released and, if this class was the sole owner, deleted.
void addExtract(AbstractExtraction* pExtraction);
void addExtract(AbstractExtraction::Ptr pExtraction);
/// Registers objects used for extracting data with the StatementImpl.
void setExtractionLimit(const Limit& extrLimit);
@@ -216,14 +217,23 @@ protected:
virtual void bindImpl() = 0;
/// Binds parameters.
virtual AbstractExtractor& extractor() = 0;
virtual AbstractExtraction::ExtractorPtr extractor() = 0;
/// Returns the concrete extractor used by the statement.
const AbstractExtractionVec& extractions() const;
/// Returns the extractions vector.
/// Returns the const reference to extractions vector.
virtual AbstractBinder& binder() = 0;
/// Returns the concrete binder used by the statement.
AbstractExtractionVec& extractions();
/// Returns the reference to extractions vector.
void fixupExtraction();
/// Sets the AbstractExtractor at the extractors.
std::size_t getExtractionLimit();
/// Returns the extraction limit value.
const Limit& extractionLimit() const;
/// Returns the extraction limit.
std::size_t columnsExtracted(int dataSet = USE_CURRENT_DATA_SET) const;
/// Returns the number of columns that the extractors handle.
@@ -236,15 +246,6 @@ protected:
/// Returns the number of rows extracted so far for the data set.
/// Default value indicates current data set (if any).
const AbstractBindingVec& bindings() const;
/// Returns the bindings.
AbstractBindingVec& bindings();
/// Returns the bindings.
AbstractExtractionVec& extractions();
/// Returns the extractions vector.
void makeExtractors(std::size_t count);
/// Determines the type of the internal extraction container and
/// calls the extraction creation function (addInternalExtract)
@@ -270,6 +271,15 @@ protected:
SessionImpl& session();
/// Rteurns session associated with this statement.
virtual AbstractBinding::BinderPtr binder() = 0;
/// Returns the concrete binder used by the statement.
const AbstractBindingVec& bindings() const;
/// Returns the const reference to bindings vector.
AbstractBindingVec& bindings();
/// Returns the reference to bindings.
void fixupBinding();
/// Sets the AbstractBinder at the bindings.
@@ -290,9 +300,6 @@ protected:
/// When connector-specific behavior is desired, it should be overriden
/// by the statement implementation.
void fixupExtraction();
/// Sets the AbstractExtractor at the extractors.
std::size_t currentDataSet() const;
/// Returns the current data set.
@@ -307,12 +314,6 @@ protected:
bool hasMoreDataSets() const;
/// Returns true if there are data sets not activated yet.
std::size_t getExtractionLimit();
/// Returns the extraction limit value.
const Limit& extractionLimit() const;
/// Returns the extraction limit.
private:
void compile();
/// Compiles the statement.
@@ -472,7 +473,7 @@ private:
//
inline void StatementImpl::addBind(AbstractBinding* pBinding)
inline void StatementImpl::addBind(AbstractBinding::Ptr pBinding)
{
poco_check_ptr (pBinding);
_bindings.push_back(pBinding);