- introduced Poco::Dynamic namespace

- moved/renamed:
Poco::DynamicAny => Poco::Dynamic::Var
Poco::DynamicAny typedef for backward compatibility (deprecated)
DynamicAny.h forwarding header for backward compatibility (deprecated)

Poco::DynamicAnyHolder => Poco::Dynamic::VarHolder
DynamicAnyHolder.h forwarding header for backward compatibility (deprecated)

Poco::DynamicStruct => Poco::Dynamic::Struct
Poco::DynamicStruct typedef for backward compatibility (deprecated)
DynamicStruct.h forwarding header for backward compatibility (deprecated)

- changed FastMutex to Mutex in Data::SessionPool (deadlocking)
This commit is contained in:
Aleksandar Fabijanic 2008-11-16 16:54:37 +00:00
parent 9d9db7ce90
commit 4b4ec9393c
52 changed files with 5982 additions and 8162 deletions

View File

@ -14,7 +14,8 @@ objects = AbstractBinder AbstractBinding AbstractExtraction AbstractExtractor \
PooledSessionHolder PooledSessionImpl Position \
Range RecordSet Row RowFilter RowFormatter RowIterator \
SimpleRowFormatter Session SessionFactory SessionImpl \
SessionPool SQLChannel Statement StatementCreator StatementImpl Time
SessionPool SessionPoolContainer SQLChannel \
Statement StatementCreator StatementImpl Time
target = PocoData
target_version = $(LIBVERSION)

View File

@ -43,6 +43,7 @@
#include "Poco/Data/BulkExtraction.h"
#include "Poco/Data/BulkBinding.h"
#include "Poco/NumberFormatter.h"
#include "Poco/String.h"
#include "Poco/Exception.h"
#include <iostream>
@ -187,7 +188,7 @@ public:
try
{
session() <<
format("INSERT INTO MiscTest VALUES (?,%s,?,?,?,?)", blobPlaceholder),
Poco::format("INSERT INTO MiscTest VALUES (?,%s,?,?,?,?)", blobPlaceholder),
use(strings),
use(blobs),
use(ints),
@ -204,7 +205,7 @@ public:
try
{
session() <<
format("INSERT INTO MiscTest VALUES (?,%s,?,?,?,?)", blobPlaceholder),
Poco::format("INSERT INTO MiscTest VALUES (?,%s,?,?,?,?)", blobPlaceholder),
use(strings, bulk),
use(blobs, bulk),
use(ints, bulk),

View File

@ -46,7 +46,7 @@
#include "Poco/Data/BLOB.h"
#include "Poco/DateTime.h"
#include "Poco/Any.h"
#include "Poco/DynamicAny.h"
#include "Poco/Dynamic/Var.h"
#include <vector>
#include <deque>
#include <list>
@ -326,8 +326,8 @@ public:
void bind(std::size_t pos, const Any& val, Direction dir = PD_IN);
/// Binds an Any.
void bind(std::size_t pos, const DynamicAny& val, Direction dir = PD_IN);
/// Binds a DynamicAny.
void bind(std::size_t pos, const Poco::Dynamic::Var& val, Direction dir = PD_IN);
/// Binds a Var.
virtual void reset();
/// Resets a binder. No-op by default. Implement for binders that cache data.

View File

@ -54,8 +54,10 @@ namespace Poco {
class DateTime;
class Any;
class DynamicAny;
namespace Dynamic {
class Var;
}
namespace Data {
@ -306,17 +308,17 @@ public:
virtual bool extract(std::size_t pos, std::list<Any>& val);
/// Extracts an Any list.
virtual bool extract(std::size_t pos, DynamicAny& val) = 0;
/// Extracts a DynamicAny. Returns false if null was received.
virtual bool extract(std::size_t pos, Poco::Dynamic::Var& val) = 0;
/// Extracts a Var. Returns false if null was received.
virtual bool extract(std::size_t pos, std::vector<DynamicAny>& val);
/// Extracts a DynamicAny vector.
virtual bool extract(std::size_t pos, std::vector<Poco::Dynamic::Var>& val);
/// Extracts a Var vector.
virtual bool extract(std::size_t pos, std::deque<DynamicAny>& val);
/// Extracts a DynamicAny deque.
virtual bool extract(std::size_t pos, std::deque<Poco::Dynamic::Var>& val);
/// Extracts a Var deque.
virtual bool extract(std::size_t pos, std::list<DynamicAny>& val);
/// Extracts a DynamicAny list.
virtual bool extract(std::size_t pos, std::list<Poco::Dynamic::Var>& val);
/// Extracts a Var list.
virtual bool isNull(std::size_t col, std::size_t row = POCO_DATA_INVALID_ROW) = 0;
/// Returns true if the value at [col,row] position is null.

View File

@ -53,7 +53,10 @@ namespace Poco {
class DateTime;
class Any;
class DynamicAny;
namespace Dynamic {
class Var;
}
namespace Data {
@ -310,17 +313,17 @@ public:
virtual void prepare(std::size_t pos, const std::list<Any>& val);
/// Prepares an Any list.
virtual void prepare(std::size_t pos, const DynamicAny&) = 0;
/// Prepares a DynamicAny.
virtual void prepare(std::size_t pos, const Poco::Dynamic::Var&) = 0;
/// Prepares a Var.
virtual void prepare(std::size_t pos, const std::vector<DynamicAny>& val);
/// Prepares a DynamicAny vector.
virtual void prepare(std::size_t pos, const std::vector<Poco::Dynamic::Var>& val);
/// Prepares a Var vector.
virtual void prepare(std::size_t pos, const std::deque<DynamicAny>& val);
/// Prepares a DynamicAny deque.
virtual void prepare(std::size_t pos, const std::deque<Poco::Dynamic::Var>& val);
/// Prepares a Var deque.
virtual void prepare(std::size_t pos, const std::list<DynamicAny>& val);
/// Prepares a DynamicAny list.
virtual void prepare(std::size_t pos, const std::list<Poco::Dynamic::Var>& val);
/// Prepares a Var list.
void setLength(Poco::UInt32 length);
/// Sets the length of prepared data.

View File

@ -44,7 +44,7 @@
#include "Poco/Data/Session.h"
#include "Poco/DateTime.h"
#include "Poco/Timespan.h"
#include "Poco/DynamicAny.h"
#include "Poco/Dynamic/Var.h"
#include "Poco/SharedPtr.h"
@ -221,10 +221,10 @@ private:
void initStatements();
Timespan _maxAge;
std::string _ageString;
DateTime _archiveDateTime;
DynamicAny _archiveCount;
Timespan _maxAge;
std::string _ageString;
DateTime _archiveDateTime;
Poco::Dynamic::Var _archiveCount;
};

View File

@ -42,7 +42,7 @@
#include "Poco/Data/Data.h"
#include "Poco/SharedPtr.h"
#include "Poco/DynamicAnyHolder.h"
#include "Poco/Dynamic/VarHolder.h"
#include "Poco/Exception.h"
#include <vector>
@ -232,28 +232,29 @@ namespace std
//
// DynamicAnyHolderImpl<BLOB>
// VarHolderImpl<BLOB>
//
namespace Poco {
namespace Dynamic {
template <>
class DynamicAnyHolderImpl<Data::BLOB>: public DynamicAnyHolder
class VarHolderImpl<Poco::Data::BLOB>: public VarHolder
{
public:
DynamicAnyHolderImpl(const Data::BLOB& val): _val(val)
VarHolderImpl(const Poco::Data::BLOB& val): _val(val)
{
}
~DynamicAnyHolderImpl()
~VarHolderImpl()
{
}
const std::type_info& type() const
{
return typeid(Data::BLOB);
return typeid(Poco::Data::BLOB);
}
void convert(std::string& val) const
@ -261,23 +262,23 @@ public:
val.assign(_val.begin(), _val.end());
}
DynamicAnyHolder* clone() const
VarHolder* clone() const
{
return new DynamicAnyHolderImpl(_val);
return new VarHolderImpl(_val);
}
const Data::BLOB& value() const
const Poco::Data::BLOB& value() const
{
return _val;
}
private:
DynamicAnyHolderImpl();
Data::BLOB _val;
VarHolderImpl();
Poco::Data::BLOB _val;
};
} // namespace Poco
} } // namespace Poco::Dynamic
#endif // Data_BLOB_INCLUDED

View File

@ -41,7 +41,7 @@
#include "Poco/Data/Data.h"
#include "Poco/DynamicAnyHolder.h"
#include "Poco/Dynamic/VarHolder.h"
#include "Poco/Exception.h"
@ -158,28 +158,29 @@ inline bool Date::operator > (const Date& date)
//
// DynamicAnyHolderImpl<BLOB>
// VarHolderImpl<BLOB>
//
namespace Poco {
namespace Dynamic {
template <>
class DynamicAnyHolderImpl<Data::Date>: public DynamicAnyHolder
class VarHolderImpl<Poco::Data::Date>: public VarHolder
{
public:
DynamicAnyHolderImpl(const Data::Date& val): _val(val)
VarHolderImpl(const Poco::Data::Date& val): _val(val)
{
}
~DynamicAnyHolderImpl()
~VarHolderImpl()
{
}
const std::type_info& type() const
{
return typeid(Data::Date);
return typeid(Poco::Data::Date);
}
void convert(Poco::Timestamp& val) const
@ -205,23 +206,23 @@ public:
val = DateTimeFormatter::format(dt, "%Y/%m/%d");
}
DynamicAnyHolder* clone() const
VarHolder* clone() const
{
return new DynamicAnyHolderImpl(_val);
return new VarHolderImpl(_val);
}
const Data::Date& value() const
const Poco::Data::Date& value() const
{
return _val;
}
private:
DynamicAnyHolderImpl();
Data::Date _val;
VarHolderImpl();
Poco::Data::Date _val;
};
} // namespace Poco
} } // namespace Poco::Dynamic
#endif // Data_Date_INCLUDED

View File

@ -47,7 +47,7 @@
#include "Poco/Data/RowIterator.h"
#include "Poco/Data/BLOB.h"
#include "Poco/String.h"
#include "Poco/DynamicAny.h"
#include "Poco/Dynamic/Var.h"
#include "Poco/Exception.h"
#include <ostream>
@ -222,30 +222,30 @@ public:
}
}
DynamicAny value(std::size_t col, std::size_t row, bool checkFiltering = true) const;
Poco::Dynamic::Var value(std::size_t col, std::size_t row, bool checkFiltering = true) const;
/// Returns the data value at column, row location.
DynamicAny value(const std::string& name, std::size_t row, bool checkFiltering = true) const;
Poco::Dynamic::Var value(const std::string& name, std::size_t row, bool checkFiltering = true) const;
/// Returns the data value at named column, row location.
template <typename T>
DynamicAny nvl(const std::string& name, const T& deflt = T()) const
Poco::Dynamic::Var nvl(const std::string& name, const T& deflt = T()) const
/// Returns the value in the named column of the current row
/// if the value is not NULL, or deflt otherwise.
{
if (isNull(name))
return DynamicAny(deflt);
return Poco::Dynamic::Var(deflt);
else
return value(name, _currentRow);
}
template <typename T>
DynamicAny nvl(std::size_t index, const T& deflt = T()) const
Poco::Dynamic::Var nvl(std::size_t index, const T& deflt = T()) const
/// Returns the value in the given column of the current row
/// if the value is not NULL, or deflt otherwise.
{
if (isNull(index, _currentRow))
return DynamicAny(deflt);
return Poco::Dynamic::Var(deflt);
else
return value(index, _currentRow);
}
@ -287,16 +287,16 @@ public:
/// Returns true if there is at least one row in the RecordSet,
/// false otherwise.
DynamicAny value(const std::string& name);
Poco::Dynamic::Var value(const std::string& name);
/// Returns the value in the named column of the current row.
DynamicAny value(std::size_t index);
Poco::Dynamic::Var value(std::size_t index);
/// Returns the value in the given column of the current row.
DynamicAny operator [] (const std::string& name);
Poco::Dynamic::Var operator [] (const std::string& name);
/// Returns the value in the named column of the current row.
DynamicAny operator [] (std::size_t index);
Poco::Dynamic::Var operator [] (std::size_t index);
/// Returns the value in the named column of the current row.
MetaColumn::ColumnDataType columnType(std::size_t pos) const;
@ -468,25 +468,25 @@ inline Statement& RecordSet::operator = (const Statement& stmt)
}
inline DynamicAny RecordSet::value(const std::string& name)
inline Poco::Dynamic::Var RecordSet::value(const std::string& name)
{
return value(name, _currentRow);
}
inline DynamicAny RecordSet::value(std::size_t index)
inline Poco::Dynamic::Var RecordSet::value(std::size_t index)
{
return value(index, _currentRow);
}
inline DynamicAny RecordSet::operator [] (const std::string& name)
inline Poco::Dynamic::Var RecordSet::operator [] (const std::string& name)
{
return value(name, _currentRow);
}
inline DynamicAny RecordSet::operator [] (std::size_t index)
inline Poco::Dynamic::Var RecordSet::operator [] (std::size_t index)
{
return value(index, _currentRow);
}

