App: modernize C++: replace 'typedef' with 'using'

This commit is contained in:
wmayer
2022-08-29 12:58:39 +02:00
parent d2168f51b9
commit 5240a30431
33 changed files with 86 additions and 85 deletions

View File

@@ -33,8 +33,8 @@
#include <Base/Parameter.h>
// forward declarations
typedef struct _object PyObject;
typedef struct PyMethodDef PyMethodDef;
using PyObject = struct _object;
using PyMethodDef = struct PyMethodDef;
namespace Base
{

View File

@@ -38,7 +38,7 @@ namespace App {
class Branding
{
public:
typedef QMap<std::string, std::string> XmlConfig;
using XmlConfig = QMap<std::string, std::string>;
Branding();
bool readFile(const QString& fn);

View File

@@ -39,7 +39,7 @@ namespace Base
class Placement;
class Rotation;
template <class _Precision> class BoundBox3;
typedef BoundBox3<double> BoundBox3d;
using BoundBox3d = BoundBox3<double>;
}
namespace Data

View File

@@ -133,7 +133,7 @@ using namespace zipios;
namespace fs = boost::filesystem;
// typedef boost::property<boost::vertex_root_t, DocumentObject* > VertexProperty;
// using VertexProperty = boost::property<boost::vertex_root_t, DocumentObject* >;
using DependencyList = boost::adjacency_list <
boost::vecS, // class OutEdgeListS : a Sequence or an AssociativeContainer
boost::vecS, // class VertexListS : a Sequence or a RandomAccessContainer
@@ -307,16 +307,16 @@ void Document::writeDependencyGraphViz(std::ostream &out)
void Document::exportGraphviz(std::ostream& out) const
{
/* Typedefs for a graph with graphviz attributes */
typedef std::map<std::string, std::string> GraphvizAttributes;
typedef boost::subgraph< adjacency_list<vecS, vecS, directedS,
property<vertex_attribute_t, GraphvizAttributes>,
property<edge_index_t, int, property<edge_attribute_t, GraphvizAttributes> >,
property<graph_name_t, std::string,
property<graph_graph_attribute_t, GraphvizAttributes,
property<graph_vertex_attribute_t, GraphvizAttributes,
property<graph_edge_attribute_t, GraphvizAttributes>
> > > > > Graph;
/* Type defs for a graph with graphviz attributes */
using GraphvizAttributes = std::map<std::string, std::string>;
using Graph = boost::subgraph< adjacency_list<vecS, vecS, directedS,
property<vertex_attribute_t, GraphvizAttributes>,
property<edge_index_t, int, property<edge_attribute_t, GraphvizAttributes> >,
property<graph_name_t, std::string,
property<graph_graph_attribute_t, GraphvizAttributes,
property<graph_vertex_attribute_t, GraphvizAttributes,
property<graph_edge_attribute_t, GraphvizAttributes>
> > > > >;
/**
* @brief The GraphCreator class
@@ -774,7 +774,7 @@ void Document::exportGraphviz(std::ostream& out) const
}
typedef std::unordered_multimap<Vertex, Edge> EdgeMap;
using EdgeMap = std::unordered_multimap<Vertex, Edge>;
void removeEdges(EdgeMap & in_edges,
EdgeMap & out_edges,

View File

@@ -49,7 +49,7 @@ public:
PyObject *getPyObject() override;
};
typedef App::FeaturePythonT<DocumentObjectGroup> DocumentObjectGroupPython;
using DocumentObjectGroupPython = App::FeaturePythonT<DocumentObjectGroup>;
} //namespace App

View File

@@ -561,7 +561,7 @@ public:
}
App::Document* _document;
typedef boost::signals2::scoped_connection Connection;
using Connection = boost::signals2::scoped_connection;
Connection connectApplicationDeletedDocument;
};
@@ -642,7 +642,7 @@ public:
App::DocumentObject* object;
bool indocument;
typedef boost::signals2::scoped_connection Connection;
using Connection = boost::signals2::scoped_connection;
Connection connectApplicationDeletedDocument;
Connection connectDocumentCreatedObject;
Connection connectDocumentDeletedObject;

View File

@@ -28,6 +28,7 @@
#include <boost_signals2.hpp>
#include <memory>
#include <set>
#include <FCGlobal.h>
namespace App
@@ -501,7 +502,7 @@ protected:
private:
App::Document* _document;
typedef boost::signals2::connection Connection;
using Connection = boost::signals2::connection;
Connection connectApplicationCreatedDocument;
Connection connectApplicationDeletedDocument;
Connection connectApplicationActivateDocument;
@@ -522,7 +523,7 @@ class AppExport DocumentObjectObserver : public DocumentObserver
{
public:
typedef std::set<App::DocumentObject*>::const_iterator const_iterator;
using const_iterator = std::set<App::DocumentObject*>::const_iterator;
/// Constructor
DocumentObjectObserver();

View File

@@ -378,7 +378,7 @@ static inline bool essentiallyInteger(double a, long &l) {
// without holding Python global lock
struct PyObjectWrapper {
public:
typedef std::shared_ptr<PyObjectWrapper> Pointer;
using Pointer = std::shared_ptr<PyObjectWrapper>;
explicit PyObjectWrapper(PyObject *obj):pyobj(obj) {
Py::_XINCREF(pyobj);

View File

@@ -45,13 +45,13 @@ class DocumentObject;
class Expression;
class Document;
typedef std::unique_ptr<Expression> ExpressionPtr;
using ExpressionPtr = std::unique_ptr<Expression>;
AppExport bool isAnyEqual(const App::any &v1, const App::any &v2);
AppExport Base::Quantity anyToQuantity(const App::any &value, const char *errmsg = nullptr);
// Map of depending objects to a map of depending property name to the full referencing object identifier
typedef std::map<App::DocumentObject*, std::map<std::string, std::vector<ObjectIdentifier> > > ExpressionDeps;
using ExpressionDeps = std::map<App::DocumentObject*, std::map<std::string, std::vector<ObjectIdentifier> > >;
class AppExport ExpressionVisitor {
public:
@@ -172,7 +172,7 @@ public:
virtual void addComponent(Component* component);
typedef std::vector<Component*> ComponentList;
using ComponentList = std::vector<Component*>;
static Component *createComponent(const std::string &n);
static Component *createComponent(Expression *e1, Expression *e2=nullptr,

View File

@@ -146,7 +146,7 @@ template<> void _class_::init(void){\
* EXTENSION_ADD_PROPERTY(MyProp, (0)) *
* initExtension(MyExtension::getExtensionClassTypeId());
* }
* typedef ExtensionPythonT<MyExtension> MyExtensionPython;
* using MyExtensionPython = ExtensionPythonT<MyExtension>;
* @endcode
*
* The special python extension type created above is important, as only those python extensions
@@ -212,7 +212,7 @@ template<> void _class_::init(void){\
* To ensure that your wrapper is used when a extension is created from python the extension type must
* be exposed as follows:
* @code
* typedef ExtensionPythonT<MyExtensionPythonT<MyExtension>> MyExtensionPython;
* using MyExtensionPython = ExtensionPythonT<MyExtensionPythonT<MyExtension>>;
* @endcode
*
* This boilerplate is absolutely necessary to allow overridable methods in python and it is the

View File

@@ -114,7 +114,7 @@ class AppExport ExtensionContainer : public App::PropertyContainer
public:
typedef std::map<Base::Type, App::Extension*>::iterator ExtensionIterator;
using ExtensionIterator = std::map<Base::Type, App::Extension*>::iterator;
ExtensionContainer();
~ExtensionContainer() override;

View File

@@ -40,7 +40,7 @@ class ExtensionPythonT : public ExtensionT
EXTENSION_PROPERTY_HEADER(App::ExtensionPythonT<ExtensionT>);
public:
typedef ExtensionT Inherited;
using Inherited = ExtensionT;
ExtensionPythonT() {
ExtensionT::m_isPythonExtension = true;
@@ -54,7 +54,7 @@ public:
ExtensionPythonT& operator= (ExtensionPythonT&&) = delete;
};
typedef ExtensionPythonT<App::Extension> ExtensionPython;
using ExtensionPython = ExtensionPythonT<App::Extension>;
// Helper macros to define python extensions
#define EXTENSION_PROXY_FIRST(function) \

View File

@@ -150,7 +150,7 @@ private:
FlagMax,
};
typedef std::bitset<FlagMax> Flags;
using Flags = std::bitset<FlagMax>;
mutable Flags _Flags;
public:
@@ -355,8 +355,8 @@ private:
};
// Special Feature-Python classes
typedef FeaturePythonT<DocumentObject> FeaturePython;
typedef FeaturePythonT<GeoFeature > GeometryPython;
using FeaturePython = FeaturePythonT<DocumentObject>;
using GeometryPython = FeaturePythonT<GeoFeature >;
} //namespace App

View File

@@ -50,7 +50,7 @@ namespace App
*/
class AppExport GeoFeatureGroupExtension : public App::GroupExtension
{
typedef App::GroupExtension inherited;
using inherited = App::GroupExtension;
EXTENSION_PROPERTY_HEADER_WITH_OVERRIDE(App::GeoFeatureGroupExtension);
public:
@@ -138,7 +138,7 @@ private:
};
typedef ExtensionPythonT<GroupExtensionPythonT<GeoFeatureGroupExtension>> GeoFeatureGroupExtensionPython;
using GeoFeatureGroupExtensionPython = ExtensionPythonT<GroupExtensionPythonT<GeoFeatureGroupExtension>>;
} //namespace App

View File

@@ -38,7 +38,7 @@ class GroupExtensionPy;
class AppExport GroupExtension : public DocumentObjectExtension
{
EXTENSION_PROPERTY_HEADER_WITH_OVERRIDE(App::GroupExtension);
typedef DocumentObjectExtension inherited;
using inherited = DocumentObjectExtension;
public:
/// Constructor
@@ -160,7 +160,7 @@ public:
};
};
typedef ExtensionPythonT<GroupExtensionPythonT<GroupExtension>> GroupExtensionPython;
using GroupExtensionPython = ExtensionPythonT<GroupExtensionPythonT<GroupExtension>>;
} //namespace App

