[App] Use std::shared_ptr instead of boost::shared_ptr
There's no need to use boost version when stl has support for shared_ptr
This commit is contained in:
@@ -682,7 +682,7 @@ bool DocumentObject::removeDynamicProperty(const char* name)
|
||||
}
|
||||
|
||||
for (auto it : removeExpr) {
|
||||
ExpressionEngine.setValue(it, boost::shared_ptr<Expression>());
|
||||
ExpressionEngine.setValue(it, std::shared_ptr<Expression>());
|
||||
}
|
||||
|
||||
return TransactionalObject::removeDynamicProperty(name);
|
||||
@@ -912,7 +912,7 @@ void DocumentObject::Save (Base::Writer &writer) const
|
||||
* @param expr Expression tree
|
||||
*/
|
||||
|
||||
void DocumentObject::setExpression(const ObjectIdentifier &path, boost::shared_ptr<Expression> expr)
|
||||
void DocumentObject::setExpression(const ObjectIdentifier &path, std::shared_ptr<Expression> expr)
|
||||
{
|
||||
ExpressionEngine.setValue(path, expr);
|
||||
}
|
||||
|
||||
@@ -422,7 +422,7 @@ public:
|
||||
|
||||
/* Expression support */
|
||||
|
||||
virtual void setExpression(const ObjectIdentifier & path, boost::shared_ptr<App::Expression> expr);
|
||||
virtual void setExpression(const ObjectIdentifier & path, std::shared_ptr<App::Expression> expr);
|
||||
|
||||
virtual const PropertyExpressionEngine::ExpressionInfo getExpression(const ObjectIdentifier &path) const;
|
||||
|
||||
|
||||
@@ -329,7 +329,7 @@ PyObject* DocumentObjectPy::setExpression(PyObject * args)
|
||||
App::ObjectIdentifier p(ObjectIdentifier::parse(getDocumentObjectPtr(), path));
|
||||
|
||||
if (Py::Object(expr).isNone())
|
||||
getDocumentObjectPtr()->setExpression(p, boost::shared_ptr<Expression>());
|
||||
getDocumentObjectPtr()->setExpression(p, std::shared_ptr<Expression>());
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
else if (PyUnicode_Check(expr)) {
|
||||
const char * exprStr = PyUnicode_AsUTF8(expr);
|
||||
@@ -337,7 +337,7 @@ PyObject* DocumentObjectPy::setExpression(PyObject * args)
|
||||
else if (PyString_Check(expr)) {
|
||||
const char * exprStr = PyString_AsString(expr);
|
||||
#endif
|
||||
boost::shared_ptr<Expression> shared_expr(Expression::parse(getDocumentObjectPtr(), exprStr));
|
||||
std::shared_ptr<Expression> shared_expr(Expression::parse(getDocumentObjectPtr(), exprStr));
|
||||
if(shared_expr && comment)
|
||||
shared_expr->comment = comment;
|
||||
|
||||
@@ -351,7 +351,7 @@ PyObject* DocumentObjectPy::setExpression(PyObject * args)
|
||||
if (unicode) {
|
||||
std::string exprStr = PyString_AsString(unicode);
|
||||
Py_DECREF(unicode);
|
||||
boost::shared_ptr<Expression> shared_expr(ExpressionParser::parse(getDocumentObjectPtr(), exprStr.c_str()));
|
||||
std::shared_ptr<Expression> shared_expr(ExpressionParser::parse(getDocumentObjectPtr(), exprStr.c_str()));
|
||||
|
||||
if(shared_expr && comment)
|
||||
shared_expr->comment = comment;
|
||||
@@ -375,7 +375,7 @@ PyObject* DocumentObjectPy::evalExpression(PyObject * args)
|
||||
return NULL; // NULL triggers exception
|
||||
|
||||
PY_TRY {
|
||||
boost::shared_ptr<Expression> shared_expr(Expression::parse(getDocumentObjectPtr(), expr));
|
||||
std::shared_ptr<Expression> shared_expr(Expression::parse(getDocumentObjectPtr(), expr));
|
||||
if(shared_expr)
|
||||
return Py::new_reference_to(shared_expr->getPyValue());
|
||||
Py_Return;
|
||||
|
||||
@@ -110,7 +110,7 @@ Property *PropertyExpressionEngine::Copy() const
|
||||
PropertyExpressionEngine * engine = new PropertyExpressionEngine();
|
||||
|
||||
for (ExpressionMap::const_iterator it = expressions.begin(); it != expressions.end(); ++it)
|
||||
engine->expressions[it->first] = ExpressionInfo(boost::shared_ptr<Expression>(it->second.expression->copy()));
|
||||
engine->expressions[it->first] = ExpressionInfo(std::shared_ptr<Expression>(it->second.expression->copy()));
|
||||
|
||||
engine->validator = validator;
|
||||
|
||||
@@ -153,7 +153,7 @@ void PropertyExpressionEngine::Paste(const Property &from)
|
||||
expressions.clear();
|
||||
for(auto &e : fromee.expressions) {
|
||||
expressions[e.first] = ExpressionInfo(
|
||||
boost::shared_ptr<Expression>(e.second.expression->copy()));
|
||||
std::shared_ptr<Expression>(e.second.expression->copy()));
|
||||
expressionChanged(e.first);
|
||||
}
|
||||
validator = fromee.validator;
|
||||
@@ -218,7 +218,7 @@ void PropertyExpressionEngine::Restore(Base::XMLReader &reader)
|
||||
*/
|
||||
|
||||
void PropertyExpressionEngine::buildGraphStructures(const ObjectIdentifier & path,
|
||||
const boost::shared_ptr<Expression> expression,
|
||||
const std::shared_ptr<Expression> expression,
|
||||
boost::unordered_map<ObjectIdentifier, int> & nodes,
|
||||
boost::unordered_map<int, ObjectIdentifier> & revNodes,
|
||||
std::vector<Edge> & edges) const
|
||||
@@ -304,7 +304,7 @@ void PropertyExpressionEngine::afterRestore()
|
||||
|
||||
for(auto &info : *restoredExpressions) {
|
||||
ObjectIdentifier path = ObjectIdentifier::parse(docObj, info.path);
|
||||
boost::shared_ptr<Expression> expression(Expression::parse(docObj, info.expr.c_str()));
|
||||
std::shared_ptr<Expression> expression(Expression::parse(docObj, info.expr.c_str()));
|
||||
if(expression)
|
||||
expression->comment = std::move(info.comment);
|
||||
setValue(path, expression);
|
||||
@@ -351,7 +351,7 @@ const boost::any PropertyExpressionEngine::getPathValue(const App::ObjectIdentif
|
||||
* @param comment Optional comment.
|
||||
*/
|
||||
|
||||
void PropertyExpressionEngine::setValue(const ObjectIdentifier & path, boost::shared_ptr<Expression> expr)
|
||||
void PropertyExpressionEngine::setValue(const ObjectIdentifier & path, std::shared_ptr<Expression> expr)
|
||||
{
|
||||
ObjectIdentifier usePath(canonicalPath(path));
|
||||
const Property * prop = usePath.getProperty();
|
||||
@@ -623,7 +623,7 @@ bool PropertyExpressionEngine::depsAreTouched() const
|
||||
* @return Empty string on success, error message on failure.
|
||||
*/
|
||||
|
||||
std::string PropertyExpressionEngine::validateExpression(const ObjectIdentifier &path, boost::shared_ptr<const Expression> expr) const
|
||||
std::string PropertyExpressionEngine::validateExpression(const ObjectIdentifier &path, std::shared_ptr<const Expression> expr) const
|
||||
{
|
||||
std::string error;
|
||||
ObjectIdentifier usePath(canonicalPath(path));
|
||||
@@ -653,7 +653,7 @@ std::string PropertyExpressionEngine::validateExpression(const ObjectIdentifier
|
||||
ExpressionMap newExpressions = expressions;
|
||||
|
||||
// Add expression in question
|
||||
boost::shared_ptr<Expression> exprClone(expr->copy());
|
||||
std::shared_ptr<Expression> exprClone(expr->copy());
|
||||
newExpressions[usePath].expression = exprClone;
|
||||
|
||||
// Build graph; an exception will be thrown if it is not a DAG
|
||||
@@ -819,9 +819,9 @@ Property *PropertyExpressionEngine::CopyOnImportExternal(
|
||||
std::unique_ptr<PropertyExpressionEngine> engine;
|
||||
for(auto it=expressions.begin();it!=expressions.end();++it) {
|
||||
#ifdef BOOST_NO_CXX11_SMART_PTR
|
||||
boost::shared_ptr<Expression> expr(it->second.expression->importSubNames(nameMap).release());
|
||||
std::shared_ptr<Expression> expr(it->second.expression->importSubNames(nameMap).release());
|
||||
#else
|
||||
boost::shared_ptr<Expression> expr(it->second.expression->importSubNames(nameMap));
|
||||
std::shared_ptr<Expression> expr(it->second.expression->importSubNames(nameMap));
|
||||
#endif
|
||||
if(!expr && !engine)
|
||||
continue;
|
||||
@@ -829,7 +829,7 @@ Property *PropertyExpressionEngine::CopyOnImportExternal(
|
||||
engine.reset(new PropertyExpressionEngine);
|
||||
for(auto it2=expressions.begin();it2!=it;++it2) {
|
||||
engine->expressions[it2->first] = ExpressionInfo(
|
||||
boost::shared_ptr<Expression>(it2->second.expression->copy()));
|
||||
std::shared_ptr<Expression>(it2->second.expression->copy()));
|
||||
}
|
||||
}else if(!expr)
|
||||
expr = it->second.expression;
|
||||
@@ -847,9 +847,9 @@ Property *PropertyExpressionEngine::CopyOnLabelChange(App::DocumentObject *obj,
|
||||
std::unique_ptr<PropertyExpressionEngine> engine;
|
||||
for(auto it=expressions.begin();it!=expressions.end();++it) {
|
||||
#ifdef BOOST_NO_CXX11_SMART_PTR
|
||||
boost::shared_ptr<Expression> expr(it->second.expression->updateLabelReference(obj,ref,newLabel).release());
|
||||
std::shared_ptr<Expression> expr(it->second.expression->updateLabelReference(obj,ref,newLabel).release());
|
||||
#else
|
||||
boost::shared_ptr<Expression> expr(it->second.expression->updateLabelReference(obj,ref,newLabel));
|
||||
std::shared_ptr<Expression> expr(it->second.expression->updateLabelReference(obj,ref,newLabel));
|
||||
#endif
|
||||
if(!expr && !engine)
|
||||
continue;
|
||||
@@ -857,7 +857,7 @@ Property *PropertyExpressionEngine::CopyOnLabelChange(App::DocumentObject *obj,
|
||||
engine.reset(new PropertyExpressionEngine);
|
||||
for(auto it2=expressions.begin();it2!=it;++it2) {
|
||||
engine->expressions[it2->first] = ExpressionInfo(
|
||||
boost::shared_ptr<Expression>(it2->second.expression->copy()));
|
||||
std::shared_ptr<Expression>(it2->second.expression->copy()));
|
||||
}
|
||||
}else if(!expr)
|
||||
expr = it->second.expression;
|
||||
@@ -875,10 +875,10 @@ Property *PropertyExpressionEngine::CopyOnLinkReplace(const App::DocumentObject
|
||||
std::unique_ptr<PropertyExpressionEngine> engine;
|
||||
for(auto it=expressions.begin();it!=expressions.end();++it) {
|
||||
#ifdef BOOST_NO_CXX11_SMART_PTR
|
||||
boost::shared_ptr<Expression> expr(
|
||||
std::shared_ptr<Expression> expr(
|
||||
it->second.expression->replaceObject(parent,oldObj,newObj).release());
|
||||
#else
|
||||
boost::shared_ptr<Expression> expr(
|
||||
std::shared_ptr<Expression> expr(
|
||||
it->second.expression->replaceObject(parent,oldObj,newObj));
|
||||
#endif
|
||||
if(!expr && !engine)
|
||||
@@ -887,7 +887,7 @@ Property *PropertyExpressionEngine::CopyOnLinkReplace(const App::DocumentObject
|
||||
engine.reset(new PropertyExpressionEngine);
|
||||
for(auto it2=expressions.begin();it2!=it;++it2) {
|
||||
engine->expressions[it2->first] = ExpressionInfo(
|
||||
boost::shared_ptr<Expression>(it2->second.expression->copy()));
|
||||
std::shared_ptr<Expression>(it2->second.expression->copy()));
|
||||
}
|
||||
}else if(!expr)
|
||||
expr = it->second.expression;
|
||||
@@ -914,7 +914,7 @@ void PropertyExpressionEngine::setExpressions(
|
||||
AtomicPropertyChange signaller(*this);
|
||||
#ifdef BOOST_NO_CXX11_SMART_PTR
|
||||
for(auto &v : exprs)
|
||||
setValue(v.first,boost::shared_ptr<Expression>(v.second.release()));
|
||||
setValue(v.first,std::shared_ptr<Expression>(v.second.release()));
|
||||
#else
|
||||
for(auto &v : exprs)
|
||||
setValue(v.first,std::move(v.second));
|
||||
|
||||
@@ -77,16 +77,16 @@ public:
|
||||
virtual Property *CopyOnLinkReplace(const App::DocumentObject *parent,
|
||||
App::DocumentObject *oldObj, App::DocumentObject *newObj) const override;
|
||||
|
||||
typedef boost::function<std::string (const App::ObjectIdentifier & path, boost::shared_ptr<const App::Expression> expr)> ValidatorFunc;
|
||||
typedef boost::function<std::string (const App::ObjectIdentifier & path, std::shared_ptr<const App::Expression> expr)> ValidatorFunc;
|
||||
|
||||
/**
|
||||
* @brief The ExpressionInfo struct encapsulates an expression and a comment.
|
||||
*/
|
||||
|
||||
struct ExpressionInfo {
|
||||
boost::shared_ptr<App::Expression> expression; /**< The actual expression tree */
|
||||
std::shared_ptr<App::Expression> expression; /**< The actual expression tree */
|
||||
|
||||
ExpressionInfo(boost::shared_ptr<App::Expression> expression = boost::shared_ptr<App::Expression>()) {
|
||||
ExpressionInfo(std::shared_ptr<App::Expression> expression = std::shared_ptr<App::Expression>()) {
|
||||
this->expression = expression;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ public:
|
||||
|
||||
void Restore(Base::XMLReader &reader) override;
|
||||
|
||||
void setValue(const App::ObjectIdentifier &path, boost::shared_ptr<App::Expression> expr);
|
||||
void setValue(const App::ObjectIdentifier &path, std::shared_ptr<App::Expression> expr);
|
||||
|
||||
const boost::any getPathValue(const App::ObjectIdentifier & path) const override;
|
||||
|
||||
@@ -147,7 +147,7 @@ public:
|
||||
/* Expression validator */
|
||||
void setValidator(ValidatorFunc f) { validator = f; }
|
||||
|
||||
std::string validateExpression(const App::ObjectIdentifier & path, boost::shared_ptr<const App::Expression> expr) const;
|
||||
std::string validateExpression(const App::ObjectIdentifier & path, std::shared_ptr<const App::Expression> expr) const;
|
||||
|
||||
void renameExpressions(const std::map<App::ObjectIdentifier, App::ObjectIdentifier> &paths);
|
||||
|
||||
@@ -179,7 +179,7 @@ private:
|
||||
std::vector<App::ObjectIdentifier> computeEvaluationOrder(ExecuteOption option);
|
||||
|
||||
void buildGraphStructures(const App::ObjectIdentifier &path,
|
||||
const boost::shared_ptr<Expression> expression, boost::unordered_map<App::ObjectIdentifier, int> &nodes,
|
||||
const std::shared_ptr<Expression> expression, boost::unordered_map<App::ObjectIdentifier, int> &nodes,
|
||||
boost::unordered_map<int, App::ObjectIdentifier> &revNodes, std::vector<Edge> &edges) const;
|
||||
|
||||
void buildGraph(const ExpressionMap &exprs,
|
||||
|
||||
Reference in New Issue
Block a user