View File

@ -42,7 +42,7 @@
#include "Poco/Data/Data.h"
#include "Poco/Data/RowFormatter.h"
#include "Poco/DynamicAny.h"
#include "Poco/Dynamic/Var.h"
#include "Poco/Tuple.h"
#include "Poco/SharedPtr.h"
#include <vector>
@ -115,13 +115,13 @@ public:
~Row();
/// Destroys the Row.
DynamicAny& get(std::size_t col);
Poco::Dynamic::Var& get(std::size_t col);
/// Returns the reference to data value at column location.
DynamicAny& operator [] (std::size_t col);
Poco::Dynamic::Var& operator [] (std::size_t col);
/// Returns the reference to data value at column location.
DynamicAny& operator [] (const std::string& name);
Poco::Dynamic::Var& operator [] (const std::string& name);
/// Returns the reference to data value at named column location.
template <typename T>
@ -232,7 +232,7 @@ public:
private:
void init(const SortMapPtr& pSortMap, const RowFormatterPtr& pFormatter);
void checkEmpty(std::size_t pos, const DynamicAny& val);
void checkEmpty(std::size_t pos, const Poco::Dynamic::Var& val);
/// Check if row contains only empty values and throws IllegalStateException
/// if that is the case.
@ -289,13 +289,13 @@ inline Row::ValueVec& Row::values()
}
inline DynamicAny& Row::operator [] (std::size_t col)
inline Poco::Dynamic::Var& Row::operator [] (std::size_t col)
{
return get(col);
}
inline DynamicAny& Row::operator [] (const std::string& name)
inline Poco::Dynamic::Var& Row::operator [] (const std::string& name)
{
return get(getPosition(name));
}

View File

@ -42,7 +42,7 @@
#include "Poco/Data/Data.h"
#include "Poco/Data/RecordSet.h"
#include "Poco/DynamicAny.h"
#include "Poco/Dynamic/Var.h"
#include "Poco/Tuple.h"
#include "Poco/String.h"
#include "Poco/RefCountedObject.h"
@ -87,10 +87,10 @@ public:
OP_NOT
};
typedef bool (*CompT)(const DynamicAny&, const DynamicAny&);
typedef bool (*CompT)(const Poco::Dynamic::Var&, const Poco::Dynamic::Var&);
typedef AutoPtr<RowFilter> Ptr;
typedef std::map<std::string, Comparison> Comparisons;
typedef Tuple<DynamicAny, Comparison, LogicOperator> ComparisonEntry;
typedef Tuple<Poco::Dynamic::Var, Comparison, LogicOperator> ComparisonEntry;
typedef std::multimap<std::string, ComparisonEntry> ComparisonMap;
typedef std::map<AutoPtr<RowFilter>, LogicOperator> FilterMap;
@ -153,7 +153,7 @@ public:
bool isEmpty() const;
/// Returns true if there is not filtering criteria specified.
bool isAllowed(std::size_t row) const;//const std::string& name, const DynamicAny& val) const;
bool isAllowed(std::size_t row) const;//const std::string& name, const Poco::Dynamic::Var& val) const;
/// Returns true if name and value are allowed.
bool exists(const std::string& name) const;
@ -166,18 +166,18 @@ private:
void init();
static bool equal(const DynamicAny& p1, const DynamicAny& p2);
static bool notEqual(const DynamicAny& p1, const DynamicAny& p2);
static bool less(const DynamicAny& p1, const DynamicAny& p2);
static bool greater(const DynamicAny& p1, const DynamicAny& p2);
static bool lessOrEqual(const DynamicAny& p1, const DynamicAny& p2);
static bool greaterOrEqual(const DynamicAny& p1, const DynamicAny& p2);
static bool logicalAnd(const DynamicAny& p1, const DynamicAny& p2);
static bool logicalOr(const DynamicAny& p1, const DynamicAny& p2);
static bool isNull(const DynamicAny& p1, const DynamicAny&);
static bool equal(const Poco::Dynamic::Var& p1, const Poco::Dynamic::Var& p2);
static bool notEqual(const Poco::Dynamic::Var& p1, const Poco::Dynamic::Var& p2);
static bool less(const Poco::Dynamic::Var& p1, const Poco::Dynamic::Var& p2);
static bool greater(const Poco::Dynamic::Var& p1, const Poco::Dynamic::Var& p2);
static bool lessOrEqual(const Poco::Dynamic::Var& p1, const Poco::Dynamic::Var& p2);
static bool greaterOrEqual(const Poco::Dynamic::Var& p1, const Poco::Dynamic::Var& p2);
static bool logicalAnd(const Poco::Dynamic::Var& p1, const Poco::Dynamic::Var& p2);
static bool logicalOr(const Poco::Dynamic::Var& p1, const Poco::Dynamic::Var& p2);
static bool isNull(const Poco::Dynamic::Var& p1, const Poco::Dynamic::Var&);
static void doCompare(DynamicAny& ret,
DynamicAny& val,
static void doCompare(Poco::Dynamic::Var& ret,
Poco::Dynamic::Var& val,
CompT comp,
const ComparisonEntry& ce);
@ -225,55 +225,55 @@ inline bool RowFilter::isNot() const
}
inline bool RowFilter::equal(const DynamicAny& p1, const DynamicAny& p2)
inline bool RowFilter::equal(const Poco::Dynamic::Var& p1, const Poco::Dynamic::Var& p2)
{
return p1 == p2;
}
inline bool RowFilter::notEqual(const DynamicAny& p1, const DynamicAny& p2)
inline bool RowFilter::notEqual(const Poco::Dynamic::Var& p1, const Poco::Dynamic::Var& p2)
{
return p1 != p2;
}
inline bool RowFilter::less(const DynamicAny& p1, const DynamicAny& p2)
inline bool RowFilter::less(const Poco::Dynamic::Var& p1, const Poco::Dynamic::Var& p2)
{
return p1 < p2;
}
inline bool RowFilter::greater(const DynamicAny& p1, const DynamicAny& p2)
inline bool RowFilter::greater(const Poco::Dynamic::Var& p1, const Poco::Dynamic::Var& p2)
{
return p1 > p2;
}
inline bool RowFilter::lessOrEqual(const DynamicAny& p1, const DynamicAny& p2)
inline bool RowFilter::lessOrEqual(const Poco::Dynamic::Var& p1, const Poco::Dynamic::Var& p2)
{
return p1 <= p2;
}
inline bool RowFilter::greaterOrEqual(const DynamicAny& p1, const DynamicAny& p2)
inline bool RowFilter::greaterOrEqual(const Poco::Dynamic::Var& p1, const Poco::Dynamic::Var& p2)
{
return p1 >= p2;
}
inline bool RowFilter::logicalAnd(const DynamicAny& p1, const DynamicAny& p2)
inline bool RowFilter::logicalAnd(const Poco::Dynamic::Var& p1, const Poco::Dynamic::Var& p2)
{
return p1 && p2;
}
inline bool RowFilter::logicalOr(const DynamicAny& p1, const DynamicAny& p2)
inline bool RowFilter::logicalOr(const Poco::Dynamic::Var& p1, const Poco::Dynamic::Var& p2)
{
return p1 || p2;
}
inline bool RowFilter::isNull(const DynamicAny& p1, const DynamicAny&)
inline bool RowFilter::isNull(const Poco::Dynamic::Var& p1, const Poco::Dynamic::Var&)
{
return p1.isEmpty();
}

View File

@ -43,7 +43,7 @@
#include "Poco/Data/Data.h"
#include "Poco/SharedPtr.h"
#include "Poco/RefCountedObject.h"
#include "Poco/DynamicAny.h"
#include "Poco/Dynamic/Var.h"
#include <sstream>
#include <vector>
@ -75,7 +75,7 @@ class Data_API RowFormatter
public:
typedef std::vector<std::string> NameVec;
typedef SharedPtr<std::vector<std::string> > NameVecPtr;
typedef std::vector<DynamicAny> ValueVec;
typedef std::vector<Poco::Dynamic::Var> ValueVec;
RowFormatter(const std::string& prefix = "", const std::string& postfix = "");
/// Creates the RowFormatter and sets the prefix and postfix to specified values.