View File

@@ -49,7 +49,7 @@ using namespace App;
using namespace Base;
namespace bp = boost::placeholders;
typedef boost::iterator_range<const char*> CharRange;
using CharRange = boost::iterator_range<const char*>;
////////////////////////////////////////////////////////////////////////

View File

@@ -51,7 +51,7 @@ namespace App
class AppExport LinkBaseExtension : public App::DocumentObjectExtension
{
EXTENSION_PROPERTY_HEADER_WITH_OVERRIDE(App::LinkExtension);
typedef App::DocumentObjectExtension inherited;
using inherited = App::DocumentObjectExtension;
public:
LinkBaseExtension();
@@ -217,7 +217,7 @@ public:
virtual const std::vector<PropInfo> &getPropertyInfo() const;
typedef std::map<std::string, PropInfo> PropInfoMap;
using PropInfoMap = std::map<std::string, PropInfo>;
virtual const PropInfoMap &getPropertyInfoMap() const;
enum LinkCopyOnChangeType {
@@ -313,7 +313,7 @@ public:
DocumentObject *getTrueLinkedObject(bool recurse,
Base::Matrix4D *mat=nullptr,int depth=0, bool noElement=false) const;
typedef std::map<const Property*,std::pair<LinkBaseExtension*,int> > LinkPropMap;
using LinkPropMap = std::map<const Property*,std::pair<LinkBaseExtension*,int> >;
bool hasPlacement() const {
return getLinkPlacementProperty() || getPlacementProperty();
@@ -398,14 +398,14 @@ protected:
///////////////////////////////////////////////////////////////////////////
typedef ExtensionPythonT<LinkBaseExtension> LinkBaseExtensionPython;
using LinkBaseExtensionPython = ExtensionPythonT<LinkBaseExtension>;
///////////////////////////////////////////////////////////////////////////
class AppExport LinkExtension : public LinkBaseExtension
{
EXTENSION_PROPERTY_HEADER_WITH_OVERRIDE(App::LinkExtension);
typedef LinkBaseExtension inherited;
using inherited = LinkBaseExtension;
public:
LinkExtension();
@@ -509,14 +509,14 @@ public:
///////////////////////////////////////////////////////////////////////////
typedef ExtensionPythonT<LinkExtension> LinkExtensionPython;
using LinkExtensionPython = ExtensionPythonT<LinkExtension>;
///////////////////////////////////////////////////////////////////////////
class AppExport Link : public App::DocumentObject, public App::LinkExtension
{
PROPERTY_HEADER_WITH_EXTENSIONS(App::Link);
typedef App::DocumentObject inherited;
using inherited = App::DocumentObject;
public:
#define LINK_PARAMS_LINK \
@@ -556,13 +556,13 @@ public:
bool canLinkProperties() const override;
};
typedef App::FeaturePythonT<Link> LinkPython;
using LinkPython = App::FeaturePythonT<Link>;
///////////////////////////////////////////////////////////////////////////
class AppExport LinkElement : public App::DocumentObject, public App::LinkBaseExtension {
PROPERTY_HEADER_WITH_EXTENSIONS(App::LinkElement);
typedef App::DocumentObject inherited;
using inherited = App::DocumentObject;
public:
#define LINK_PARAMS_ELEMENT \
@@ -599,13 +599,13 @@ public:
}
};
typedef App::FeaturePythonT<LinkElement> LinkElementPython;
using LinkElementPython = App::FeaturePythonT<LinkElement>;
///////////////////////////////////////////////////////////////////////////
class AppExport LinkGroup : public App::DocumentObject, public App::LinkBaseExtension {
PROPERTY_HEADER_WITH_EXTENSIONS(App::LinkGroup);
typedef App::DocumentObject inherited;
using inherited = App::DocumentObject;
public:
#define LINK_PARAMS_GROUP \
@@ -630,7 +630,7 @@ public:
}
};
typedef App::FeaturePythonT<LinkGroup> LinkGroupPython;
using LinkGroupPython = App::FeaturePythonT<LinkGroup>;
} //namespace App

View File

@@ -40,8 +40,8 @@ std::string LinkBaseExtensionPy::representation() const
return str.str();
}
typedef std::map<std::string, std::pair<int,Property*> > PropTmpMap;
typedef std::map<std::string, Property*> PropMap;
using PropTmpMap = std::map<std::string, std::pair<int,Property*> >;
using PropMap = std::map<std::string, Property*>;
static bool getProperty(PropTmpMap &props, const LinkBaseExtension::PropInfoMap &infoMap,
const PropMap &propMap, PyObject *key, PyObject *value)

