Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

MySQL: accept BLOBs type for strings #165

Closed
wants to merge 3 commits into from

2 participants

@adrianimboden

I noticed that when a TEXT column is being written in mysql, everything is OK.
When the column is being read, the type is being reported as BLOB tough.

This patch allows the type to be BLOB when reading as string.

Maybe the problem lies deeper, but I think this solution ist not that bad tough.

@obiltschnig
Owner

merged change into develop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 30, 2013
  1. @adrianimboden

    MySQL: accept BLOBs type for strings (TEXT datatype is being reported…

    adrianimboden authored
    … as BLOB datatype in the meta information when extracted)
Commits on May 12, 2013
  1. @adrianimboden
  2. @adrianimboden
This page is out of date. Refresh to see the latest.
Showing with 305 additions and 346 deletions.
  1. +4 −2 Data/MySQL/src/Extractor.cpp
  2. +4 −4 Data/MySQL/testsuite/src/MySQLTest.cpp
  3. +5 −5 Data/ODBC/src/ODBCStatementImpl.cpp
  4. +1 −1  Data/ODBC/testsuite/src/ODBCDB2Test.cpp
  5. +1 −1  Data/ODBC/testsuite/src/ODBCMySQLTest.cpp
  6. +1 −1  Data/ODBC/testsuite/src/ODBCOracleTest.cpp
  7. +1 −1  Data/ODBC/testsuite/src/ODBCPostgreSQLTest.cpp
  8. +1 −1  Data/ODBC/testsuite/src/ODBCSQLServerTest.cpp
  9. +1 −1  Data/ODBC/testsuite/src/ODBCSQLiteTest.cpp
  10. +3 −3 Data/ODBC/testsuite/src/ODBCTest.cpp
  11. +2 −2 Data/ODBC/testsuite/src/SQLExecutor.cpp
  12. +4 −4 Data/SQLite/src/SQLiteStatementImpl.cpp
  13. +2 −2 Data/SQLite/testsuite/src/SQLiteTest.cpp
  14. +3 −3 Data/include/Poco/Data/ArchiveStrategy.h
  15. +6 −6 Data/include/Poco/Data/Binding.h
  16. +6 −6 Data/include/Poco/Data/BulkBinding.h
  17. +7 −7 Data/include/Poco/Data/BulkExtraction.h
  18. +12 −12 Data/include/Poco/Data/Extraction.h
  19. +2 −2 Data/include/Poco/Data/RecordSet.h
  20. +5 −5 Data/include/Poco/Data/Row.h
  21. +1 −1  Data/include/Poco/Data/RowFormatter.h
  22. +1 −1  Data/include/Poco/Data/Statement.h
  23. +1 −1  Data/include/Poco/Data/StatementCreator.h
  24. +3 −3 Data/include/Poco/Data/StatementImpl.h
  25. +1 −1  Data/src/ArchiveStrategy.cpp
  26. +3 −3 Data/src/Row.cpp
  27. +6 −6 Data/src/SQLChannel.cpp
  28. +4 −4 Data/src/Statement.cpp
  29. +3 −3 Data/testsuite/src/TestStatementImpl.cpp
  30. +20 −20 Foundation/include/Poco/NamedTuple.h
  31. +2 −2 Foundation/include/Poco/ObjectPool.h
  32. +8 −44 Foundation/include/Poco/SharedPtr.h
  33. +1 −1  Foundation/src/NotificationCenter.cpp
  34. +10 −10 Foundation/src/TextEncoding.cpp
  35. +11 −11 Foundation/testsuite/src/SharedPtrTest.cpp
  36. +7 −7 Foundation/testsuite/src/TextEncodingTest.cpp
  37. +1 −1  JSON/include/Poco/JSON/Parser.h
  38. +3 −3 JSON/include/Poco/JSON/Template.h
  39. +2 −2 JSON/src/ParseHandler.cpp
  40. +26 −32 JSON/src/Template.cpp
  41. +2 −2 JSON/src/TemplateCache.cpp
  42. +4 −4 JSON/testsuite/src/JSONTest.cpp
  43. +4 −4 MongoDB/include/Poco/MongoDB/Database.h
  44. +3 −3 MongoDB/include/Poco/MongoDB/Document.h
  45. +1 −1  MongoDB/include/Poco/MongoDB/InsertRequest.h
  46. +1 −1  MongoDB/include/Poco/MongoDB/JavaScriptCode.h
  47. +1 −1  MongoDB/include/Poco/MongoDB/PoolableConnectionFactory.h
  48. +1 −1  MongoDB/include/Poco/MongoDB/RegularExpression.h
  49. +1 −1  MongoDB/src/Database.cpp
  50. +13 −13 MongoDB/src/Document.cpp
  51. +1 −1  MongoDB/src/RegularExpression.cpp
  52. +2 −3 MongoDB/src/ReplicaSet.cpp
  53. +1 −1  MongoDB/src/ResponseMessage.cpp
  54. +2 −2 MongoDB/testsuite/src/MongoDBTest.cpp
  55. +1 −1  Net/include/Poco/Net/ParallelSocketAcceptor.h
  56. +1 −1  Net/samples/HTTPFormServer/src/HTTPFormServer.cpp
  57. +1 −1  Net/samples/HTTPTimeServer/src/HTTPTimeServer.cpp
  58. +1 −1  Net/samples/TimeServer/src/TimeServer.cpp
  59. +1 −1  Net/samples/WebSocketServer/src/WebSocketServer.cpp
  60. +3 −3 Net/src/HTTPServer.cpp
  61. +14 −14 Net/testsuite/src/HTTPServerTest.cpp
  62. +3 −3 Net/testsuite/src/TCPServerTest.cpp
  63. +1 −1  Net/testsuite/src/WebSocketTest.cpp
  64. +2 −2 NetSSL_OpenSSL/include/Poco/Net/CertificateHandlerFactoryMgr.h
  65. +2 −2 NetSSL_OpenSSL/include/Poco/Net/PrivateKeyFactoryMgr.h
  66. +1 −1  NetSSL_OpenSSL/samples/HTTPSTimeServer/src/HTTPSTimeServer.cpp
  67. +3 −3 NetSSL_OpenSSL/samples/Mail/src/Mail.cpp
  68. +3 −3 NetSSL_OpenSSL/samples/download/src/download.cpp
  69. +2 −2 NetSSL_OpenSSL/src/CertificateHandlerFactoryMgr.cpp
  70. +2 −2 NetSSL_OpenSSL/src/PrivateKeyFactoryMgr.cpp
  71. +6 −6 NetSSL_OpenSSL/src/SSLManager.cpp
  72. +1 −1  NetSSL_OpenSSL/testsuite/src/HTTPSClientSessionTest.cpp
  73. +8 −8 NetSSL_OpenSSL/testsuite/src/HTTPSServerTest.cpp
  74. +5 −5 NetSSL_OpenSSL/testsuite/src/TCPServerTest.cpp
  75. +1 −1  PageCompiler/samples/HTTPTimeServer/src/HTTPTimeServerApp.cpp
  76. +8 −8 Util/src/JSONConfiguration.cpp
  77. +2 −2 XML/src/ParserEngine.cpp
  78. +1 −1  Zip/src/ZipManipulator.cpp
  79. +10 −10 Zip/src/ZipStream.cpp