View File

@ -42,7 +42,7 @@
#include "Poco/Data/Data.h"
#include "Poco/Data/Row.h"
#include "Poco/DynamicAny.h"
#include "Poco/Dynamic/Var.h"
#include <iterator>

View File

@ -49,7 +49,6 @@
#include "Poco/Message.h"
#include "Poco/AutoPtr.h"
#include "Poco/String.h"
#include "Poco/DynamicAny.h"
namespace Poco {

View File

@ -174,17 +174,18 @@ private:
std::string _sessionKey;
std::string _connectionString;
int _minSessions;
int _maxSessions;
int _idleTime;
int _nSessions;
int _minSessions;
int _maxSessions;
int _idleTime;
int _nSessions;
SessionList _idleSessions;
SessionList _activeSessions;
Poco::Timer _janitorTimer;
FeatureMap _featureMap;
PropertyMap _propertyMap;
bool _shutdown;
mutable Poco::FastMutex _mutex;
bool _shutdown;
mutable
Poco::Mutex _mutex;
friend class PooledSessionImpl;
};

View File

@ -41,7 +41,7 @@
#include "Poco/Data/Data.h"
#include "Poco/DynamicAnyHolder.h"
#include "Poco/Dynamic/VarHolder.h"
#include "Poco/Exception.h"
@ -158,28 +158,29 @@ inline bool Time::operator > (const Time& time)
//
// DynamicAnyHolderImpl<BLOB>
// VarHolderImpl<BLOB>
//
namespace Poco {
namespace Dynamic {
template <>
class DynamicAnyHolderImpl<Data::Time>: public DynamicAnyHolder
class VarHolderImpl<Poco::Data::Time>: public VarHolder
{
public:
DynamicAnyHolderImpl(const Data::Time& val): _val(val)
VarHolderImpl(const Poco::Data::Time& val): _val(val)
{
}
~DynamicAnyHolderImpl()
~VarHolderImpl()
{
}
const std::type_info& type() const
{
return typeid(Data::Time);
return typeid(Poco::Data::Time);
}
void convert(Poco::Timestamp& val) const
@ -209,23 +210,23 @@ public:
val = DateTimeFormatter::format(dt, "%H:%M:%S");
}
DynamicAnyHolder* clone() const
VarHolder* clone() const
{
return new DynamicAnyHolderImpl(_val);
return new VarHolderImpl(_val);
}
const Data::Time& value() const
const Poco::Data::Time& value() const
{
return _val;
}
private:
DynamicAnyHolderImpl();
Data::Time _val;
VarHolderImpl();
Poco::Data::Time _val;
};
} // namespace Poco
} } // namespace Poco::Dynamic
#endif // Data_Time_INCLUDED

View File

@ -41,7 +41,7 @@
#include "Poco/Data/DataException.h"
#include "Poco/DateTime.h"
#include "Poco/Any.h"
#include "Poco/DynamicAny.h"
#include "Poco/Dynamic/Var.h"
namespace Poco {
@ -449,7 +449,7 @@ void AbstractBinder::bind(std::size_t pos, const Any& val, Direction dir)
}
void AbstractBinder::bind(std::size_t pos, const DynamicAny& val, Direction dir)
void AbstractBinder::bind(std::size_t pos, const Poco::Dynamic::Var& val, Direction dir)
{
const std::type_info& type = val.type();

View File

@ -396,19 +396,19 @@ bool AbstractExtractor::extract(std::size_t pos, std::list<Any>& val)
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<DynamicAny>& val)
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::Dynamic::Var>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<DynamicAny>& val)
bool AbstractExtractor::extract(std::size_t pos, std::deque<Poco::Dynamic::Var>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<DynamicAny>& val)
bool AbstractExtractor::extract(std::size_t pos, std::list<Poco::Dynamic::Var>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}

View File

@ -397,19 +397,19 @@ void AbstractPreparation::prepare(std::size_t pos, const std::list<Any>& val)
}
void AbstractPreparation::prepare(std::size_t pos, const std::vector<DynamicAny>& val)
void AbstractPreparation::prepare(std::size_t pos, const std::vector<Poco::Dynamic::Var>& val)
{
throw NotImplementedException("std::vector preparation must be implemented.");
}
void AbstractPreparation::prepare(std::size_t pos, const std::deque<DynamicAny>& val)
void AbstractPreparation::prepare(std::size_t pos, const std::deque<Poco::Dynamic::Var>& val)
{
throw NotImplementedException("std::deque preparation must be implemented.");
}
void AbstractPreparation::prepare(std::size_t pos, const std::list<DynamicAny>& val)
void AbstractPreparation::prepare(std::size_t pos, const std::list<Poco::Dynamic::Var>& val)
{
throw NotImplementedException("std::list preparation must be implemented.");
}

View File