View File

@@ -50,7 +50,7 @@ public:
};
typedef App::FeaturePythonT<MaterialObject> MaterialObjectPython;
using MaterialObjectPython = App::FeaturePythonT<MaterialObject>;
} //namespace App

View File

@@ -66,7 +66,7 @@ protected:
private:
std::map<std::string, std::string>& nameMap;
typedef std::pair<std::string, std::string> PropertyTag;
using PropertyTag = std::pair<std::string, std::string>;
std::stack<PropertyTag> propertyStack;
};
}

View File

@@ -59,7 +59,7 @@ private:
App::Document* appdoc;
std::vector<App::DocumentObject*> objects;
std::map<std::string, std::string> nameMap;
typedef boost::signals2::connection Connection;
using Connection = boost::signals2::connection;
Connection connectExport;
Connection connectImport;
};

View File

@@ -346,7 +346,7 @@ public:
const std::string &getSubObjectName(bool newStyle) const;
const std::string &getSubObjectName() const;
typedef std::map<std::pair<App::DocumentObject*,std::string>,std::string> SubNameMap;
using SubNameMap = std::map<std::pair<App::DocumentObject*,std::string>,std::string>;
void importSubNames(const SubNameMap &subNameMap);
bool updateLabelReference(App::DocumentObject *, const std::string &, const char *);
@@ -363,7 +363,7 @@ public:
* the property may not exist at the time this ObjectIdentifier is
* constructed.
*/
typedef std::map<App::DocumentObject *, std::set<std::string> > Dependencies;
using Dependencies = std::map<App::DocumentObject *, std::set<std::string> >;
/** Get dependencies of this object identifier
*
@@ -516,8 +516,8 @@ namespace std {
template<>
struct hash<App::ObjectIdentifier> {
typedef App::ObjectIdentifier argument_type;
typedef std::size_t result_type;
using argument_type = App::ObjectIdentifier;
using result_type = std::size_t;
inline result_type operator()(argument_type const& s) const {
return s.hash();
}

View File

@@ -80,7 +80,7 @@ protected:
void onExtendedUnsetupObject () override;
};
typedef ExtensionPythonT<GroupExtensionPythonT<OriginGroupExtension>> OriginGroupExtensionPython;
using OriginGroupExtensionPython = ExtensionPythonT<GroupExtensionPythonT<OriginGroupExtension>>;
} /* App */