View
6 Data/MySQL/src/Extractor.cpp
@@ -147,8 +147,10 @@ bool Extractor::extract(std::size_t pos, std::string& val)
if (_metadata.isNull(static_cast<Poco::UInt32>(pos)))
return false;
-
- if (_metadata.metaColumn(static_cast<Poco::UInt32>(pos)).type() != Poco::Data::MetaColumn::FDT_STRING)
+
+ //mysql reports TEXT types as FDT_BLOB when being extracted
+ MetaColumn::ColumnDataType columnType = _metadata.metaColumn(static_cast<Poco::UInt32>(pos)).type();
+ if (columnType != Poco::Data::MetaColumn::FDT_STRING && columnType != Poco::Data::MetaColumn::FDT_BLOB)
throw MySQLException("Extractor: not a string");
val.assign(reinterpret_cast<const char*>(_metadata.rawData(pos)), _metadata.length(pos));
View
8 Data/MySQL/testsuite/src/MySQLTest.cpp
@@ -57,8 +57,8 @@ using Poco::Nullable;
using Poco::Tuple;
using Poco::NamedTuple;
-Poco::SharedPtr<Poco::Data::Session> MySQLTest::_pSession = 0;
-Poco::SharedPtr<SQLExecutor> MySQLTest::_pExecutor = 0;
+Poco::SharedPtr<Poco::Data::Session> MySQLTest::_pSession;
+Poco::SharedPtr<SQLExecutor> MySQLTest::_pExecutor;
//
// Parameters for barebone-test
@@ -825,7 +825,7 @@ CppUnit::Test* MySQLTest::suite()
try
{
- _pSession = new Session(MySQL::Connector::KEY, _dbConnString);
+ _pSession = Poco::SharedPtr<Session>(new Session(MySQL::Connector::KEY, _dbConnString));
}
catch (ConnectionFailedException& ex)
{
@@ -835,7 +835,7 @@ CppUnit::Test* MySQLTest::suite()
std::cout << "*** Connected to [" << "MySQL" << "] test database." << std::endl;
- _pExecutor = new SQLExecutor("MySQL SQL Executor", _pSession);
+ _pExecutor = Poco::SharedPtr<SQLExecutor>(new SQLExecutor("MySQL SQL Executor", _pSession.get()));
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("MySQLTest");
View
10 Data/ODBC/src/ODBCStatementImpl.cpp
@@ -117,7 +117,7 @@ void ODBCStatementImpl::compileImpl()
std::size_t maxFieldSize = AnyCast<std::size_t>(session().getProperty("maxFieldSize"));
- _pBinder = new Binder(_stmt, maxFieldSize, bind, pDT);
+ _pBinder = BinderPtr(new Binder(_stmt, maxFieldSize, bind, pDT));
makeInternalExtractors();
doPrepare();
@@ -158,12 +158,12 @@ void ODBCStatementImpl::addPreparator()
std::size_t maxFieldSize = AnyCast<std::size_t>(session().getProperty("maxFieldSize"));
- _preparations.push_back(new Preparator(_stmt, statement, maxFieldSize, ext));
+ _preparations.push_back(PreparatorPtr(new Preparator(_stmt, statement, maxFieldSize, ext)));
}
else
- _preparations.push_back(new Preparator(*_preparations[0]));
+ _preparations.push_back(PreparatorPtr(new Preparator(*_preparations[0])));
- _extractors.push_back(new Extractor(_stmt, _preparations.back()));
+ _extractors.push_back(ExtractorPtr(new Extractor(_stmt, _preparations.back())));
}
@@ -187,7 +187,7 @@ void ODBCStatementImpl::doPrepare()
"SQLSetStmtAttr(SQL_ATTR_ROW_ARRAY_SIZE)");
}
- AbstractPreparation::Ptr pAP = 0;
+ AbstractPreparation::Ptr pAP;
Poco::Data::AbstractPreparator::Ptr pP = _preparations[curDataSet];
for (std::size_t pos = 0; it != itEnd; ++it)
{
View
2  Data/ODBC/testsuite/src/ODBCDB2Test.cpp
@@ -611,7 +611,7 @@ CppUnit::Test* ODBCDB2Test::suite()
{
std::cout << "*** Connected to [" << _driver << "] test database." << std::endl;
- _pExecutor = new SQLExecutor(_driver + " SQL Executor", _pSession);
+ _pExecutor = ExecPtr(new SQLExecutor(_driver + " SQL Executor", _pSession.get()));
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCDB2Test");
View
2  Data/ODBC/testsuite/src/ODBCMySQLTest.cpp
@@ -436,7 +436,7 @@ CppUnit::Test* ODBCMySQLTest::suite()
{
std::cout << "*** Connected to [" << _driver << "] test database." << std::endl;
- _pExecutor = new SQLExecutor(_driver + " SQL Executor", _pSession);
+ _pExecutor = ExecPtr(new SQLExecutor(_driver + " SQL Executor", _pSession.get()));
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCMySQLTest");
View
2  Data/ODBC/testsuite/src/ODBCOracleTest.cpp
@@ -860,7 +860,7 @@ CppUnit::Test* ODBCOracleTest::suite()
{
std::cout << "*** Connected to [" << _driver << "] test database." << std::endl;
- _pExecutor = new SQLExecutor(_driver + " SQL Executor", _pSession);
+ _pExecutor = ExecPtr(new SQLExecutor(_driver + " SQL Executor", _pSession.get()));
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCOracleTest");
View
2  Data/ODBC/testsuite/src/ODBCPostgreSQLTest.cpp
@@ -577,7 +577,7 @@ CppUnit::Test* ODBCPostgreSQLTest::suite()
{
std::cout << "*** Connected to [" << _driver << "] test database." << std::endl;
- _pExecutor = new SQLExecutor(_driver + " SQL Executor", _pSession);
+ _pExecutor = ExecPtr(new SQLExecutor(_driver + " SQL Executor", _pSession.get()));
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCPostgreSQLTest");
View
2  Data/ODBC/testsuite/src/ODBCSQLServerTest.cpp
@@ -741,7 +741,7 @@ CppUnit::Test* ODBCSQLServerTest::suite()
{
std::cout << "*** Connected to [" << _driver << "] test database." << std::endl;
- _pExecutor = new SQLExecutor(_driver + " SQL Executor", _pSession);
+ _pExecutor = ExecPtr(new SQLExecutor(_driver + " SQL Executor", _pSession.get()));
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCSQLServerTest");
View
2  Data/ODBC/testsuite/src/ODBCSQLiteTest.cpp
@@ -340,7 +340,7 @@ CppUnit::Test* ODBCSQLiteTest::suite()
{
std::cout << "*** Connected to [" << _driver << "] test database." << std::endl;
- _pExecutor = new SQLExecutor(_driver + " SQL Executor", _pSession);
+ _pExecutor = ExecPtr(new SQLExecutor(_driver + " SQL Executor", _pSession.get()));
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCSQLiteTest");
View
6 Data/ODBC/testsuite/src/ODBCTest.cpp
@@ -1311,15 +1311,15 @@ ODBCTest::SessionPtr ODBCTest::init(const std::string& driver,
const std::string& db)
{
Utility::drivers(_drivers);
- if (!canConnect(driver, dsn, uid, pwd, dbConnString, db)) return 0;
+ if (!canConnect(driver, dsn, uid, pwd, dbConnString, db)) return ODBCTest::SessionPtr();
try
{
std::cout << "Conecting to [" << dbConnString << ']' << std::endl;
- return new Session(Poco::Data::ODBC::Connector::KEY, dbConnString);
+ return ODBCTest::SessionPtr(new Session(Poco::Data::ODBC::Connector::KEY, dbConnString));
}catch (ConnectionFailedException& ex)
{
std::cout << ex.displayText() << std::endl;
- return 0;
+ return ODBCTest::SessionPtr();
}
}
View
4 Data/ODBC/testsuite/src/SQLExecutor.cpp
@@ -1109,8 +1109,8 @@ void SQLExecutor::sharedPtrComplexTypeVector()
{
std::string funct = "sharedPtrComplexTypeVector()";
std::vector<Poco::SharedPtr<Person> > people;
- people.push_back(new Person("LN1", "FN1", "ADDR1", 1));
- people.push_back(new Person("LN2", "FN2", "ADDR2", 2));
+ people.push_back(Poco::SharedPtr<Person>(new Person("LN1", "FN1", "ADDR1", 1)));
+ people.push_back(Poco::SharedPtr<Person>(new Person("LN2", "FN2", "ADDR2", 2)));
try { session() << "INSERT INTO Person VALUES (?,?,?,?)", use(people), now; }
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
View
8 Data/SQLite/src/SQLiteStatementImpl.cpp
@@ -130,13 +130,13 @@ void SQLiteStatementImpl::compileImpl()
_pStmt = pStmt;
if (!leftOver.empty())
{
- _pLeftover = new std::string(leftOver);
+ _pLeftover = SharedPtr<std::string>(new std::string(leftOver));
_canCompile = true;
}
else _canCompile = false;
- _pBinder = new Binder(_pStmt);
- _pExtractor = new Extractor(_pStmt);
+ _pBinder = BinderPtr(new Binder(_pStmt));
+ _pExtractor = ExtractorPtr(new Extractor(_pStmt));
if (SQLITE_DONE == _nextResponse && _isExtracted)
{
@@ -235,7 +235,7 @@ void SQLiteStatementImpl::clear()
sqlite3_finalize(_pStmt);
_pStmt=0;
}
- _pLeftover = 0;
+ _pLeftover = SharedPtr<std::string>();
}
View
4 Data/SQLite/testsuite/src/SQLiteTest.cpp
@@ -609,8 +609,8 @@ void SQLiteTest::testSharedPtrComplexTypeVector()
{
Session tmp (Poco::Data::SQLite::Connector::KEY, "dummy.db");
std::vector<Poco::SharedPtr<Person> > people;
- people.push_back(new Person("LN1", "FN1", "ADDR1", 1));
- people.push_back(new Person("LN2", "FN2", "ADDR2", 2));
+ people.push_back(Poco::SharedPtr<Person>(new Person("LN1", "FN1", "ADDR1", 1)));
+ people.push_back(Poco::SharedPtr<Person>(new Person("LN2", "FN2", "ADDR2", 2)));
tmp << "DROP TABLE IF EXISTS Person", now;
tmp << "CREATE TABLE IF NOT EXISTS Person (LastName VARCHAR(30), FirstName VARCHAR, Address VARCHAR, Age INTEGER(3))", now;
tmp << "INSERT INTO PERSON VALUES(:ln, :fn, :ad, :age)", use(people), now;
View
6 Data/include/Poco/Data/ArchiveStrategy.h
@@ -157,19 +157,19 @@ inline Session& ArchiveStrategy::session()
inline void ArchiveStrategy::setCopyStatement()
{
- _pCopyStatement = new Statement(*_pSession);
+ _pCopyStatement = StatementPtr(new Statement(*_pSession));
}
inline void ArchiveStrategy::setDeleteStatement()
{
- _pDeleteStatement = new Statement(*_pSession);
+ _pDeleteStatement = StatementPtr(new Statement(*_pSession));
}
inline void ArchiveStrategy::setCountStatement()
{
- _pCountStatement = new Statement(*_pSession);
+ _pCountStatement = StatementPtr(new Statement(*_pSession));
}
View
12 Data/include/Poco/Data/Binding.h
@@ -1411,14 +1411,14 @@ inline AbstractBinding::Ptr use(T& t, const std::string& name = "")
// 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);
+ return AbstractBinding::Ptr(new Binding<T>(t, name, AbstractBinding::PD_IN));
}
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);
+ return AbstractBinding::Ptr(new Binding<NullData>(const_cast<NullData&>(t), name, AbstractBinding::PD_IN));
}
@@ -1426,7 +1426,7 @@ template <typename T>
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);
+ return AbstractBinding::Ptr(new Binding<T>(t, name, AbstractBinding::PD_IN));
}
@@ -1450,7 +1450,7 @@ inline AbstractBinding::Ptr out(T& t)
/// Convenience function for a more compact Binding creation.
{
poco_static_assert (!IsConst<T>::VALUE);
- return new Binding<T>(t, "", AbstractBinding::PD_OUT);
+ return AbstractBinding::Ptr(new Binding<T>(t, "", AbstractBinding::PD_OUT));
}
@@ -1459,7 +1459,7 @@ inline AbstractBinding::Ptr io(T& t)
/// Convenience function for a more compact Binding creation.
{
poco_static_assert (!IsConst<T>::VALUE);
- return new Binding<T>(t, "", AbstractBinding::PD_IN_OUT);
+ return AbstractBinding::Ptr(new Binding<T>(t, "", AbstractBinding::PD_IN_OUT));
}
@@ -1496,7 +1496,7 @@ 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.
{
- return new CopyBinding<T>(t, name, AbstractBinding::PD_IN);
+ return AbstractBinding::Ptr(new CopyBinding<T>(t, name, AbstractBinding::PD_IN));
}
View
12 Data/include/Poco/Data/BulkBinding.h
@@ -117,7 +117,7 @@ template <typename T>
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);
+ return AbstractBinding::Ptr(new BulkBinding<std::vector<T> >(t, static_cast<Poco::UInt32>(t.size()), name));
}
@@ -125,7 +125,7 @@ template <typename T>
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);
+ return AbstractBinding::Ptr(new BulkBinding<std::vector<T> >(t, static_cast<Poco::UInt32>(t.size()), name));
}
@@ -133,7 +133,7 @@ template <typename T>
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);
+ return AbstractBinding::Ptr(new BulkBinding<std::deque<T> >(t, static_cast<Poco::UInt32>(t.size()), name));
}
@@ -141,7 +141,7 @@ template <typename T>
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);
+ return AbstractBinding::Ptr(new BulkBinding<std::deque<T> >(t, static_cast<Poco::UInt32>(t.size()), name));
}
@@ -149,7 +149,7 @@ template <typename T>
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);
+ return AbstractBinding::Ptr(new BulkBinding<std::list<T> >(t, static_cast<Poco::UInt32>(t.size()), name));
}
@@ -157,7 +157,7 @@ template <typename T>
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);
+ return AbstractBinding::Ptr(new BulkBinding<std::list<T> >(t, static_cast<Poco::UInt32>(t.size()), name));
}
View
14 Data/include/Poco/Data/BulkExtraction.h
@@ -138,7 +138,7 @@ class BulkExtraction: public AbstractExtraction
if (limit != _rResult.size()) _rResult.resize(limit);
pPrep->setLength(limit);
pPrep->setBulk(true);
- return new Preparation<C>(pPrep, col, _rResult);
+ return AbstractPreparation::Ptr(new Preparation<C>(pPrep, col, _rResult));
}
protected:
@@ -233,7 +233,7 @@ AbstractExtraction::Ptr into(std::vector<T>& t, const Bulk& bulk, const Position
/// Convenience function to allow for a more compact creation of an extraction object
/// with std::vector bulk extraction support.
{
- return new BulkExtraction<std::vector<T> >(t, bulk.size(), pos);
+ return AbstractExtraction::Ptr(new BulkExtraction<std::vector<T> >(t, bulk.size(), pos));
}
@@ -244,7 +244,7 @@ AbstractExtraction::Ptr into(std::vector<T>& t, BulkFnType, const Position& pos
{
Poco::UInt32 size = static_cast<Poco::UInt32>(t.size());
if (0 == size) throw InvalidArgumentException("Zero length not allowed.");
- return new BulkExtraction<std::vector<T> >(t, size, pos);
+ return AbstractExtraction::Ptr(new BulkExtraction<std::vector<T> >(t, size, pos));
}
@@ -253,7 +253,7 @@ AbstractExtraction::Ptr into(std::deque<T>& t, const Bulk& bulk, const Position&
/// Convenience function to allow for a more compact creation of an extraction object
/// with std::deque bulk extraction support.
{
- return new BulkExtraction<std::deque<T> >(t, bulk.size(), pos);
+ return AbstractExtraction::Ptr(new BulkExtraction<std::deque<T> >(t, bulk.size(), pos));
}
@@ -264,7 +264,7 @@ AbstractExtraction::Ptr into(std::deque<T>& t, BulkFnType, const Position& pos =
{
Poco::UInt32 size = static_cast<Poco::UInt32>(t.size());
if (0 == size) throw InvalidArgumentException("Zero length not allowed.");
- return new BulkExtraction<std::deque<T> >(t, size, pos);
+ return AbstractExtraction::Ptr(new BulkExtraction<std::deque<T> >(t, size, pos));
}
@@ -273,7 +273,7 @@ AbstractExtraction::Ptr into(std::list<T>& t, const Bulk& bulk, const Position&
/// Convenience function to allow for a more compact creation of an extraction object
/// with std::list bulk extraction support.
{
- return new BulkExtraction<std::list<T> >(t, bulk.size(), pos);
+ return AbstractExtraction::Ptr(new BulkExtraction<std::list<T> >(t, bulk.size(), pos));
}
@@ -284,7 +284,7 @@ AbstractExtraction::Ptr into(std::list<T>& t, BulkFnType, const Position& pos =
{
Poco::UInt32 size = static_cast<Poco::UInt32>(t.size());
if (0 == size) throw InvalidArgumentException("Zero length not allowed.");
- return new BulkExtraction<std::list<T> >(t, size, pos);
+ return AbstractExtraction::Ptr(new BulkExtraction<std::list<T> >(t, size, pos));
}
View
24 Data/include/Poco/Data/Extraction.h
@@ -137,7 +137,7 @@ class Extraction: public AbstractExtraction
AbstractPreparation::Ptr createPreparation(AbstractPreparator::Ptr& pPrep, std::size_t pos)
{
- return new Preparation<T>(pPrep, pos, _rResult);
+ return AbstractPreparation::Ptr(new Preparation<T>(pPrep, pos, _rResult));
}
private:
@@ -217,7 +217,7 @@ class Extraction<std::vector<T> >: public AbstractExtraction
AbstractPreparation::Ptr createPreparation(AbstractPreparator::Ptr& pPrep, std::size_t pos)
{
- return new Preparation<T>(pPrep, pos, _default);
+ return AbstractPreparation::Ptr(new Preparation<T>(pPrep, pos, _default));
}
protected:
@@ -303,7 +303,7 @@ class Extraction<std::vector<bool> >: public AbstractExtraction
AbstractPreparation::Ptr createPreparation(AbstractPreparator::Ptr& pPrep, std::size_t pos)
{
- return new Preparation<bool>(pPrep, pos, _default);
+ return SharedPtr<AbstractPreparation>(new Preparation<bool>(pPrep, pos, _default));
}
protected:
@@ -387,7 +387,7 @@ class Extraction<std::list<T> >: public AbstractExtraction
AbstractPreparation::Ptr createPreparation(AbstractPreparator::Ptr& pPrep, std::size_t pos)
{
- return new Preparation<T>(pPrep, pos, _default);
+ return AbstractPreparation::Ptr(new Preparation<T>(pPrep, pos, _default));
}
protected:
@@ -471,7 +471,7 @@ class Extraction<std::deque<T> >: public AbstractExtraction
AbstractPreparation::Ptr createPreparation(AbstractPreparator::Ptr& pPrep, std::size_t pos)
{
- return new Preparation<T>(pPrep, pos, _default);
+ return AbstractPreparation::Ptr(new Preparation<T>(pPrep, pos, _default));
}
protected:
@@ -612,7 +612,7 @@ class Extraction<std::set<T> >: public AbstractExtraction
AbstractPreparation::Ptr createPreparation(AbstractPreparator::Ptr& pPrep, std::size_t pos)
{
- return new Preparation<T>(pPrep, pos, _default);
+ return AbstractPreparation::Ptr(new Preparation<T>(pPrep, pos, _default));
}
private:
@@ -676,7 +676,7 @@ class Extraction<std::multiset<T> >: public AbstractExtraction
AbstractPreparation::Ptr createPreparation(AbstractPreparator::Ptr& pPrep, std::size_t pos)
{
- return new Preparation<T>(pPrep, pos, _default);
+ return AbstractPreparation::Ptr(new Preparation<T>(pPrep, pos, _default));
}
private:
@@ -740,7 +740,7 @@ class Extraction<std::map<K, V> >: public AbstractExtraction
AbstractPreparation::Ptr createPreparation(AbstractPreparator::Ptr& pPrep, std::size_t pos)
{
- return new Preparation<V>(pPrep, pos, _default);
+ return AbstractPreparation::Ptr(new Preparation<V>(pPrep, pos, _default));
}
private:
@@ -804,7 +804,7 @@ class Extraction<std::multimap<K, V> >: public AbstractExtraction
AbstractPreparation::Ptr createPreparation(AbstractPreparator::Ptr& pPrep, std::size_t pos)
{
- return new Preparation<V>(pPrep, pos, _default);
+ return AbstractPreparation::Ptr(new Preparation<V>(pPrep, pos, _default));
}
private:
@@ -820,7 +820,7 @@ template <typename 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);
+ return AbstractExtraction::Ptr(new Extraction<T>(t));
}
@@ -829,7 +829,7 @@ 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.
{
- return new Extraction<T>(t, pos);
+ return AbstractExtraction::Ptr(new Extraction<T>(t, pos));
}
@@ -838,7 +838,7 @@ 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
{
- return new Extraction<T>(t, def, pos);
+ return AbstractExtraction::Ptr(new Extraction<T>(t, def, pos));
}
View
4 Data/include/Poco/Data/RecordSet.h
@@ -99,12 +99,12 @@ class Data_API RecordSet: private Statement
static const std::size_t UNKNOWN_TOTAL_ROW_COUNT;
explicit RecordSet(const Statement& rStatement,
- RowFormatter::Ptr pRowFormatter = 0);
+ RowFormatter::Ptr pRowFormatter = RowFormatter::Ptr());
/// Creates the RecordSet.
explicit RecordSet(Session& rSession,
const std::string& query,
- RowFormatter::Ptr pRowFormatter = 0);
+ RowFormatter::Ptr pRowFormatter = RowFormatter::Ptr());
/// Creates the RecordSet.
explicit RecordSet(Session& rSession,
View
10 Data/include/Poco/Data/Row.h
@@ -104,12 +104,12 @@ class Data_API Row
/// Creates the Row.
Row(NameVecPtr pNames,
- const RowFormatter::Ptr& pFormatter = 0);
+ const RowFormatter::Ptr& pFormatter = RowFormatter::Ptr());
/// Creates the Row.
Row(NameVecPtr pNames,
const SortMapPtr& pSortMap,
- const RowFormatter::Ptr& pFormatter = 0);
+ const RowFormatter::Ptr& pFormatter = RowFormatter::Ptr());
/// Creates the Row.
~Row();
@@ -128,7 +128,7 @@ class Data_API Row
void append(const std::string& name, const T& val)
/// Appends the value to the row.
{
- if (!_pNames) _pNames = new NameVec;
+ if (!_pNames) _pNames = NameVecPtr(new NameVec);
_values.push_back(val);
_pNames->push_back(name);
if (1 == _values.size()) addSortField(0);
@@ -221,14 +221,14 @@ class Data_API Row
const ValueVec& values() const;
/// Returns the const reference to values vector.
- void setFormatter(const RowFormatter::Ptr& pFormatter = 0);
+ void setFormatter(const RowFormatter::Ptr& pFormatter = RowFormatter::Ptr());
/// Sets the formatter for this row and takes the
/// shared ownership of it.
const RowFormatter& getFormatter() const;
/// Returns the reference to the formatter.
- void setSortMap(const SortMapPtr& pSortMap = 0);
+ void setSortMap(const SortMapPtr& pSortMap = SortMapPtr());
/// Adds the sorting fields entry and takes the
/// shared ownership of it.
View
2  Data/include/Poco/Data/RowFormatter.h
@@ -240,7 +240,7 @@ template <typename T>
inline RowFormatter::Ptr format(const T& formatter)
/// Utility function used to pass formatter to the statement.
{
- return new T(formatter);
+ return RowFormatter::Ptr(new T(formatter));
}
View
2  Data/include/Poco/Data/Statement.h
@@ -804,7 +804,7 @@ inline void Statement::setRowFormatter(RowFormatter::Ptr pRowFormatter)
inline const RowFormatter::Ptr& Statement::getRowFormatter()
{
- if (!_pRowFormatter) _pRowFormatter = new SimpleRowFormatter;
+ if (!_pRowFormatter) _pRowFormatter = RowFormatter::Ptr(new SimpleRowFormatter);
return _pRowFormatter;
}
View
2  Data/include/Poco/Data/StatementCreator.h
@@ -79,7 +79,7 @@ class Data_API StatementCreator
if (!_ptrImpl->isConnected())
throw NotConnectedException(_ptrImpl->connectionString());
- Statement stmt(_ptrImpl->createStatementImpl());
+ Statement stmt(StatementImpl::Ptr(_ptrImpl->createStatementImpl()));
stmt << t;
return stmt;
}
View
6 Data/include/Poco/Data/StatementImpl.h
@@ -339,7 +339,7 @@ class Data_API StatementImpl
{
C* pData = new C;
Column<C>* pCol = new Column<C>(mc, pData);
- return new InternalExtraction<C>(*pData, pCol, Poco::UInt32(currentDataSet()));
+ return SharedPtr<InternalExtraction<C> >(new InternalExtraction<C>(*pData, pCol, Poco::UInt32(currentDataSet())));
}
template <class C>
@@ -347,10 +347,10 @@ class Data_API StatementImpl
{
C* pData = new C;
Column<C>* pCol = new Column<C>(mc, pData);
- return new InternalBulkExtraction<C>(*pData,
+ return SharedPtr<InternalBulkExtraction<C> >(new InternalBulkExtraction<C>(*pData,
pCol,
static_cast<Poco::UInt32>(getExtractionLimit()),
- Position(currentDataSet()));
+ Position(currentDataSet())));
}
template <class T>
View
2  Data/src/ArchiveStrategy.cpp
@@ -74,7 +74,7 @@ void ArchiveStrategy::open()
if (_connector.empty() || _connect.empty())
throw IllegalStateException("Connector and connect string must be non-empty.");
- _pSession = new Session(_connector, _connect);
+ _pSession = SessionPtr(new Session(_connector, _connect));
}
View
6 Data/src/Row.cpp
@@ -63,7 +63,7 @@ Row::Row(NameVecPtr pNames,
const RowFormatter::Ptr& pFormatter): _pNames(pNames)
{
if (!_pNames) throw NullPointerException();
- init(0, pFormatter);
+ init(SortMapPtr(), pFormatter);
}
@@ -376,7 +376,7 @@ void Row::setFormatter(const RowFormatter::Ptr& pFormatter)
if (pFormatter.get())
_pFormatter = pFormatter;
else
- _pFormatter = new SimpleRowFormatter;
+ _pFormatter = SimpleRowFormatter::Ptr(new SimpleRowFormatter);
}
@@ -385,7 +385,7 @@ void Row::setSortMap(const SortMapPtr& pSortMap)
if (pSortMap.get())
_pSortMap = pSortMap;
else
- _pSortMap = new SortMap;
+ _pSortMap = SortMapPtr(new SortMap);
}
View
12 Data/src/SQLChannel.cpp
@@ -98,7 +98,7 @@ void SQLChannel::open()
if (_connector.empty() || _connect.empty())
throw IllegalStateException("Connector and connect string must be non-empty.");
- _pSession = new Session(_connector, _connect);
+ _pSession = SessionPtr(new Session(_connector, _connect));
initLogStatement();
}
@@ -181,7 +181,7 @@ void SQLChannel::setProperty(const std::string& name, const std::string& value)
{
if (value.empty())
{
- _pArchiveStrategy = 0;
+ _pArchiveStrategy = StrategyPtr();
}
else if (_pArchiveStrategy)
{
@@ -189,14 +189,14 @@ void SQLChannel::setProperty(const std::string& name, const std::string& value)
}
else
{
- _pArchiveStrategy = new ArchiveByAgeStrategy(_connector, _connect, _table, value);
+ _pArchiveStrategy = StrategyPtr(new ArchiveByAgeStrategy(_connector, _connect, _table, value));
}
}
else if (name == PROP_MAX_AGE)
{
if (value.empty() || "forever" == value)
{
- _pArchiveStrategy = 0;
+ _pArchiveStrategy = StrategyPtr();
}
else if (_pArchiveStrategy)
{
@@ -204,7 +204,7 @@ void SQLChannel::setProperty(const std::string& name, const std::string& value)
}
else
{
- ArchiveByAgeStrategy* p = new ArchiveByAgeStrategy(_connector, _connect, _table);
+ StrategyPtr p(new ArchiveByAgeStrategy(_connector, _connect, _table));
p->setThreshold(value);
_pArchiveStrategy = p;
}
@@ -277,7 +277,7 @@ std::string SQLChannel::getProperty(const std::string& name) const
void SQLChannel::initLogStatement()
{
- _pLogStatement = new Statement(*_pSession);
+ _pLogStatement = StatementPtr(new Statement(*_pSession));
std::string sql;
Poco::format(sql, "INSERT INTO %s VALUES (?,?,?,?,?,?,?,?)", _table);
View
8 Data/src/Statement.cpp
@@ -103,7 +103,7 @@ void Statement::swap(Statement& other)
Statement& Statement::reset(Session& session)
{
- Statement stmt(session.createStatementImpl());
+ Statement stmt(StatementImpl::Ptr(session.createStatementImpl()));
swap(stmt);
return *this;
}
@@ -150,8 +150,8 @@ const Statement::Result& Statement::doAsyncExec(bool reset)
{
if (done()) _pImpl->reset();
if (!_pAsyncExec)
- _pAsyncExec = new AsyncExecMethod(_pImpl, &StatementImpl::execute);
- _pResult = new Result((*_pAsyncExec)(reset));
+ _pAsyncExec = AsyncExecMethodPtr(new AsyncExecMethod(_pImpl.get(), &StatementImpl::execute));
+ _pResult = ResultPtr(new Result((*_pAsyncExec)(reset)));
return *_pResult;
}
@@ -160,7 +160,7 @@ void Statement::setAsync(bool async)
{
_async = async;
if (_async && !_pAsyncExec)
- _pAsyncExec = new AsyncExecMethod(_pImpl, &StatementImpl::execute);
+ _pAsyncExec = AsyncExecMethodPtr(new AsyncExecMethod(_pImpl.get(), &StatementImpl::execute));
}
View
6 Data/testsuite/src/TestStatementImpl.cpp
@@ -54,9 +54,9 @@ TestStatementImpl::~TestStatementImpl()
void TestStatementImpl::compileImpl()
{
// prepare binding
- _ptrBinder = new Binder;
- _ptrExtractor = new Extractor;
- _ptrPreparation = new Preparator;
+ _ptrBinder = SharedPtr<Binder>(new Binder);
+ _ptrExtractor = SharedPtr<Extractor>(new Extractor);
+ _ptrPreparation = SharedPtr<Preparator>(new Preparator);
_compiled = true;
}
View
40 Foundation/include/Poco/NamedTuple.h
@@ -319,7 +319,7 @@ struct NamedTuple: public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T1
{
if (!_pNames)
{
- _pNames = new NameVec;
+ _pNames = NameVecPtr(new NameVec);
_pNames->push_back(n0);
_pNames->push_back(n1);
_pNames->push_back(n2);
@@ -609,7 +609,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
{
if (!_pNames)
{
- _pNames = new NameVec;
+ _pNames = NameVecPtr(new NameVec);
_pNames->push_back(n0);
_pNames->push_back(n1);
_pNames->push_back(n2);
@@ -891,7 +891,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
{
if (!_pNames)
{
- _pNames = new NameVec;
+ _pNames = NameVecPtr(new NameVec);
_pNames->push_back(n0);
_pNames->push_back(n1);
_pNames->push_back(n2);
@@ -1165,7 +1165,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,Null
{
if (!_pNames)
{
- _pNames = new NameVec;
+ _pNames = NameVecPtr(new NameVec);
_pNames->push_back(n0);
_pNames->push_back(n1);
_pNames->push_back(n2);
@@ -1432,7 +1432,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,NullType
{
if (!_pNames)
{
- _pNames = new NameVec;
+ _pNames = NameVecPtr(new NameVec);
_pNames->push_back(n0);
_pNames->push_back(n1);
_pNames->push_back(n2);
@@ -1691,7 +1691,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,NullTypeList
{
if (!_pNames)
{
- _pNames = new NameVec;
+ _pNames = NameVecPtr(new NameVec);
_pNames->push_back(n0);
_pNames->push_back(n1);
_pNames->push_back(n2);
@@ -1942,7 +1942,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,NullTypeList>:
{
if (!_pNames)
{
- _pNames = new NameVec;
+ _pNames = NameVecPtr(new NameVec);
_pNames->push_back(n0);
_pNames->push_back(n1);
_pNames->push_back(n2);
@@ -2184,7 +2184,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,NullTypeList>:
{
if (!_pNames)
{
- _pNames = new NameVec;
+ _pNames = NameVecPtr(new NameVec);
_pNames->push_back(n0);
_pNames->push_back(n1);
_pNames->push_back(n2);
@@ -2419,7 +2419,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,NullTypeList>:
{
if (!_pNames)
{
- _pNames = new NameVec;
+ _pNames = NameVecPtr(new NameVec);
_pNames->push_back(n0);
_pNames->push_back(n1);
_pNames->push_back(n2);
@@ -2645,7 +2645,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,NullTypeList>:
{
if (!_pNames)
{
- _pNames = new NameVec;
+ _pNames = NameVecPtr(new NameVec);
_pNames->push_back(n0);
_pNames->push_back(n1);
_pNames->push_back(n2);
@@ -2864,7 +2864,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,NullTypeList>:
{
if (!_pNames)
{
- _pNames = new NameVec;
+ _pNames = NameVecPtr(new NameVec);
_pNames->push_back(n0);
_pNames->push_back(n1);
_pNames->push_back(n2);
@@ -3075,7 +3075,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,NullTypeList>:
{
if (!_pNames)
{
- _pNames = new NameVec;
+ _pNames = NameVecPtr(new NameVec);
_pNames->push_back(n0);
_pNames->push_back(n1);
_pNames->push_back(n2);
@@ -3278,7 +3278,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,NullTypeList>:
{
if (!_pNames)
{
- _pNames = new NameVec;
+ _pNames = NameVecPtr(new NameVec);
_pNames->push_back(n0);
_pNames->push_back(n1);
_pNames->push_back(n2);
@@ -3471,7 +3471,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,NullTypeList>:
{
if (!_pNames)
{
- _pNames = new NameVec;
+ _pNames = NameVecPtr(new NameVec);
_pNames->push_back(n0);
_pNames->push_back(n1);
_pNames->push_back(n2);
@@ -3656,7 +3656,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,NullTypeList>:
{
if (!_pNames)
{
- _pNames = new NameVec;
+ _pNames = NameVecPtr(new NameVec);
_pNames->push_back(n0);
_pNames->push_back(n1);
_pNames->push_back(n2);
@@ -3835,7 +3835,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,NullTypeList>:
{
if (!_pNames)
{
- _pNames = new NameVec;
+ _pNames = NameVecPtr(new NameVec);
_pNames->push_back(n0);
_pNames->push_back(n1);
_pNames->push_back(n2);
@@ -4005,7 +4005,7 @@ struct NamedTuple<T0,T1,T2,T3,NullTypeList>:
{
if (!_pNames)
{
- _pNames = new NameVec;
+ _pNames = NameVecPtr(new NameVec);
_pNames->push_back(n0);
_pNames->push_back(n1);
_pNames->push_back(n2);
@@ -4168,7 +4168,7 @@ struct NamedTuple<T0,T1,T2,NullTypeList>:
{
if (!_pNames)
{
- _pNames = new NameVec;
+ _pNames = NameVecPtr(new NameVec);
_pNames->push_back(n0);
_pNames->push_back(n1);
_pNames->push_back(n2);
@@ -4323,7 +4323,7 @@ struct NamedTuple<T0,T1,NullTypeList>:
{
if (!_pNames)
{
- _pNames = new NameVec;
+ _pNames = NameVecPtr(new NameVec);
_pNames->push_back(n0);
_pNames->push_back(n1);
}
@@ -4469,7 +4469,7 @@ struct NamedTuple<T0,NullTypeList>:
{
if (!_pNames)
{
- _pNames = new NameVec;
+ _pNames = NameVecPtr(new NameVec);
_pNames->push_back(n0);
}
}
View
4 Foundation/include/Poco/ObjectPool.h
@@ -144,7 +144,7 @@ class PoolableObjectFactory <C, Poco::SharedPtr<C> >
public:
Poco::SharedPtr<C> createObject()
{
- return new C;
+ return Poco::SharedPtr<C>(new C);
}
bool validateObject(Poco::SharedPtr<C> pObject)
@@ -244,7 +244,7 @@ class ObjectPool
_size++;
return pObject;
}
- else return 0;
+ else return P();
}
void returnObject(P pObject)
View
52 Foundation/include/Poco/SharedPtr.h
@@ -139,7 +139,7 @@ class SharedPtr
{
}
- SharedPtr(C* ptr): _pCounter(new RC), _ptr(ptr)
+ explicit SharedPtr(C* ptr): _pCounter(new RC), _ptr(ptr)
{
}
@@ -192,11 +192,6 @@ class SharedPtr
return *this;
}
- SharedPtr& operator = (C* ptr)
- {
- return assign(ptr);
- }
-
SharedPtr& operator = (const SharedPtr& ptr)
{
return assign(ptr);
@@ -270,15 +265,14 @@ class SharedPtr
{
return _ptr;
}
-
- operator C* ()
- {
- return _ptr;
- }
- operator const C* () const
+ //Don't allow implicit conversion to ptr, but allow SharedPtr
+ //to be used in conditional contexts
+ typedef C * SharedPtr::*unspecified_bool_type;
+
+ operator unspecified_bool_type() const
{
- return _ptr;
+ return _ptr == 0 ? 0: &SharedPtr::_ptr;
}
bool operator ! () const
@@ -301,11 +295,6 @@ class SharedPtr
return get() == ptr;
}
- bool operator == (C* ptr) const
- {
- return get() == ptr;
- }
-
bool operator != (const SharedPtr& ptr) const
{
return get() != ptr.get();
@@ -315,12 +304,7 @@ class SharedPtr
{
return get() != ptr;
}
-
- bool operator != (C* ptr) const
- {
- return get() != ptr;
- }
-
+
bool operator < (const SharedPtr& ptr) const
{
return get() < ptr.get();
@@ -331,11 +315,6 @@ class SharedPtr
return get() < ptr;
}
- bool operator < (C* ptr) const
- {
- return get() < ptr;
- }
-
bool operator <= (const SharedPtr& ptr) const
{
return get() <= ptr.get();
@@ -346,11 +325,6 @@ class SharedPtr
return get() <= ptr;
}
- bool operator <= (C* ptr) const
- {
- return get() <= ptr;
- }
-
bool operator > (const SharedPtr& ptr) const
{
return get() > ptr.get();
@@ -361,11 +335,6 @@ class SharedPtr
return get() > ptr;
}
- bool operator > (C* ptr) const
- {
- return get() > ptr;
- }
-
bool operator >= (const SharedPtr& ptr) const
{
return get() >= ptr.get();
@@ -375,11 +344,6 @@ class SharedPtr
{
return get() >= ptr;
}
-
- bool operator >= (C* ptr) const
- {
- return get() >= ptr;
- }
int referenceCount() const
{
View
2  Foundation/src/NotificationCenter.cpp
@@ -57,7 +57,7 @@ NotificationCenter::~NotificationCenter()
void NotificationCenter::addObserver(const AbstractObserver& observer)
{
Mutex::ScopedLock lock(_mutex);
- _observers.push_back(observer.clone());
+ _observers.push_back(SharedPtr<AbstractObserver>(observer.clone()));
}
View
20 Foundation/src/TextEncoding.cpp
@@ -68,16 +68,16 @@ class TextEncodingManager
TextEncoding::Ptr pUtf8Encoding(new UTF8Encoding);
add(pUtf8Encoding, TextEncoding::GLOBAL);
- add(new ASCIIEncoding);
- add(new Latin1Encoding);
- add(new Latin2Encoding);
- add(new Latin9Encoding);
+ add(SharedPtr<ASCIIEncoding>(new ASCIIEncoding));
+ add(SharedPtr<Latin1Encoding>(new Latin1Encoding));
+ add(SharedPtr<Latin2Encoding>(new Latin2Encoding));
+ add(SharedPtr<Latin9Encoding>(new Latin9Encoding));
add(pUtf8Encoding);
- add(new UTF16Encoding);
- add(new UTF32Encoding);
- add(new Windows1250Encoding);
- add(new Windows1251Encoding);
- add(new Windows1252Encoding);
+ add(SharedPtr<UTF16Encoding>(new UTF16Encoding));
+ add(SharedPtr<UTF32Encoding>(new UTF32Encoding));
+ add(SharedPtr<Windows1250Encoding>(new Windows1250Encoding));
+ add(SharedPtr<Windows1251Encoding>(new Windows1251Encoding));
+ add(SharedPtr<Windows1252Encoding>(new Windows1252Encoding));
}
~TextEncodingManager()
@@ -169,7 +169,7 @@ int TextEncoding::sequenceLength(const unsigned char* bytes, int length) const
TextEncoding& TextEncoding::byName(const std::string& encodingName)
{
- TextEncoding* pEncoding = manager().find(encodingName);
+ SharedPtr<TextEncoding> pEncoding = manager().find(encodingName);
if (pEncoding)
return *pEncoding;
else
View
22 Foundation/testsuite/src/SharedPtrTest.cpp
@@ -114,9 +114,9 @@ void SharedPtrTest::testSharedPtr()
pTO2 = pTmp;
}
assert (pTO1 < pTO2);
- ptr1 = pTO1;
+ ptr1 = SharedPtr<TestObject>(pTO1);
assert (ptr1.referenceCount() == 1);
- SharedPtr<TestObject> ptr2 = pTO2;
+ SharedPtr<TestObject> ptr2 = SharedPtr<TestObject>(pTO2);
SharedPtr<TestObject> ptr3 = ptr1;
assert (ptr1.referenceCount() == 2);
SharedPtr<TestObject> ptr4;
@@ -166,14 +166,14 @@ void SharedPtrTest::testSharedPtr()
assert (!(ptr4 != ptr2));
assert (TestObject::count() == 2);
- ptr1 = 0;
- ptr2 = 0;
- ptr3 = 0;
- ptr4 = 0;
+ ptr1 = SharedPtr<TestObject>();
+ ptr2 = SharedPtr<TestObject>();
+ ptr3 = SharedPtr<TestObject>();
+ ptr4 = SharedPtr<TestObject>();
assert (TestObject::count() == 0);
{
- SharedPtr<TestObject> ptr = new TestObject("");
+ SharedPtr<TestObject> ptr(new TestObject(""));
assert (TestObject::count() == 1);
}
assert (TestObject::count() == 0);
@@ -195,21 +195,21 @@ void SharedPtrTest::testImplicitCast()
assert (TestObject::count() == 1);
}
assert (TestObject::count() == 0);
- SharedPtr<TestObject> ptr1 = new DerivedObject("test", 666);
+ SharedPtr<TestObject> ptr1(new DerivedObject("test", 666));
assert (TestObject::count() == 1);
- ptr1 = 0;
+ ptr1 = SharedPtr<TestObject>();
assert (TestObject::count() == 0);
}
void SharedPtrTest::testExplicitCast()
{
- SharedPtr<TestObject> ptr1 = new DerivedObject("test", 666);
+ SharedPtr<TestObject> ptr1(new DerivedObject("test", 666));
SharedPtr<DerivedObject> ptr2 = ptr1.cast<DerivedObject>();
assert (ptr2.get() != 0);
// cast the other way round must fail
- ptr1 = new TestObject("test");
+ ptr1 = SharedPtr<TestObject>(new TestObject("test"));
assert (TestObject::count() == 2);
ptr2 = ptr1.cast<DerivedObject>();
assert (TestObject::count() == 1);
View
14 Foundation/testsuite/src/TextEncodingTest.cpp
@@ -83,31 +83,31 @@ void TextEncodingTest::testTextEncoding()
TextEncoding& glob = TextEncoding::global();
assert (std::string("UTF-8") == glob.canonicalName());
- TextEncoding::global(new Latin1Encoding);
+ TextEncoding::global(Latin1Encoding::Ptr(new Latin1Encoding));
TextEncoding& glob2 = TextEncoding::global();
assert (std::string("ISO-8859-1") == glob2.canonicalName());
- TextEncoding::global(new Latin2Encoding);
+ TextEncoding::global(Latin2Encoding::Ptr(new Latin2Encoding));
TextEncoding& glob3 = TextEncoding::global();
assert (std::string("ISO-8859-2") == glob3.canonicalName());
- TextEncoding::global(new Latin9Encoding);
+ TextEncoding::global(Latin9Encoding::Ptr(new Latin9Encoding));
TextEncoding& glob4 = TextEncoding::global();
assert (std::string("ISO-8859-15") == glob4.canonicalName());
- TextEncoding::global(new Windows1250Encoding);
+ TextEncoding::global(Windows1250Encoding::Ptr(new Windows1250Encoding));
TextEncoding& glob5 = TextEncoding::global();
assert (std::string("Windows-1250") == glob5.canonicalName());
- TextEncoding::global(new Windows1251Encoding);
+ TextEncoding::global(Windows1251Encoding::Ptr(new Windows1251Encoding));
TextEncoding& glob6 = TextEncoding::global();
assert (std::string("Windows-1251") == glob6.canonicalName());
- TextEncoding::global(new Windows1252Encoding);
+ TextEncoding::global(Windows1252Encoding::Ptr(new Windows1252Encoding));
TextEncoding& glob7 = TextEncoding::global();
assert (std::string("Windows-1252") == glob7.canonicalName());
- TextEncoding::global(new UTF8Encoding);
+ TextEncoding::global(UTF8Encoding::Ptr(new UTF8Encoding));
TextEncoding& glob8 = TextEncoding::global();
assert (std::string("UTF-8") == glob8.canonicalName());
}
View
2  JSON/include/Poco/JSON/Parser.h
@@ -59,7 +59,7 @@ class JSON_API Parser
{
public:
- Parser(const Handler::Ptr& pHandler = new ParseHandler);
+ Parser(const Handler::Ptr& pHandler = SharedPtr<Handler>(new ParseHandler));
/// Constructor.
virtual ~Parser();
View
6 JSON/include/Poco/JSON/Template.h
@@ -142,9 +142,9 @@ class JSON_API Template
std::string readString(std::istream& in);
void readWhiteSpace(std::istream& in);
- MultiPart* _parts;
- std::stack<MultiPart*> _partStack;
- MultiPart* _currentPart;
+ SharedPtr<MultiPart> _parts;
+ std::stack<SharedPtr<MultiPart> > _partStack;
+ SharedPtr<MultiPart> _currentPart;
Path _templatePath;
Timestamp _parseTime;
};
View
4 JSON/src/ParseHandler.cpp
@@ -58,7 +58,7 @@ ParseHandler::~ParseHandler()
void ParseHandler::startObject()
{
- Object::Ptr newObj = new Object(_preserveObjectOrder);
+ Object::Ptr newObj(new Object(_preserveObjectOrder));
if ( _stack.empty() ) // The first object
{
@@ -94,7 +94,7 @@ void ParseHandler::endObject()
void ParseHandler::startArray()
{
- Array::Ptr newArr = new Array();
+ Array::Ptr newArr(new Array());
if ( _stack.empty() ) // The first array
{
View
58 JSON/src/Template.cpp
@@ -114,7 +114,7 @@ class MultiPart: public Part
{
}
- virtual void addPart(Part* part)
+ virtual void addPart(const SharedPtr<Part>& part)
{
_parts.push_back(part);
}
@@ -253,16 +253,16 @@ class LogicPart : public MultiPart
{
}
- void addPart(LogicQuery* query, Part* part)
+ void addPart(const SharedPtr<LogicQuery>& query, const SharedPtr<Part>& part)
{
MultiPart::addPart(part);
_queries.push_back(query);
}
- void addPart(Part* part)
+ void addPart(const SharedPtr<Part>& part)
{
MultiPart::addPart(part);
- _queries.push_back(new LogicElseQuery());
+ _queries.push_back(SharedPtr<LogicElseQuery>(new LogicElseQuery()));
}
void render(const Var& data, std::ostream& out) const
@@ -370,24 +370,18 @@ class IncludePart: public Part
Template::Template(const Path& templatePath)
- : _parts(NULL)
- , _templatePath(templatePath)
+ : _templatePath(templatePath)
{
}
Template::Template()
- : _parts(NULL)
{
}
Template::~Template()
{
- if ( _parts != NULL )
- {
- delete _parts;
- }
}
@@ -406,7 +400,7 @@ void Template::parse(std::istream& in)
{
_parseTime.update();
- _parts = new MultiPart();
+ _parts = SharedPtr<MultiPart>(new MultiPart());
_currentPart = _parts;
while(in.good())
@@ -414,7 +408,7 @@ void Template::parse(std::istream& in)
std::string text = readText(in); // Try to read text first
if ( text.length() > 0 )
{
- _currentPart->addPart(new StringPart(text));
+ _currentPart->addPart(SharedPtr<StringPart>(new StringPart(text)));
}
if ( in.bad() )
@@ -435,7 +429,7 @@ void Template::parse(std::istream& in)
{
throw JSONTemplateException("Missing query in <? echo ?>");
}
- _currentPart->addPart(new EchoPart(query));
+ _currentPart->addPart(SharedPtr<EchoPart>(new EchoPart(query)));
}
else if ( command.compare("for") == 0 )
{
@@ -453,7 +447,7 @@ void Template::parse(std::istream& in)
}
_partStack.push(_currentPart);
- LoopPart* part = new LoopPart(loopVariable, query);
+ SharedPtr<LoopPart> part(new LoopPart(loopVariable, query));
_partStack.push(part);
_currentPart->addPart(part);
_currentPart = part;
@@ -465,12 +459,12 @@ void Template::parse(std::istream& in)
throw JSONTemplateException("Unexpected <? else ?> found");
}
_currentPart = _partStack.top();
- LogicPart* lp = dynamic_cast<LogicPart*>(_currentPart);
- if ( lp == NULL )
+ SharedPtr<LogicPart> lp = _currentPart.cast<LogicPart>();
+ if ( !lp )
{
throw JSONTemplateException("Missing <? if ?> or <? ifexist ?> for <? else ?>");
}
- MultiPart* part = new MultiPart();
+ SharedPtr<MultiPart> part(new MultiPart());
lp->addPart(part);
_currentPart = part;
}
@@ -489,13 +483,13 @@ void Template::parse(std::istream& in)
}
_currentPart = _partStack.top();
- LogicPart* lp = dynamic_cast<LogicPart*>(_currentPart);
- if ( lp == NULL )
+ SharedPtr<LogicPart> lp = _currentPart.cast<LogicPart>();
+ if ( lp )
{
throw JSONTemplateException("Missing <? if ?> or <? ifexist ?> for <? elsif / elif ?>");
}
- MultiPart* part = new MultiPart();
- lp->addPart(new LogicQuery(query), part);
+ SharedPtr<MultiPart> part(new MultiPart());
+ lp->addPart(SharedPtr<LogicQuery>(new LogicQuery(query)), part);
_currentPart = part;
}
else if ( command.compare("endfor") == 0 )
@@ -504,9 +498,9 @@ void Template::parse(std::istream& in)
{
throw JSONTemplateException("Unexpected <? endfor ?> found");
}
- MultiPart* loopPart = _partStack.top();
- LoopPart* lp = dynamic_cast<LoopPart*>(loopPart);
- if ( lp == NULL )
+ SharedPtr<MultiPart> loopPart = _partStack.top();
+ SharedPtr<LoopPart> lp = loopPart.cast<LoopPart>();
+ if ( !lp )
{
throw JSONTemplateException("Missing <? for ?> command");
}
@@ -522,8 +516,8 @@ void Template::parse(std::istream& in)
}
_currentPart = _partStack.top();
- LogicPart* lp = dynamic_cast<LogicPart*>(_currentPart);
- if ( lp == NULL )
+ SharedPtr<LogicPart> lp = _currentPart.cast<LogicPart>();
+ if ( !lp )
{
throw JSONTemplateException("Missing <? if ?> or <? ifexist ?> for <? endif ?>");
}
@@ -541,17 +535,17 @@ void Template::parse(std::istream& in)
throw JSONTemplateException("Missing query in <? " + command + " ?>");
}
_partStack.push(_currentPart);
- LogicPart* lp = new LogicPart();
+ SharedPtr<LogicPart> lp(new LogicPart());
_partStack.push(lp);
_currentPart->addPart(lp);
- _currentPart = new MultiPart();
+ _currentPart = SharedPtr<MultiPart>(new MultiPart());
if ( command.compare("ifexist") == 0 )
{
- lp->addPart(new LogicExistQuery(query), _currentPart);
+ lp->addPart(SharedPtr<LogicExistQuery>(new LogicExistQuery(query)), _currentPart);
}
else
{
- lp->addPart(new LogicQuery(query), _currentPart);
+ lp->addPart(SharedPtr<LogicQuery>(new LogicQuery(query)), _currentPart);
}
}
else if ( command.compare("include") == 0 )
@@ -566,7 +560,7 @@ void Template::parse(std::istream& in)
{
Path resolvePath(_templatePath);
resolvePath.makeParent();
- _currentPart->addPart(new IncludePart(resolvePath, filename));
+ _currentPart->addPart(SharedPtr<IncludePart>(new IncludePart(resolvePath, filename)));
}
}
else
View
4 JSON/src/TemplateCache.cpp
@@ -89,7 +89,7 @@ Template::Ptr TemplateCache::getTemplate(const Path& path)
poco_information_f1(*_logger, "Loading template %s", templatePath.toString());
}
- tpl = new Template(templatePath);
+ tpl = SharedPtr<Template>(new Template(templatePath));
try
{
@@ -123,7 +123,7 @@ Template::Ptr TemplateCache::getTemplate(const Path& path)
poco_information_f1(*_logger, "Reloading template %s", templatePath.toString());
}
- tpl = new Template(templatePath);
+ tpl = SharedPtr<Template>(new Template(templatePath));
try
{
View
8 JSON/testsuite/src/JSONTest.cpp
@@ -834,7 +834,7 @@ void JSONTest::testPrintHandler()
std::string json = "{ \"name\" : \"Homer\", \"age\" : 38, \"wife\" : \"Marge\", \"age\" : 36, \"children\" : [ \"Bart\", \"Lisa\", \"Maggie\" ] }";
Parser parser;
std::ostringstream ostr;
- PrintHandler::Ptr pHandler = new PrintHandler(ostr);
+ PrintHandler::Ptr pHandler(new PrintHandler(ostr));
parser.setHandler(pHandler);
parser.parse(json);
assert (ostr.str() == "{\"name\":\"Homer\",\"age\":38,\"wife\":\"Marge\",\"age\":36,\"children\":[\"Bart\",\"Lisa\",\"Maggie\"]}");
@@ -1021,7 +1021,7 @@ void JSONTest::testStringifyPreserveOrder()
"\"children\" : [ \"Bart\", \"Lisa\", \"Maggie\" ], "
"\"address\" : { \"number\" : 742, \"street\" : \"Evergreen Terrace\", \"town\" : \"Springfield\" } } }";
- ParseHandler::Ptr pHandler = new ParseHandler(true);
+ ParseHandler::Ptr pHandler(new ParseHandler(true));
Parser parser(pHandler);
Var result;
@@ -1262,8 +1262,8 @@ void JSONTest::testTemplate()
Template tpl;
tpl.parse("Hello world! From <?= person.name?>.\n<?if person.tooOld?>You're too old.<?endif?>");
- Object::Ptr data = new Object();
- Object::Ptr person = new Object();
+ Object::Ptr data(new Object());
+ Object::Ptr person(new Object());
data->set("person", person);
person->set("name", "Franky");
person->set("tooOld", true);
View
8 MongoDB/include/Poco/MongoDB/Database.h
@@ -124,28 +124,28 @@ inline Poco::SharedPtr<Poco::MongoDB::QueryRequest> Database::createCommand() co
inline Poco::SharedPtr<Poco::MongoDB::DeleteRequest>
Database::createDeleteRequest(const std::string& collectionName) const
{
- return new Poco::MongoDB::DeleteRequest(_dbname + '.' + collectionName);
+ return Poco::SharedPtr<Poco::MongoDB::DeleteRequest>(new Poco::MongoDB::DeleteRequest(_dbname + '.' + collectionName));
}
inline Poco::SharedPtr<Poco::MongoDB::InsertRequest>
Database::createInsertRequest(const std::string& collectionName) const
{
- return new Poco::MongoDB::InsertRequest(_dbname + '.' + collectionName);
+ return Poco::SharedPtr<Poco::MongoDB::InsertRequest>(new Poco::MongoDB::InsertRequest(_dbname + '.' + collectionName));
}
inline Poco::SharedPtr<Poco::MongoDB::QueryRequest>
Database::createQueryRequest(const std::string& collectionName) const
{
- return new Poco::MongoDB::QueryRequest(_dbname + '.' + collectionName);
+ return Poco::SharedPtr<Poco::MongoDB::QueryRequest>(new Poco::MongoDB::QueryRequest(_dbname + '.' + collectionName));
}
inline Poco::SharedPtr<Poco::MongoDB::UpdateRequest>
Database::createUpdateRequest(const std::string& collectionName) const
{
- return new Poco::MongoDB::UpdateRequest(_dbname + '.' + collectionName);
+ return Poco::SharedPtr<Poco::MongoDB::UpdateRequest>(new Poco::MongoDB::UpdateRequest(_dbname + '.' + collectionName));
}
} } // namespace Poco::MongoDB
View
6 MongoDB/include/Poco/MongoDB/Document.h
@@ -91,7 +91,7 @@ class MongoDB_API Document
// adds it to the document.
/// The active document is returned to allow chaining of the add methods.
{
- return addElement(new ConcreteElement<T>(name, value));
+ return addElement(typename ConcreteElement<T>::Ptr(new ConcreteElement<T>(name, value)));
}
Document& add(const std::string& name, const char* value)
@@ -99,7 +99,7 @@ class MongoDB_API Document
// adds it to the document.
/// The active document is returned to allow chaining of the add methods.
{
- return addElement(new ConcreteElement<std::string>(name, std::string(value)));
+ return addElement(ConcreteElement<std::string>::Ptr(new ConcreteElement<std::string>(name, std::string(value))));
}
Document& addNewDocument(const std::string& name);
@@ -212,7 +212,7 @@ inline Document& Document::addElement(Element::Ptr element)
inline Document& Document::addNewDocument(const std::string& name)
{
- Document::Ptr newDoc = new Document();
+ Document::Ptr newDoc(new Document());
add(name, newDoc);
return *newDoc;
}
View
2  MongoDB/include/Poco/MongoDB/InsertRequest.h
@@ -92,7 +92,7 @@ class MongoDB_API InsertRequest : public RequestMessage
inline Document& InsertRequest::addNewDocument()
{
- Document::Ptr doc = new Document();
+ Document::Ptr doc(new Document());
_documents.push_back(doc);
return *doc;
}
View
2  MongoDB/include/Poco/MongoDB/JavaScriptCode.h
@@ -104,7 +104,7 @@ inline void BSONReader::read<JavaScriptCode::Ptr>(JavaScriptCode::Ptr& to)
{
std::string code;
BSONReader(_reader).read(code);
- to = new JavaScriptCode();
+ to = JavaScriptCode::Ptr(new JavaScriptCode());
to->setCode(code);
}
View
2  MongoDB/include/Poco/MongoDB/PoolableConnectionFactory.h
@@ -65,7 +65,7 @@ class PoolableObjectFactory<MongoDB::Connection, MongoDB::Connection::Ptr>
MongoDB::Connection::Ptr createObject()
{
- return new MongoDB::Connection(_address);
+ return MongoDB::Connection::Ptr(new MongoDB::Connection(_address));
}
bool validateObject(MongoDB::Connection::Ptr pObject)
View
2  MongoDB/include/Poco/MongoDB/RegularExpression.h
@@ -130,7 +130,7 @@ inline void BSONReader::read<RegularExpression::Ptr>(RegularExpression::Ptr& to)
std::string pattern = readCString();
std::string options = readCString();
- to = new RegularExpression(pattern, options);
+ to = RegularExpression::Ptr(new RegularExpression(pattern, options));
}
View
2  MongoDB/src/Database.cpp
@@ -71,7 +71,7 @@ double Database::count(Connection& connection, const std::string& collectionName
Poco::MongoDB::Document::Ptr Database::ensureIndex(Connection& connection, const std::string& collection, const std::string& indexName, Poco::MongoDB::Document::Ptr keys, bool unique, bool background, int version, int ttl)
{
- Poco::MongoDB::Document::Ptr index = new Poco::MongoDB::Document();
+ Poco::MongoDB::Document::Ptr index(new Poco::MongoDB::Document());
index->add("ns", _dbname + ".players");
index->add("name", indexName);
index->add("key", keys);
View
26 MongoDB/src/Document.cpp
@@ -90,43 +90,43 @@ void Document::read(BinaryReader& reader)
switch(type)
{
case ElementTraits<double>::TypeId:
- element = new ConcreteElement<double>(name, 0);
+ element = SharedPtr<ConcreteElement<double> >(new ConcreteElement<double>(name, 0));
break;
case ElementTraits<Int32>::TypeId:
- element = new ConcreteElement<Int32>(name, 0);
+ element = SharedPtr<ConcreteElement<Int32> >(new ConcreteElement<Int32>(name, 0));
break;
case ElementTraits<std::string>::TypeId:
- element = new ConcreteElement<std::string>(name, "");
+ element = SharedPtr<ConcreteElement<std::string> >(new ConcreteElement<std::string>(name, ""));
break;
case ElementTraits<Document::Ptr>::TypeId:
- element = new ConcreteElement<Document::Ptr>(name, new Document());
+ element = SharedPtr<ConcreteElement<Document::Ptr> >(new ConcreteElement<Document::Ptr>(name, Document::Ptr(new Document())));
break;
case ElementTraits<Array::Ptr>::TypeId:
- element = new ConcreteElement<Array::Ptr>(name, new Array());
+ element = SharedPtr<ConcreteElement<Array::Ptr> >(new ConcreteElement<Array::Ptr>(name, Array::Ptr(new Array())));
break;
case ElementTraits<Binary::Ptr>::TypeId:
- element = new ConcreteElement<Binary::Ptr>(name, new Binary());
+ element = SharedPtr<ConcreteElement<Binary::Ptr> >(new ConcreteElement<Binary::Ptr>(name, Binary::Ptr(new Binary())));
break;
case ElementTraits<ObjectId::Ptr>::TypeId:
- element = new ConcreteElement<ObjectId::Ptr>(name, new ObjectId());
+ element = SharedPtr<ConcreteElement<ObjectId::Ptr> >(new ConcreteElement<ObjectId::Ptr>(name, ObjectId::Ptr(new ObjectId())));
break;
case ElementTraits<bool>::TypeId:
- element = new ConcreteElement<bool>(name, false);
+ element = SharedPtr<ConcreteElement<bool> >(new ConcreteElement<bool>(name, false));
break;
case ElementTraits<Poco::Timestamp>::TypeId:
- element = new ConcreteElement<Poco::Timestamp>(name, Poco::Timestamp());
+ element = SharedPtr<ConcreteElement<Poco::Timestamp> >(new ConcreteElement<Poco::Timestamp>(name, Poco::Timestamp()));
break;
case ElementTraits<NullValue>::TypeId:
- element = new ConcreteElement<NullValue>(name, NullValue(0));
+ element = SharedPtr<ConcreteElement<NullValue> >(new ConcreteElement<NullValue>(name, NullValue(0)));
break;
case ElementTraits<RegularExpression::Ptr>::TypeId:
- element = new ConcreteElement<RegularExpression::Ptr>(name, new RegularExpression());
+ element = SharedPtr<ConcreteElement<RegularExpression::Ptr> >(new ConcreteElement<RegularExpression::Ptr>(name, RegularExpression::Ptr(new RegularExpression())));
break;
case ElementTraits<JavaScriptCode::Ptr>::TypeId:
- element = new ConcreteElement<JavaScriptCode::Ptr>(name, new JavaScriptCode());
+ element = SharedPtr<ConcreteElement<JavaScriptCode::Ptr> >(new ConcreteElement<JavaScriptCode::Ptr>(name, JavaScriptCode::Ptr(new JavaScriptCode())));
break;
case ElementTraits<Int64>::TypeId:
- element = new ConcreteElement<Int64>(name, 0);
+ element = SharedPtr<ConcreteElement<Int64> >(new ConcreteElement<Int64>(name, 0));
break;
default:
{
View
2