@ -96,12 +96,12 @@ RecordSet::~RecordSet()
}
DynamicAny RecordSet::value(std::size_t col, std::size_t row, bool useFilter) const
Poco::Dynamic::Var RecordSet::value(std::size_t col, std::size_t row, bool useFilter) const
{
if (useFilter && isFiltered() && !isAllowed(row))
throw InvalidAccessException("Row not allowed");
if (isNull(col, row)) return DynamicAny();
if (isNull(col, row)) return Poco::Dynamic::Var();
switch (columnType(col))
{
@ -127,12 +127,12 @@ DynamicAny RecordSet::value(std::size_t col, std::size_t row, bool useFilter) co
}
DynamicAny RecordSet::value(const std::string& name, std::size_t row, bool useFilter) const
Poco::Dynamic::Var RecordSet::value(const std::string& name, std::size_t row, bool useFilter) const
{
if (useFilter && isFiltered() && !isAllowed(row))
throw InvalidAccessException("Row not allowed");
if (isNull(metaColumn(name).position(), row)) return DynamicAny();
if (isNull(metaColumn(name).position(), row)) return Poco::Dynamic::Var();
switch (columnType(name))
{

View File

@ -87,7 +87,7 @@ void Row::init(const SortMapPtr& pSortMap, const RowFormatterPtr& pFormatter)
// Row sortability in the strict weak ordering sense is
// an invariant, hence we must start with a zero here.
// If null value is later retrieved from DB, the
// DynamicAny::empty() call should be used to empty
// Var::empty() call should be used to empty
// the corresponding Row value.
_values[0] = 0;
addSortField(0);
@ -100,7 +100,7 @@ Row::~Row()
}
DynamicAny& Row::get(std::size_t col)
Poco::Dynamic::Var& Row::get(std::size_t col)
{
try
{
@ -130,7 +130,7 @@ std::size_t Row::getPosition(const std::string& name)
}
void Row::checkEmpty(std::size_t pos, const DynamicAny& val)
void Row::checkEmpty(std::size_t pos, const Poco::Dynamic::Var& val)
{
bool empty = true;
SortMap::const_iterator it = _pSortMap->begin();
@ -198,7 +198,7 @@ void Row::addSortField(const std::string& name)
void Row::removeSortField(std::size_t pos)
{
checkEmpty(pos, DynamicAny());
checkEmpty(pos, Poco::Dynamic::Var());
SortMap::iterator it = _pSortMap->begin();
SortMap::iterator end = _pSortMap->end();
@ -288,8 +288,8 @@ bool Row::isEqualSize(const Row& other) const
bool Row::isEqualType(const Row& other) const
{
std::vector<DynamicAny>::const_iterator it = _values.begin();
std::vector<DynamicAny>::const_iterator end = _values.end();
std::vector<Poco::Dynamic::Var>::const_iterator it = _values.begin();
std::vector<Poco::Dynamic::Var>::const_iterator end = _values.end();
for (int i = 0; it != end; ++it, ++i)
{
if (it->type() != other._values[i].type())
@ -305,8 +305,8 @@ bool Row::operator == (const Row& other) const
if (!isEqualSize(other)) return false;
if (!isEqualType(other)) return false;
std::vector<DynamicAny>::const_iterator it = _values.begin();
std::vector<DynamicAny>::const_iterator end = _values.end();
std::vector<Poco::Dynamic::Var>::const_iterator it = _values.begin();
std::vector<Poco::Dynamic::Var>::const_iterator end = _values.end();
for (int i = 0; it != end; ++it, ++i)
{
if ((*it).convert<std::string>() != other._values[i].convert<std::string>())

View File

@ -88,7 +88,7 @@ RowFilter::~RowFilter()
bool RowFilter::isAllowed(std::size_t row) const
{
DynamicAny retVal;
Poco::Dynamic::Var retVal;
const RecordSet& rs = recordSet();
std::size_t columns = rs.columnCount();
@ -101,9 +101,9 @@ bool RowFilter::isAllowed(std::size_t row) const
const std::string name = toUpper(rs.metaColumn(static_cast<UInt32>(col)).name());
if (_comparisonMap.find(name) == _comparisonMap.end()) continue;
DynamicAny ret;
Poco::Dynamic::Var ret;
CompT compOp = 0;
DynamicAny val = rs.value(col, row, false);
Poco::Dynamic::Var val = rs.value(col, row, false);
switch (it->second.get<1>())
{
@ -197,8 +197,8 @@ void RowFilter::removeFilter(const Ptr& pFilter)
}
void RowFilter::doCompare(DynamicAny& ret,
DynamicAny& val,
void RowFilter::doCompare(Poco::Dynamic::Var& ret,
Poco::Dynamic::Var& val,
CompT comp,
const ComparisonEntry& ce)
{

View File

@ -67,9 +67,9 @@ SessionPool::~SessionPool()
Session SessionPool::get()
{
Poco::FastMutex::ScopedLock lock(_mutex);
Poco::Mutex::ScopedLock lock(_mutex);
if (_shutdown) throw InvalidAccessException("Session pull has been shut down.");
purgeDeadSessions();
if (_idleSessions.empty())
@ -104,7 +104,7 @@ Session SessionPool::get()
void SessionPool::purgeDeadSessions()
{
Poco::FastMutex::ScopedLock lock(_mutex);
Poco::Mutex::ScopedLock lock(_mutex);
if (_shutdown) return;
SessionList::iterator it = _idleSessions.begin();
@ -128,21 +128,21 @@ int SessionPool::capacity() const
int SessionPool::used() const
{
Poco::FastMutex::ScopedLock lock(_mutex);
Poco::Mutex::ScopedLock lock(_mutex);
return (int) _activeSessions.size();
}
int SessionPool::idle() const
{
Poco::FastMutex::ScopedLock lock(_mutex);
Poco::Mutex::ScopedLock lock(_mutex);
return (int) _idleSessions.size();
}
int SessionPool::dead()
{
Poco::FastMutex::ScopedLock lock(_mutex);
Poco::Mutex::ScopedLock lock(_mutex);
int count = 0;
SessionList::iterator it = _activeSessions.begin();
@ -159,7 +159,7 @@ int SessionPool::dead()
int SessionPool::allocated() const
{
Poco::FastMutex::ScopedLock lock(_mutex);
Poco::Mutex::ScopedLock lock(_mutex);
return _nSessions;
}
@ -173,7 +173,7 @@ int SessionPool::available() const
void SessionPool::setFeature(const std::string& name, bool state)
{
Poco::FastMutex::ScopedLock lock(_mutex);
Poco::Mutex::ScopedLock lock(_mutex);
if (_shutdown) throw InvalidAccessException("Session pull has been shut down.");
if (_nSessions > 0)
@ -197,7 +197,7 @@ bool SessionPool::getFeature(const std::string& name)
void SessionPool::setProperty(const std::string& name, const Poco::Any& value)
{
Poco::FastMutex::ScopedLock lock(_mutex);
Poco::Mutex::ScopedLock lock(_mutex);
if (_shutdown) throw InvalidAccessException("Session pull has been shut down.");
if (_nSessions > 0)
@ -220,7 +220,7 @@ Poco::Any SessionPool::getProperty(const std::string& name)
void SessionPool::putBack(PooledSessionHolderPtr pHolder)
{
Poco::FastMutex::ScopedLock lock(_mutex);
Poco::Mutex::ScopedLock lock(_mutex);
if (_shutdown) return;
SessionList::iterator it = std::find(_activeSessions.begin(), _activeSessions.end(), pHolder);
@ -244,7 +244,7 @@ void SessionPool::putBack(PooledSessionHolderPtr pHolder)
void SessionPool::onJanitorTimer(Poco::Timer&)
{
Poco::FastMutex::ScopedLock lock(_mutex);
Poco::Mutex::ScopedLock lock(_mutex);
if (_shutdown) return;
SessionList::iterator it = _idleSessions.begin();
@ -264,7 +264,7 @@ void SessionPool::onJanitorTimer(Poco::Timer&)
void SessionPool::shutdown()
{
Poco::FastMutex::ScopedLock lock(_mutex);
Poco::Mutex::ScopedLock lock(_mutex);
if (_shutdown) return;
_shutdown = true;
_janitorTimer.stop();

View File

@ -47,7 +47,7 @@
#include "Poco/BinaryWriter.h"
#include "Poco/DateTime.h"
#include "Poco/Types.h"
#include "Poco/DynamicAny.h"
#include "Poco/Dynamic/Var.h"
#include "Poco/Exception.h"
#include <cstring>
#include <sstream>
@ -64,7 +64,7 @@ using Poco::UInt32;
using Poco::Int64;
using Poco::UInt64;
using Poco::DateTime;
using Poco::DynamicAny;
using Poco::Dynamic::Var;
using Poco::InvalidAccessException;
using Poco::IllegalStateException;
using Poco::RangeException;
@ -879,7 +879,7 @@ void DataTest::testRow()
try
{
row4.set("field1", DynamicAny());
row4.set("field1", Var());
row4.addSortField(1);
row4.removeSortField(0);
fail ("must fail - field 1 is empty");

View File

@ -180,7 +180,7 @@ bool Extractor::extract(std::size_t pos, Poco::Any& val)
}
bool Extractor::extract(std::size_t pos, Poco::DynamicAny& val)
bool Extractor::extract(std::size_t pos, Poco::Dynamic::Var& val)
{
return true;
}

View File

@ -81,8 +81,8 @@ public:
bool extract(std::size_t pos, Poco::Any& val);
/// Extracts an Any.
bool extract(std::size_t pos, Poco::DynamicAny& val);
/// Extracts a DynamicAny.
bool extract(std::size_t pos, Poco::Dynamic::Var& val);
/// Extracts a Var.
#ifndef POCO_LONG_IS_64_BIT
bool extract(std::size_t pos, long& val);

View File

@ -147,7 +147,7 @@ void Preparation::prepare(std::size_t pos, const Poco::Any&)
}
void Preparation::prepare(std::size_t pos, const Poco::DynamicAny&)
void Preparation::prepare(std::size_t pos, const Poco::Dynamic::Var&)
{
}

View File

@ -114,8 +114,8 @@ public:
void prepare(std::size_t pos, const Poco::Any&);
/// Prepares an Any.
void prepare(std::size_t pos, const Poco::DynamicAny&);
/// Prepares a DynamicAny.
void prepare(std::size_t pos, const Poco::Dynamic::Var&);
/// Prepares a Var.
};

View File

@ -87,7 +87,7 @@ void SessionPoolTest::testSessionPool()
assert (pool.dead() == 0);
assert (pool.allocated() == pool.used() + pool.idle());
Session s1(pool.get());
try { pool.setFeature("f1", true); fail ("must fail"); }
catch ( Poco::InvalidAccessException& ) { }

View File

@ -261,15 +261,6 @@
<File
RelativePath=".\src\Debugger.cpp">
</File>
<File
RelativePath=".\src\DynamicAny.cpp">
</File>
<File
RelativePath=".\src\DynamicAnyHolder.cpp">
</File>
<File
RelativePath=".\src\DynamicStruct.cpp">
</File>
<File
RelativePath=".\src\Environment.cpp">
</File>
@ -583,18 +574,10 @@
<File
RelativePath=".\include\Poco\Debugger.h">
</File>
<File
RelativePath=".\include\Poco\DynamicAny.h">
</File>
<File
RelativePath=".\include\Poco\DynamicAnyHolder.h">
</File>
<File
RelativePath=".\include\Poco\DynamicFactory.h">
</File>
<File
RelativePath=".\include\Poco\DynamicStruct.h">
</File>
<File
RelativePath=".\include\Poco\Environment.h">
</File>
@ -3652,6 +3635,54 @@
</File>
</Filter>
</Filter>
<Filter
Name="Dynamic"
>
<Filter
Name="Header Files"
>
<File
RelativePath=".\include\Poco\DynamicAny.h"
>
</File>
<File
RelativePath=".\include\Poco\DynamicAnyHolder.h"
>
</File>
<File
RelativePath=".\include\Poco\DynamicStruct.h"
>
</File>
<File
RelativePath=".\include\Poco\Dynamic\Struct.h"
>
</File>
<File
RelativePath=".\include\Poco\Dynamic\Var.h"
>
</File>
<File
RelativePath=".\include\Poco\Dynamic\VarHolder.h"
>
</File>
</Filter>
<Filter
Name="Source Files"
>
<File
RelativePath=".\src\Struct.cpp"
>
</File>
<File
RelativePath=".\src\Var.cpp"
>
</File>
<File
RelativePath=".\src\VarHolder.cpp"
>
</File>
</Filter>
</Filter>
</Files>
<Globals>
</Globals>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Version="8.00"
Name="Foundation"
ProjectGUID="{8164D41D-B053-405B-826C-CF37AC0EF176}"
RootNamespace="Foundation"
@ -373,18 +373,6 @@
RelativePath=".\src\Debugger.cpp"
>
</File>
<File
RelativePath=".\src\DynamicAny.cpp"
>
</File>
<File
RelativePath=".\src\DynamicAnyHolder.cpp"
>
</File>
<File
RelativePath=".\src\DynamicStruct.cpp"
>
</File>
<File
RelativePath=".\src\Environment.cpp"
>
@ -801,22 +789,10 @@
RelativePath=".\include\Poco\Debugger.h"
>
</File>
<File
RelativePath=".\include\Poco\DynamicAny.h"
>
</File>
<File
RelativePath=".\include\Poco\DynamicAnyHolder.h"
>
</File>
<File
RelativePath=".\include\Poco\DynamicFactory.h"
>
</File>
<File
RelativePath=".\include\Poco\DynamicStruct.h"
>
</File>
<File
RelativePath=".\include\Poco\Environment.h"
>
@ -4747,6 +4723,54 @@
</File>
</Filter>
</Filter>
<Filter
Name="Dynamic"
>
<Filter
Name="Header Files"
>
<File
RelativePath=".\include\Poco\DynamicAny.h"
>
</File>
<File
RelativePath=".\include\Poco\DynamicAnyHolder.h"
>
</File>
<File
RelativePath=".\include\Poco\DynamicStruct.h"
>
</File>
<File
RelativePath=".\include\Poco\Dynamic\Struct.h"
>
</File>
<File
RelativePath=".\include\Poco\Dynamic\Var.h"
>
</File>
<File
RelativePath=".\include\Poco\Dynamic\VarHolder.h"
>
</File>
</Filter>
<Filter
Name="Source Files"
>
<File
RelativePath=".\src\Struct.cpp"
>
</File>
<File
RelativePath=".\src\Var.cpp"
>
</File>
<File
RelativePath=".\src\VarHolder.cpp"
>
</File>
</Filter>
</Filter>
</Files>
<Globals>
</Globals>

View File

@ -364,18 +364,6 @@
RelativePath=".\src\Debugger.cpp"
>
</File>
<File
RelativePath=".\src\DynamicAny.cpp"
>
</File>
<File
RelativePath=".\src\DynamicAnyHolder.cpp"
>
</File>
<File
RelativePath=".\src\DynamicStruct.cpp"
>
</File>
<File
RelativePath=".\src\Environment.cpp"
>
@ -792,22 +780,10 @@
RelativePath=".\include\Poco\Debugger.h"
>
</File>
<File
RelativePath=".\include\Poco\DynamicAny.h"
>
</File>
<File
RelativePath=".\include\Poco\DynamicAnyHolder.h"
>
</File>
<File
RelativePath=".\include\Poco\DynamicFactory.h"
>
</File>
<File
RelativePath=".\include\Poco\DynamicStruct.h"
>
</File>
<File
RelativePath=".\include\Poco\Environment.h"
>
@ -4738,6 +4714,54 @@
</File>
</Filter>
</Filter>
<Filter
Name="Dynamic"
>
<Filter
Name="Header Files"
>
<File
RelativePath=".\include\Poco\DynamicAny.h"
>
</File>
<File
RelativePath=".\include\Poco\DynamicAnyHolder.h"
>
</File>
<File
RelativePath=".\include\Poco\DynamicStruct.h"
>
</File>
<File
RelativePath=".\include\Poco\Dynamic\Struct.h"
>
</File>
<File
RelativePath=".\include\Poco\Dynamic\Var.h"
>
</File>
<File
RelativePath=".\include\Poco\Dynamic\VarHolder.h"
>
</File>
</Filter>
<Filter
Name="Source Files"
>
<File
RelativePath=".\src\Struct.cpp"
>
</File>
<File
RelativePath=".\src\Var.cpp"
>
</File>
<File
RelativePath=".\src\VarHolder.cpp"
>
</File>
</Filter>
</Filter>
</Files>
<Globals>
</Globals>

View File

@ -12,7 +12,6 @@ objects = ArchiveStrategy ASCIIEncoding AsyncChannel Base64Decoder Base64Encoder
BinaryReader BinaryWriter Bugcheck ByteOrder Channel Checksum Configurable ConsoleChannel \
CountingStream DateTime LocalDateTime DateTimeFormat DateTimeFormatter DateTimeParser \
Debugger DeflatingStream DigestEngine DigestStream DirectoryIterator \
DynamicAny DynamicAnyHolder DynamicStruct \
Environment Event EventArgs ErrorHandler Exception FPEnvironment File Glob \
FileChannel Formatter FormattingChannel HexBinaryDecoder LineEndingConverter \
HexBinaryEncoder InflatingStream Latin1Encoding Latin9Encoding LogFile Logger \
@ -24,12 +23,12 @@ objects = ArchiveStrategy ASCIIEncoding AsyncChannel Base64Decoder Base64Encoder
RegularExpression RefCountedObject Runnable RotateStrategy Condition \
SHA1Engine Semaphore SharedLibrary SimpleFileChannel \
SignalHandler SplitterChannel Stopwatch StreamChannel StreamConverter StreamCopier \
StreamTokenizer String StringTokenizer SynchronizedObject \
StreamTokenizer String StringTokenizer Struct SynchronizedObject \
Task TaskManager TaskNotification TeeStream Hash HashStatistic \
TemporaryFile TextConverter TextEncoding TextIterator Thread ThreadLocal \
ThreadPool ThreadTarget ActiveDispatcher Timer Timespan Timestamp Timezone Token URI \
FileStreamFactory URIStreamFactory URIStreamOpener UTF16Encoding Windows1252Encoding \
UTF8Encoding UnicodeConverter UUID UUIDGenerator Void Format \
UTF8Encoding UnicodeConverter UUID UUIDGenerator Var VarHolder Void Format \
Pipe PipeImpl PipeStream SharedMemory FileStream Unicode UTF8String \
adler32 compress crc32 deflate gzio infback inffast inflate inftrees trees zutil \
pcre_chartables pcre_compile pcre_globals pcre_maketables pcre_study \

View File

@ -0,0 +1,407 @@
//
// Struct.h
//
// $Id: //poco/Main/Foundation/include/Poco/Struct.h#9 $
//
// Library: Foundation
// Package: Dynamic
// Module: Struct
//
// Definition of the Struct class.
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Foundation_Struct_INCLUDED
#define Foundation_Struct_INCLUDED
#include "Poco/Foundation.h"
#include "Poco/Dynamic/Var.h"
#include "Poco/Dynamic/VarHolder.h"
#include <map>
#include <set>
namespace Poco {
namespace Dynamic {
class Foundation_API Struct
/// Struct allows to define a named collection of Var objects.
{
public:
typedef std::map<std::string, Var> Data;
typedef Data::iterator Iterator;
typedef Data::const_iterator ConstIterator;
Struct();
/// Creates an empty Struct
Struct(const Data &val);
/// Creates the Struct from the given value.
virtual ~Struct();
/// Destroys the Struct.
Var& operator [] (const std::string& name);
/// Returns the Var with the given name, creates an entry if not found.
const Var& operator [] (const std::string& name) const;
/// Returns the Var with the given name, throws a
/// NotFoundException if the data member is not found.
bool contains(const std::string& name) const;
/// Returns true if the Struct contains a member with the given
/// name
Iterator find(const std::string& name);
/// Returns an iterator, pointing to the <name,Var> pair containing
/// the element, or it returns end() if the member was not found
ConstIterator find(const std::string& name) const;
/// Returns a const iterator, pointing to the <name,Var> pair containing
/// the element, or it returns end() if the member was not found
Iterator end();
/// Returns the end iterator for the Struct
ConstIterator end() const;
/// Returns the end const iterator for the Struct
Iterator begin();
/// Returns the begin iterator for the Struct
ConstIterator begin() const;
/// Returns the begin const iterator for the Struct
std::pair<Struct::Iterator, bool> insert(const std::string& key, const Var& value);
/// Inserts a <name, Var> pair into the Struct,
/// returns a pair containing the iterator and a boolean which
/// indicates success or not (is true, when insert succeeded, false,
/// when already another element was present, in this case Iterator
/// points to that other element)
std::pair<Struct::Iterator, bool> insert(const Struct::Data::value_type& aPair);
/// Inserts a <name, Var> pair into the Struct,
/// returns a pair containing the iterator and a boolean which
/// indicates success or not (is true, when insert succeeded, false,
/// when already another element was present, in this case Iterator
/// points to that other element)
Struct::Data::size_type erase(const std::string& key);
/// Erases the element if found, returns number of elements deleted
void erase(Struct::Iterator it);
/// Erases the element at the given position
bool empty() const;
/// Returns true if the Struct doesn't contain any members
Struct::Data::size_type size() const;
/// Returns the number of members the Struct contains
std::set<std::string> members() const;
/// Returns a sorted collection containing all member names
private:
Data _data;
};
//
// inlines
//
inline Var& Struct::operator [] (const std::string& name)
{
return _data[name];
}
inline bool Struct::contains(const std::string& name) const
{
return find(name) != end();
}
inline Struct::Iterator Struct::find(const std::string& name)
{
return _data.find(name);
}
inline Struct::ConstIterator Struct::find(const std::string& name) const
{
return _data.find(name);
}
inline Struct::Iterator Struct::end()
{
return _data.end();
}
inline Struct::ConstIterator Struct::end() const
{
return _data.end();
}
inline Struct::Iterator Struct::begin()
{
return _data.begin();
}
inline Struct::ConstIterator Struct::begin() const
{
return _data.begin();
}
inline std::pair<Struct::Iterator, bool> Struct::insert(const std::string& key, const Var& value)
{
return insert(std::make_pair(key, value));
}
inline std::pair<Struct::Iterator, bool> Struct::insert(const Struct::Data::value_type& aPair)
{
return _data.insert(aPair);
}
inline Struct::Data::size_type Struct::erase(const std::string& key)
{
return _data.erase(key);
}
inline void Struct::erase(Struct::Iterator it)
{
_data.erase(it);
}
inline bool Struct::empty() const
{
return _data.empty();
}
inline Struct::Data::size_type Struct::size() const
{
return _data.size();
}
template <>
class VarHolderImpl<Struct>: public VarHolder
{
public:
VarHolderImpl(const Struct& val): _val(val)
{
}
~VarHolderImpl()
{
}
const std::type_info& type() const
{
return typeid(Struct);
}
void convert(Int8& val) const
{
throw BadCastException("Cannot cast Struct type to Int8");
}
void convert(Int16& val) const
{
throw BadCastException("Cannot cast Struct type to Int16");
}
void convert(Int32& val) const
{
throw BadCastException("Cannot cast Struct type to Int32");
}
void convert(Int64& val) const
{
throw BadCastException("Cannot cast Struct type to Int64");
}
void convert(UInt8& val) const
{
throw BadCastException("Cannot cast Struct type to UInt8");
}
void convert(UInt16& val) const
{
throw BadCastException("Cannot cast Struct type to UInt16");
}
void convert(UInt32& val) const
{
throw BadCastException("Cannot cast Struct type to UInt32");
}
void convert(UInt64& val) const
{
throw BadCastException("Cannot cast Struct type to UInt64");
}
void convert(bool& val) const
{
throw BadCastException("Cannot cast Struct type to bool");
}
void convert(float& val) const
{
throw BadCastException("Cannot cast Struct type to float");
}
void convert(double& val) const
{
throw BadCastException("Cannot cast Struct type to double");
}
void convert(char& val) const
{
throw BadCastException("Cannot cast Struct type to char");
}
void convert(std::string& val) const
{
// Serialize in JSON format: equals an object
// JSON format definition: { string ':' value } string:value pair n-times, sep. by ','
val.append("{ ");
Struct::ConstIterator it = _val.begin();
Struct::ConstIterator itEnd = _val.end();
if (!_val.empty())
{
Var key(it->first);
appendJSONString(val, key);
val.append(" : ");
appendJSONString(val, it->second);
++it;
}
for (; it != itEnd; ++it)
{
val.append(", ");
Var key(it->first);
appendJSONString(val, key);
val.append(" : ");
appendJSONString(val, it->second);
}
val.append(" }");
}
void convert(Poco::DateTime&) const
{
throw BadCastException("Struct -> Poco::DateTime");
}
void convert(Poco::LocalDateTime&) const
{
throw BadCastException("Struct -> Poco::LocalDateTime");
}
void convert(Poco::Timestamp&) const
{
throw BadCastException("Struct -> Poco::Timestamp");
}
VarHolder* clone() const
{
return new VarHolderImpl(_val);
}
const Struct& value() const
{
return _val;
}
bool isArray() const
{
return false;
}
bool isStruct() const
{
return true;
}
bool isInteger() const
{
return false;
}
bool isSigned() const
{
return false;
}
bool isNumeric() const
{
return false;
}
bool isString() const
{
return false;
}
Var& operator [] (const std::string& name)
{
return _val[name];
}
const Var& operator [] (const std::string& name) const
{
return _val[name];
}
private:
Struct _val;
};
} // namespace Dynamic
//@ deprecated
typedef Dynamic::Struct DynamicStruct;
} // namespace Poco
#endif // Foundation_Struct_INCLUDED

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -4,10 +4,10 @@
// $Id: //poco/Main/Foundation/include/Poco/DynamicStruct.h#9 $
//
// Library: Foundation
// Package: Core
// Module: DynamicStruct
// Package: Dynamic
// Module: Struct
//
// Definition of the DynamicStruct class.
// Forward header for Struct class to maintain backward compatibility.
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
@ -39,361 +39,8 @@
#ifndef Foundation_DynamicStruct_INCLUDED
#define Foundation_DynamicStruct_INCLUDED
#include "Poco/Foundation.h"
#include "Poco/DynamicAny.h"
#include "Poco/DynamicAnyHolder.h"
#include <map>
#include <set>
namespace Poco {
class Foundation_API DynamicStruct
/// DynamicStruct allows to define a named collection of DynamicAny objects.
{
public:
typedef std::map<std::string, DynamicAny> Data;
typedef Data::iterator Iterator;
typedef Data::const_iterator ConstIterator;
DynamicStruct();
/// Creates an empty DynamicStruct
DynamicStruct(const Data &val);
/// Creates the DynamicStruct from the given value.
virtual ~DynamicStruct();
/// Destroys the DynamicStruct.
DynamicAny& operator [] (const std::string& name);
/// Returns the DynamicAny with the given name, creates an entry if not found.
const DynamicAny& operator [] (const std::string& name) const;
/// Returns the DynamicAny with the given name, throws a
/// NotFoundException if the data member is not found.
bool contains(const std::string& name) const;
/// Returns true if the DynamicStruct contains a member with the given
/// name
Iterator find(const std::string& name);
/// Returns an iterator, pointing to the <name,DynamicAny> pair containing
/// the element, or it returns end() if the member was not found
ConstIterator find(const std::string& name) const;
/// Returns a const iterator, pointing to the <name,DynamicAny> pair containing
/// the element, or it returns end() if the member was not found
Iterator end();
/// Returns the end iterator for the DynamicStruct
ConstIterator end() const;
/// Returns the end const iterator for the DynamicStruct
Iterator begin();
/// Returns the begin iterator for the DynamicStruct
ConstIterator begin() const;
/// Returns the begin const iterator for the DynamicStruct
std::pair<DynamicStruct::Iterator, bool> insert(const std::string& key, const DynamicAny& value);
/// Inserts a <name, DynamicAny> pair into the DynamicStruct,
/// returns a pair containing the iterator and a boolean which
/// indicates success or not (is true, when insert succeeded, false,
/// when already another element was present, in this case Iterator
/// points to that other element)
std::pair<DynamicStruct::Iterator, bool> insert(const DynamicStruct::Data::value_type& aPair);
/// Inserts a <name, DynamicAny> pair into the DynamicStruct,
/// returns a pair containing the iterator and a boolean which
/// indicates success or not (is true, when insert succeeded, false,
/// when already another element was present, in this case Iterator
/// points to that other element)
DynamicStruct::Data::size_type erase(const std::string& key);
/// Erases the element if found, returns number of elements deleted
void erase(DynamicStruct::Iterator it);
/// Erases the element at the given position
bool empty() const;
/// Returns true if the DynamicStruct doesn't contain any members
DynamicStruct::Data::size_type size() const;
/// Returns the number of members the DynamicStruct contains
std::set<std::string> members() const;
/// Returns a sorted collection containing all member names
private:
Data _data;
};
//
// inlines
//
inline DynamicAny& DynamicStruct::operator [] (const std::string& name)
{
return _data[name];
}
inline bool DynamicStruct::contains(const std::string& name) const
{
return find(name) != end();
}
inline DynamicStruct::Iterator DynamicStruct::find(const std::string& name)
{
return _data.find(name);
}
inline DynamicStruct::ConstIterator DynamicStruct::find(const std::string& name) const
{
return _data.find(name);
}
inline DynamicStruct::Iterator DynamicStruct::end()
{
return _data.end();
}
inline DynamicStruct::ConstIterator DynamicStruct::end() const
{
return _data.end();
}
inline DynamicStruct::Iterator DynamicStruct::begin()
{
return _data.begin();
}
inline DynamicStruct::ConstIterator DynamicStruct::begin() const
{
return _data.begin();
}
inline std::pair<DynamicStruct::Iterator, bool> DynamicStruct::insert(const std::string& key, const DynamicAny& value)
{
return insert(std::make_pair(key, value));
}
inline std::pair<DynamicStruct::Iterator, bool> DynamicStruct::insert(const DynamicStruct::Data::value_type& aPair)
{
return _data.insert(aPair);
}
inline DynamicStruct::Data::size_type DynamicStruct::erase(const std::string& key)
{
return _data.erase(key);
}
inline void DynamicStruct::erase(DynamicStruct::Iterator it)
{
_data.erase(it);
}
inline bool DynamicStruct::empty() const
{
return _data.empty();
}
inline DynamicStruct::Data::size_type DynamicStruct::size() const
{
return _data.size();
}
template <>
class DynamicAnyHolderImpl<DynamicStruct>: public DynamicAnyHolder
{
public:
DynamicAnyHolderImpl(const DynamicStruct& val): _val(val)
{
}
~DynamicAnyHolderImpl()
{
}
const std::type_info& type() const
{
return typeid(DynamicStruct);
}
void convert(Int8& val) const
{
throw BadCastException("Cannot cast DynamicStruct type to Int8");
}
void convert(Int16& val) const
{
throw BadCastException("Cannot cast DynamicStruct type to Int16");
}
void convert(Int32& val) const
{
throw BadCastException("Cannot cast DynamicStruct type to Int32");
}
void convert(Int64& val) const
{
throw BadCastException("Cannot cast DynamicStruct type to Int64");
}
void convert(UInt8& val) const
{
throw BadCastException("Cannot cast DynamicStruct type to UInt8");
}
void convert(UInt16& val) const
{
throw BadCastException("Cannot cast DynamicStruct type to UInt16");
}
void convert(UInt32& val) const
{
throw BadCastException("Cannot cast DynamicStruct type to UInt32");
}
void convert(UInt64& val) const
{
throw BadCastException("Cannot cast DynamicStruct type to UInt64");
}
void convert(bool& val) const
{
throw BadCastException("Cannot cast DynamicStruct type to bool");
}
void convert(float& val) const
{
throw BadCastException("Cannot cast DynamicStruct type to float");
}
void convert(double& val) const
{
throw BadCastException("Cannot cast DynamicStruct type to double");
}
void convert(char& val) const
{
throw BadCastException("Cannot cast DynamicStruct type to char");
}
void convert(std::string& val) const
{
// Serialize in JSON format: equals an object
// JSON format definition: { string ':' value } string:value pair n-times, sep. by ','
val.append("{ ");
DynamicStruct::ConstIterator it = _val.begin();
DynamicStruct::ConstIterator itEnd = _val.end();
if (!_val.empty())
{
DynamicAny key(it->first);
appendJSONString(val, key);
val.append(" : ");
appendJSONString(val, it->second);
++it;
}
for (; it != itEnd; ++it)
{
val.append(", ");
DynamicAny key(it->first);
appendJSONString(val, key);
val.append(" : ");
appendJSONString(val, it->second);
}
val.append(" }");
}
void convert(Poco::DateTime&) const
{
throw BadCastException("DynamicStruct -> Poco::DateTime");
}
void convert(Poco::LocalDateTime&) const
{
throw BadCastException("DynamicStruct -> Poco::LocalDateTime");
}
void convert(Poco::Timestamp&) const
{
throw BadCastException("DynamicStruct -> Poco::Timestamp");
}
DynamicAnyHolder* clone() const
{
return new DynamicAnyHolderImpl(_val);
}
const DynamicStruct& value() const
{
return _val;
}
bool isArray() const
{
return false;
}
bool isStruct() const
{
return true;
}
bool isInteger() const
{
return false;
}
bool isSigned() const
{
return false;
}
bool isNumeric() const
{
return false;
}
bool isString() const
{
return false;
}
DynamicAny& operator [] (const std::string& name)
{
return _val[name];
}
const DynamicAny& operator [] (const std::string& name) const
{
return _val[name];
}
private:
DynamicStruct _val;
};
} // namespace Poco
//@ deprecated
#include "Poco/Dynamic/Struct.h"
#endif // Foundation_DynamicStruct_INCLUDED

View File

@ -1,11 +1,11 @@
//
// DynamicStruct.cpp
// Struct.cpp
//
// $Id: //poco/Main/Foundation/src/DynamicStruct.cpp#4 $
// $Id: //poco/Main/Foundation/src/Struct.cpp#4 $
//
// Library: Foundation
// Package: Core
// Module: DynamicStruct
// Module: Struct
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
@ -34,31 +34,32 @@
//
#include "Poco/DynamicStruct.h"
#include "Poco/Dynamic/Struct.h"
#include "Poco/Exception.h"
namespace Poco {
namespace Dynamic {
DynamicStruct::DynamicStruct():
Struct::Struct():
_data()
{
}
DynamicStruct::DynamicStruct(const Data& d):
Struct::Struct(const Data& d):
_data(d)
{
}
DynamicStruct::~DynamicStruct()
Struct::~Struct()
{
}
const DynamicAny& DynamicStruct::operator[](const std::string& name) const
const Var& Struct::operator[](const std::string& name) const
{
ConstIterator it = find(name);
if (it == end())
@ -67,7 +68,7 @@ const DynamicAny& DynamicStruct::operator[](const std::string& name) const
}
std::set<std::string> DynamicStruct::members() const
std::set<std::string> Struct::members() const
{
std::set<std::string> keys;
ConstIterator it = begin();
@ -78,4 +79,4 @@ std::set<std::string> DynamicStruct::members() const
}
} // namespace Poco::Poco
} } // namespace Poco::Dynamic

View File

@ -1,11 +1,11 @@
//
// DynamicAny.cpp
// Var.cpp
//
// $Id: //poco/svn/Foundation/src/DynamicAny.cpp#3 $
// $Id: //poco/svn/Foundation/src/Var.cpp#3 $
//
// Library: Foundation
// Package: Core
// Module: DynamicAny
// Module: Var
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
@ -34,27 +34,28 @@
//
#include "Poco/DynamicAny.h"
#include "Poco/DynamicStruct.h"
#include "Poco/Dynamic/Var.h"
#include "Poco/Dynamic/Struct.h"
#include <algorithm>
#include <cctype>
namespace Poco {
namespace Dynamic {
DynamicAny::DynamicAny(): _pHolder(0)
Var::Var(): _pHolder(0)
{
}
DynamicAny::DynamicAny(const char* pVal):
_pHolder(new DynamicAnyHolderImpl<std::string>(pVal))
Var::Var(const char* pVal):
_pHolder(new VarHolderImpl<std::string>(pVal))
{
}
DynamicAny::DynamicAny(const DynamicAny& other):
Var::Var(const Var& other):
_pHolder(0)
{
if (other._pHolder)
@ -62,21 +63,21 @@ DynamicAny::DynamicAny(const DynamicAny& other):
}
DynamicAny::~DynamicAny()
Var::~Var()
{
delete _pHolder;
}
DynamicAny& DynamicAny::operator = (const DynamicAny& other)
Var& Var::operator = (const Var& other)
{
DynamicAny tmp(other);
Var tmp(other);
swap(tmp);
return *this;
}
const DynamicAny DynamicAny::operator + (const DynamicAny& other) const
const Var Var::operator + (const Var& other) const
{
if (isInteger())
{
@ -94,7 +95,7 @@ const DynamicAny DynamicAny::operator + (const DynamicAny& other) const
}
DynamicAny& DynamicAny::operator += (const DynamicAny& other)
Var& Var::operator += (const Var& other)
{
if (isInteger())
{
@ -112,7 +113,7 @@ DynamicAny& DynamicAny::operator += (const DynamicAny& other)
}
const DynamicAny DynamicAny::operator - (const DynamicAny& other) const
const Var Var::operator - (const Var& other) const
{
if (isInteger())
{
@ -128,7 +129,7 @@ const DynamicAny DynamicAny::operator - (const DynamicAny& other) const
}
DynamicAny& DynamicAny::operator -= (const DynamicAny& other)
Var& Var::operator -= (const Var& other)
{
if (isInteger())
{
@ -144,7 +145,7 @@ DynamicAny& DynamicAny::operator -= (const DynamicAny& other)
}
const DynamicAny DynamicAny::operator * (const DynamicAny& other) const
const Var Var::operator * (const Var& other) const
{
if (isInteger())
{
@ -160,7 +161,7 @@ const DynamicAny DynamicAny::operator * (const DynamicAny& other) const
}
DynamicAny& DynamicAny::operator *= (const DynamicAny& other)
Var& Var::operator *= (const Var& other)
{
if (isInteger())
{
@ -176,7 +177,7 @@ DynamicAny& DynamicAny::operator *= (const DynamicAny& other)
}
const DynamicAny DynamicAny::operator / (const DynamicAny& other) const
const Var Var::operator / (const Var& other) const
{
if (isInteger())
{
@ -192,7 +193,7 @@ const DynamicAny DynamicAny::operator / (const DynamicAny& other) const
}
DynamicAny& DynamicAny::operator /= (const DynamicAny& other)
Var& Var::operator /= (const Var& other)
{
if (isInteger())
{
@ -208,7 +209,7 @@ DynamicAny& DynamicAny::operator /= (const DynamicAny& other)
}
DynamicAny& DynamicAny::operator ++ ()
Var& Var::operator ++ ()
{
if (!isInteger())
throw InvalidArgumentException("Invalid operation for this data type.");
@ -216,17 +217,17 @@ DynamicAny& DynamicAny::operator ++ ()
return *this = *this + 1;
}
const DynamicAny DynamicAny::operator ++ (int)
const Var Var::operator ++ (int)
{
if (!isInteger())
throw InvalidArgumentException("Invalid operation for this data type.");
DynamicAny tmp(*this);
Var tmp(*this);
*this += 1;
return tmp;
}
DynamicAny& DynamicAny::operator -- ()
Var& Var::operator -- ()
{
if (!isInteger())
throw InvalidArgumentException("Invalid operation for this data type.");
@ -234,32 +235,32 @@ DynamicAny& DynamicAny::operator -- ()
return *this = *this - 1;
}
const DynamicAny DynamicAny::operator -- (int)
const Var Var::operator -- (int)
{
if (!isInteger())
throw InvalidArgumentException("Invalid operation for this data type.");
DynamicAny tmp(*this);
Var tmp(*this);
*this -= 1;
return tmp;
}
bool DynamicAny::operator == (const DynamicAny& other) const
bool Var::operator == (const Var& other) const
{
if (isEmpty() || other.isEmpty()) return false;
return convert<std::string>() == other.convert<std::string>();
}
bool DynamicAny::operator == (const char* other) const
bool Var::operator == (const char* other) const
{
if (isEmpty()) return false;
return convert<std::string>() == other;
}
bool DynamicAny::operator != (const DynamicAny& other) const
bool Var::operator != (const Var& other) const
{
if (isEmpty() && other.isEmpty()) return false;
else if (isEmpty() || other.isEmpty()) return true;
@ -268,83 +269,83 @@ bool DynamicAny::operator != (const DynamicAny& other) const
}
bool DynamicAny::operator != (const char* other) const
bool Var::operator != (const char* other) const
{
if (isEmpty()) return true;
return convert<std::string>() != other;
}
bool DynamicAny::operator < (const DynamicAny& other) const
bool Var::operator < (const Var& other) const
{
if (isEmpty() || other.isEmpty()) return false;
return convert<std::string>() < other.convert<std::string>();
}
bool DynamicAny::operator <= (const DynamicAny& other) const
bool Var::operator <= (const Var& other) const
{
if (isEmpty() || other.isEmpty()) return false;
return convert<std::string>() <= other.convert<std::string>();
}
bool DynamicAny::operator > (const DynamicAny& other) const
bool Var::operator > (const Var& other) const
{
if (isEmpty() || other.isEmpty()) return false;
return convert<std::string>() > other.convert<std::string>();
}
bool DynamicAny::operator >= (const DynamicAny& other) const
bool Var::operator >= (const Var& other) const
{
if (isEmpty() || other.isEmpty()) return false;
return convert<std::string>() >= other.convert<std::string>();
}
bool DynamicAny::operator || (const DynamicAny& other) const
bool Var::operator || (const Var& other) const
{
if (isEmpty() || other.isEmpty()) return false;
return convert<bool>() || other.convert<bool>();
}
bool DynamicAny::operator && (const DynamicAny& other) const
bool Var::operator && (const Var& other) const
{
if (isEmpty() || other.isEmpty()) return false;
return convert<bool>() && other.convert<bool>();
}
void DynamicAny::empty()
void Var::empty()
{
delete _pHolder;
_pHolder = 0;
}
DynamicAny& DynamicAny::operator [] (const std::string& name)
Var& Var::operator [] (const std::string& name)
{
return holderImpl<DynamicStruct, InvalidAccessException>("Not an array.")->operator[](name);
}
const DynamicAny& DynamicAny::operator [] (const std::string& name) const
const Var& Var::operator [] (const std::string& name) const
{
return const_cast<const DynamicAny&>(holderImpl<DynamicStruct,
return const_cast<const Var&>(holderImpl<DynamicStruct,
InvalidAccessException>("Not an array.")->operator[](name));
}
DynamicAny DynamicAny::parse(const std::string& val)
Var Var::parse(const std::string& val)
{
std::string::size_type t = 0;
return parse(val, t);
}
DynamicAny DynamicAny::parse(const std::string& val, std::string::size_type& pos)
Var Var::parse(const std::string& val, std::string::size_type& pos)
{
// { -> an Object==DynamicStruct
// [ -> an array
@ -368,7 +369,7 @@ DynamicAny DynamicAny::parse(const std::string& val, std::string::size_type& pos
}
DynamicAny DynamicAny::parseObject(const std::string& val, std::string::size_type& pos)
Var Var::parseObject(const std::string& val, std::string::size_type& pos)
{
poco_assert_dbg (val[pos] == '{');
++pos;
@ -381,7 +382,7 @@ DynamicAny DynamicAny::parseObject(const std::string& val, std::string::size_typ
if (val[pos] != ':')
throw DataFormatException("Incorrect object, must contain: key : value pairs");
++pos; // skip past :
DynamicAny value = parse(val, pos);
Var value = parse(val, pos);
aStruct.insert(key, value);
skipWhiteSpace(val, pos);
if (val[pos] == ',')
@ -397,12 +398,12 @@ DynamicAny DynamicAny::parseObject(const std::string& val, std::string::size_typ
}
DynamicAny DynamicAny::parseArray(const std::string& val, std::string::size_type& pos)
Var Var::parseArray(const std::string& val, std::string::size_type& pos)
{
poco_assert_dbg (val[pos] == '[');
++pos;
skipWhiteSpace(val, pos);
std::vector<DynamicAny> result;
std::vector<Var> result;
while (val[pos] != ']' && pos < val.size())
{
result.push_back(parse(val, pos));
@ -420,7 +421,7 @@ DynamicAny DynamicAny::parseArray(const std::string& val, std::string::size_type
}
std::string DynamicAny::parseString(const std::string& val, std::string::size_type& pos)
std::string Var::parseString(const std::string& val, std::string::size_type& pos)
{
static const std::string STR_STOP("'\"");
static const std::string OTHER_STOP(" ,]}"); // we stop at space, ',', ']' or '}'
@ -461,14 +462,14 @@ std::string DynamicAny::parseString(const std::string& val, std::string::size_ty
}
void DynamicAny::skipWhiteSpace(const std::string& val, std::string::size_type& pos)
void Var::skipWhiteSpace(const std::string& val, std::string::size_type& pos)
{
while (std::isspace(val[pos]))
++pos;
}
std::string DynamicAny::toString(const DynamicAny& any)
std::string Var::toString(const Var& any)
{
std::string res;
appendJSONString(res, any);
@ -476,4 +477,4 @@ std::string DynamicAny::toString(const DynamicAny& any)
}
} // namespace Poco::Poco
} } // namespace Poco::Dynamic

View File

@ -1,11 +1,11 @@
//
// DynamicAnyHolder.cpp
// VarHolder.cpp
//
// $Id: //poco/svn/Foundation/src/DynamicAnyHolder.cpp#3 $
// $Id: //poco/svn/Foundation/src/VarHolder.cpp#3 $
//
// Library: Foundation
// Package: Core
// Module: DynamicAnyHolder
// Module: VarHolder
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
@ -34,24 +34,25 @@
//
#include "Poco/DynamicAnyHolder.h"
#include "Poco/DynamicAny.h"
#include "Poco/Dynamic/VarHolder.h"
#include "Poco/Dynamic/Var.h"
namespace Poco {
namespace Dynamic {
DynamicAnyHolder::DynamicAnyHolder()
VarHolder::VarHolder()
{
}
DynamicAnyHolder::~DynamicAnyHolder()
VarHolder::~VarHolder()
{
}
void appendJSONString(std::string& val, const DynamicAny& any)
void appendJSONString(std::string& val, const Var& any)
{
bool isJsonString = (any.type() == typeid(std::string) || any.type() == typeid(char) || any.type() == typeid(Poco::DateTime) || any.type() == typeid(Poco::LocalDateTime));
if (isJsonString)
@ -66,4 +67,4 @@ void appendJSONString(std::string& val, const DynamicAny& any)
}
} // namespace Poco
} } // namespace Poco::Dynamic

View File

@ -37,7 +37,7 @@ objects = ActiveMethodTest ActivityTest ActiveDispatcherTest \
HashingTestSuite HashTableTest SimpleHashTableTest LinearHashTableTest \
HashSetTest HashMapTest SharedMemoryTest \
UniqueExpireCacheTest UniqueExpireLRUCacheTest \
TuplesTest NamedTuplesTest TypeListTest DynamicAnyTest FileStreamTest
TuplesTest NamedTuplesTest TypeListTest VarTest DynamicTestSuite FileStreamTest
target = testrunner
target_version = 1

View File

@ -277,9 +277,6 @@
<File
RelativePath=".\src\CoreTestSuite.cpp">
</File>
<File
RelativePath=".\src\DynamicAnyTest.cpp">
</File>
<File
RelativePath=".\src\DynamicFactoryTest.cpp">
</File>
@ -347,9 +344,6 @@
<File
RelativePath=".\src\CoreTestSuite.h">
</File>
<File
RelativePath=".\src\DynamicAnyTest.h">
</File>
<File
RelativePath=".\src\DynamicFactoryTest.h">
</File>
@ -1215,6 +1209,34 @@
</File>
</Filter>
</Filter>
<Filter
Name="Dynamic"
>
<Filter
Name="Header Files"
>
<File
RelativePath=".\src\DynamicTestSuite.h"
>
</File>
<File
RelativePath=".\src\VarTest.h"
>
</File>
</Filter>
<Filter
Name="Source Files"
>
<File
RelativePath=".\src\DynamicTestSuite.cpp"
>
</File>
<File
RelativePath=".\src\VarTest.cpp"
>
</File>
</Filter>
</Filter>
</Files>
<Globals>
</Globals>

View File

@ -406,10 +406,6 @@
RelativePath=".\src\CoreTestSuite.cpp"
>
</File>
<File
RelativePath=".\src\DynamicAnyTest.cpp"
>
</File>
<File
RelativePath=".\src\DynamicFactoryTest.cpp"
>
@ -498,10 +494,6 @@
RelativePath=".\src\CoreTestSuite.h"
>
</File>
<File
RelativePath=".\src\DynamicAnyTest.h"
>
</File>
<File
RelativePath=".\src\DynamicFactoryTest.h"
>
@ -1584,6 +1576,34 @@
</File>
</Filter>
</Filter>
<Filter
Name="Dynamic"
>
<Filter
Name="Header Files"
>
<File
RelativePath=".\src\DynamicTestSuite.h"
>
</File>
<File
RelativePath=".\src\VarTest.h"
>
</File>
</Filter>
<Filter
Name="Source Files"
>
<File
RelativePath=".\src\DynamicTestSuite.cpp"
>
</File>
<File
RelativePath=".\src\VarTest.cpp"
>
</File>
</Filter>
</Filter>
</Files>
<Globals>
</Globals>

View File

@ -395,10 +395,6 @@
RelativePath=".\src\CoreTestSuite.cpp"
>
</File>
<File
RelativePath=".\src\DynamicAnyTest.cpp"
>
</File>
<File
RelativePath=".\src\DynamicFactoryTest.cpp"
>
@ -487,10 +483,6 @@
RelativePath=".\src\CoreTestSuite.h"
>
</File>
<File
RelativePath=".\src\DynamicAnyTest.h"
>
</File>
<File
RelativePath=".\src\DynamicFactoryTest.h"
>
@ -1573,6 +1565,34 @@
</File>
</Filter>
</Filter>
<Filter
Name="Dynamic"
>
<Filter
Name="Header Files"
>
<File
RelativePath=".\src\DynamicTestSuite.h"
>
</File>
<File
RelativePath=".\src\VarTest.h"
>
</File>
</Filter>
<Filter
Name="Source Files"
>
<File
RelativePath=".\src\DynamicTestSuite.cpp"
>
</File>
<File
RelativePath=".\src\VarTest.cpp"
>
</File>
</Filter>
</Filter>
</Files>
<Globals>
</Globals>

View File

@ -47,7 +47,6 @@
#include "DynamicFactoryTest.h"
#include "MemoryPoolTest.h"
#include "AnyTest.h"
#include "DynamicAnyTest.h"
#include "FormatTest.h"
#include "TuplesTest.h"
#include "NamedTuplesTest.h"
@ -74,7 +73,6 @@ CppUnit::Test* CoreTestSuite::suite()
pSuite->addTest(DynamicFactoryTest::suite());
pSuite->addTest(MemoryPoolTest::suite());
pSuite->addTest(AnyTest::suite());
pSuite->addTest(DynamicAnyTest::suite());
pSuite->addTest(FormatTest::suite());
pSuite->addTest(TuplesTest::suite());
pSuite->addTest(NamedTuplesTest::suite());

File diff suppressed because it is too large Load Diff

View File

@ -1,185 +0,0 @@
//
// DynamicAnyTest.h
//
// $Id: //poco/svn/Foundation/testsuite/src/DynamicAnyTest.h#2 $
//
// Tests for Any types
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef DynamicAnyTest_INCLUDED
#define DynamicAnyTest_INCLUDED
#include "Poco/Foundation.h"
#include "Poco/DynamicAny.h"
#include "Poco/Exception.h"
#include "CppUnit/TestCase.h"
class DynamicAnyTest: public CppUnit::TestCase
{
public:
DynamicAnyTest(const std::string& name);
~DynamicAnyTest();
void testInt8();
void testInt16();
void testInt32();
void testInt64();
void testUInt8();
void testUInt16();
void testUInt32();
void testUInt64();
void testBool();
void testChar();
void testFloat();
void testDouble();
void testLong();
void testULong();
void testString();
void testUDT();
void testConversionOperator();
void testComparisonOperators();
void testArithmeticOperators();
void testLimitsInt();
void testLimitsFloat();
void testCtor();
void testIsStruct();
void testIsArray();
void testArrayIdxOperator();
void testDynamicStructBasics();
void testDynamicStruct();
void testArrayToString();
void testStructToString();
void testArrayOfStructsToString();
void testStructWithArraysToString();
void testJSONDeserializeString();
void testJSONDeserializePrimitives();
void testJSONDeserializeArray();
void testJSONDeserializeStruct();
void testJSONDeserializeComplex();
void testDate();
void testEmpty();
void setUp();
void tearDown();
static CppUnit::Test* suite();
private:
void testGetIdxMustThrow(Poco::DynamicAny& a1, std::vector<Poco::DynamicAny>::size_type n);
template<typename T>
void testGetIdx(Poco::DynamicAny& a1, std::vector<Poco::DynamicAny>::size_type n, const T& expectedResult)
{
Poco::DynamicAny& val1 = a1[n];
assert (val1 == expectedResult);
const Poco::DynamicAny& c1 = a1;
assert (a1 == c1); // silence the compiler
const Poco::DynamicAny& cval1 = a1[n];
assert (cval1 == expectedResult);
}
template<typename TL, typename TS>
void testLimitsSigned()
{
TL iMin = std::numeric_limits<TS>::min();
Poco::DynamicAny da = iMin - 1;
try { TS i; i = da.convert<TS>(); fail("must fail"); }
catch (Poco::RangeException&) {}
TL iMax = std::numeric_limits<TS>::max();
da = iMax + 1;
try { TS i; i = da.convert<TS>(); fail("must fail"); }
catch (Poco::RangeException&) {}
}
template<typename TL, typename TS>
void testLimitsFloatToInt()
{
Poco::DynamicAny da;
if (std::numeric_limits<TS>::is_signed)
{
TL iMin = static_cast<TL>(std::numeric_limits<TS>::min());
da = iMin * 10;
try { TS i; i = da.convert<TS>(); fail("must fail"); }
catch (Poco::RangeException&) {}
}
TL iMax = static_cast<TL>(std::numeric_limits<TS>::max());
da = iMax * 10;
try { TS i; i = da.convert<TS>(); fail("must fail"); }
catch (Poco::RangeException&) {}
}
template<typename TS, typename TU>
void testLimitsSignedUnsigned()
{
assert (std::numeric_limits<TS>::is_signed);
assert (!std::numeric_limits<TU>::is_signed);
TS iMin = std::numeric_limits<TS>::min();
Poco::DynamicAny da = iMin;
try { TU i; i = da.convert<TU>(); fail("must fail"); }
catch (Poco::RangeException&) {}
}
template<typename TL, typename TS>
void testLimitsUnsigned()
{
TL iMax = std::numeric_limits<TS>::max();
Poco::DynamicAny da = iMax + 1;
try { TS i; i = da.convert<TS>(); fail("must fail"); }
catch (Poco::RangeException&) {}
}
template <typename T>
void testEmptyComparisons()
{
Poco::DynamicAny da;
T val = 0;
assert (da != val);
assert (val != da);
assert (!(val == da));
assert (!(da == val));
assert (!(da < val));
assert (!(val < da));
assert (!(da > val));
assert (!(val > da));
assert (!(da <= val));
assert (!(val <= da));
assert (!(da >= val));
assert (!(val >= da));
}
};
#endif // DynamicAnyTest_INCLUDED

View File

@ -0,0 +1,44 @@
//
// DynamicTestSuite.cpp
//
// $Id: //poco/svn/Foundation/testsuite/src/DynamicTestSuite.cpp#2 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "DynamicTestSuite.h"
#include "VarTest.h"
CppUnit::Test* DynamicTestSuite::suite()
{
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("DynamicTestSuite");
pSuite->addTest(VarTest::suite());
return pSuite;
}

View File

@ -0,0 +1,49 @@
//
// DynamicTestSuite.h
//
// $Id: //poco/svn/Foundation/testsuite/src/DynamicTestSuite.h#2 $
//
// Definition of the DynamicTestSuite class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef DynamicTestSuite_INCLUDED
#define DynamicTestSuite_INCLUDED
#include "CppUnit/TestSuite.h"
class DynamicTestSuite
{
public:
static CppUnit::Test* suite();
};
#endif // DynamicTestSuite_INCLUDED

View File

@ -32,6 +32,7 @@
#include "FoundationTestSuite.h"
#include "CoreTestSuite.h"
#include "DynamicTestSuite.h"
#include "DateTimeTestSuite.h"
#include "StreamsTestSuite.h"
#include "CryptTestSuite.h"
@ -55,6 +56,7 @@ CppUnit::Test* FoundationTestSuite::suite()
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("FoundationTestSuite");
pSuite->addTest(CoreTestSuite::suite());
pSuite->addTest(DynamicTestSuite::suite());
pSuite->addTest(DateTimeTestSuite::suite());
pSuite->addTest(StreamsTestSuite::suite());
pSuite->addTest(CryptTestSuite::suite());