View File

@@ -98,7 +98,7 @@ public:
PyObject *getPyObject() override;
};
//typedef App::FeaturePythonT<Part> PartPython;
//using PartPython = App::FeaturePythonT<Part>;
} //namespace App

View File

@@ -48,7 +48,7 @@ public:
};
typedef App::FeaturePythonT<App::Placement> PlacementPython;
using PlacementPython = App::FeaturePythonT<App::Placement>;
} //namespace App

View File

@@ -474,11 +474,11 @@ class PropertyListsT: public ParentT
, public AtomicPropertyChangeInterface<PropertyListsT<T,ListT,ParentT> >
{
public:
typedef typename ListT::const_reference const_reference;
typedef ListT list_type;
typedef ParentT parent_type;
typedef typename AtomicPropertyChangeInterface<
PropertyListsT<T,ListT,ParentT> >::AtomicPropertyChange atomic_change;
using const_reference = typename ListT::const_reference;
using list_type = ListT;
using parent_type = ParentT;
using atomic_change = typename AtomicPropertyChangeInterface<
PropertyListsT<T,ListT,ParentT> >::AtomicPropertyChange;
friend atomic_change;

View File

@@ -550,7 +550,7 @@ PyObject* PropertyContainerPy::restorePropertyContent(PyObject *args)
//check if it really is a buffer
try {
typedef boost::iostreams::basic_array_source<char> Device;
using Device = boost::iostreams::basic_array_source<char>;
boost::iostreams::stream<Device> stream((char*)buf.buf, buf.len);
prop->restoreFromStream(stream);
}

View File

@@ -77,7 +77,7 @@ public:
Property *CopyOnLinkReplace(const App::DocumentObject *parent,
App::DocumentObject *oldObj, App::DocumentObject *newObj) const override;
typedef std::function<std::string (const App::ObjectIdentifier & path, std::shared_ptr<const App::Expression> expr)> ValidatorFunc;
using ValidatorFunc = std::function<std::string (const App::ObjectIdentifier & path, std::shared_ptr<const App::Expression> expr)>;
/**
* @brief The ExpressionInfo struct encapsulates an expression.
@@ -176,13 +176,13 @@ protected:
private:
typedef boost::adjacency_list< boost::listS, boost::vecS, boost::directedS > DiGraph;
typedef std::pair<int, int> Edge;
using DiGraph = boost::adjacency_list< boost::listS, boost::vecS, boost::directedS >;
using Edge = std::pair<int, int>;
// Note: use std::map instead of unordered_map to keep the binding order stable
#if defined(FC_OS_MACOSX) || defined(FC_OS_BSD)
typedef std::map<App::ObjectIdentifier, ExpressionInfo> ExpressionMap;
using ExpressionMap = std::map<App::ObjectIdentifier, ExpressionInfo>;
#else
typedef std::map<const App::ObjectIdentifier, ExpressionInfo> ExpressionMap;
using ExpressionMap = std::map<const App::ObjectIdentifier, ExpressionInfo>;
#endif
std::vector<App::ObjectIdentifier> computeEvaluationOrder(ExecuteOption option);

View File

@@ -199,7 +199,7 @@ class AppExport PropertyVectorList: public PropertyListsT<Base::Vector3d>
{
TYPESYSTEM_HEADER_WITH_OVERRIDE();
typedef PropertyListsT<Base::Vector3d> inherited;
using inherited = PropertyListsT<Base::Vector3d>;
public:
/**

View File

@@ -2519,14 +2519,14 @@ bool PropertyLinkSubList::adjustLink(const std::set<App::DocumentObject*> &inLis
// has now been changed to simply use the absoluteFilePath(), and rely on user
// to be aware of possible duplicated file location. The reason being that
// some user (especially Linux user) use symlink to organize file tree.
typedef std::map<QString,DocInfoPtr> DocInfoMap;
using DocInfoMap = std::map<QString, DocInfoPtr>;
DocInfoMap _DocInfoMap;
class App::DocInfo :
public std::enable_shared_from_this<App::DocInfo>
{
public:
typedef boost::signals2::scoped_connection Connection;
using Connection = boost::signals2::scoped_connection;
Connection connFinishRestoreDocument;
Connection connPendingReloadDocument;
Connection connDeleteDocument;

View File

@@ -40,7 +40,7 @@ class DocumentObject;
class Document;
class DocInfo;
typedef std::shared_ptr<DocInfo> DocInfoPtr;
using DocInfoPtr = std::shared_ptr<DocInfo>;
class PropertyXLink;
@@ -99,7 +99,7 @@ class AppExport PropertyLinkBase : public Property, public ScopedLink
{
TYPESYSTEM_HEADER_WITH_OVERRIDE();
public:
typedef std::pair<std::string,std::string> ShadowSub;
using ShadowSub = std::pair<std::string,std::string>;
PropertyLinkBase();
~PropertyLinkBase() override;
@@ -674,7 +674,7 @@ class AppExport PropertyLinkList :
public PropertyListsT<DocumentObject*,std::vector<DocumentObject*>, PropertyLinkListBase>
{
TYPESYSTEM_HEADER_WITH_OVERRIDE();
typedef PropertyListsT<DocumentObject*,std::vector<DocumentObject*>,PropertyLinkListBase> inherited;
using inherited = PropertyListsT<DocumentObject*,std::vector<DocumentObject*>,PropertyLinkListBase>;
public:
/**
@@ -899,7 +899,7 @@ class AppExport PropertyLinkSubList : public PropertyLinkBase
TYPESYSTEM_HEADER_WITH_OVERRIDE();
public:
typedef std::pair<DocumentObject*, std::vector<std::string> > SubSet;
using SubSet = std::pair<DocumentObject*, std::vector<std::string> >;
/**
* A constructor.
* A more elaborate description of the constructor.
@@ -1198,7 +1198,7 @@ class AppExport PropertyXLinkSubList: public PropertyLinkBase
{
TYPESYSTEM_HEADER_WITH_OVERRIDE();
typedef typename AtomicPropertyChangeInterface<PropertyXLinkSubList>::AtomicPropertyChange atomic_change;
using atomic_change = typename AtomicPropertyChangeInterface<PropertyXLinkSubList>::AtomicPropertyChange;
friend atomic_change;
public:

View File

@@ -798,7 +798,7 @@ public:
class AppExport PropertyStringList: public PropertyListsT<std::string>
{
TYPESYSTEM_HEADER_WITH_OVERRIDE();
typedef PropertyListsT<std::string> inherited;
using inherited = PropertyListsT<std::string>;
public:
@@ -891,7 +891,7 @@ private:
class AppExport PropertyBoolList : public PropertyListsT<bool,boost::dynamic_bitset<> >
{
TYPESYSTEM_HEADER_WITH_OVERRIDE();
typedef PropertyListsT<bool,boost::dynamic_bitset<> > inherited;
using inherited = PropertyListsT<bool, boost::dynamic_bitset<> >;
public:
PropertyBoolList();
@@ -1105,7 +1105,7 @@ protected:
*/
class AppExport PropertyPersistentObject: public PropertyString {
TYPESYSTEM_HEADER_WITH_OVERRIDE();
typedef PropertyString inherited;
using inherited = PropertyString;
public:
PyObject *getPyObject() override;
void setValue(const char* type) override;

View File

@@ -89,7 +89,7 @@ public:
private:
int transID;
typedef std::pair<const TransactionalObject*, TransactionObject*> Info;
using Info = std::pair<const TransactionalObject*, TransactionObject*>;
bmi::multi_index_container<
Info,
bmi::indexed_by<