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

This commit is contained in:
wmayer
2022-08-29 11:42:09 +02:00
parent c0d69f7d8e
commit 4e42ff7baa
27 changed files with 67 additions and 67 deletions

View File

@@ -27,7 +27,7 @@
#include "Type.h"
// Python stuff
typedef struct _object PyObject;
using PyObject = struct _object;
/// define for subclassing Base::BaseClass

View File

@@ -27,7 +27,7 @@
#include <memory>
#include <FCGlobal.h>
typedef struct _object PyObject;
using PyObject = struct _object;
namespace Base
{

View File

@@ -43,8 +43,8 @@ class BoundBox3
static bool isOnRayS(_Precision, _Precision, _Precision);
public:
typedef _Precision num_type;
typedef float_traits<num_type> traits_type;
using num_type = _Precision;
using traits_type = float_traits<num_type>;
/** Public attributes */
//@{
@@ -982,8 +982,8 @@ inline void BoundBox3<_Precision>::ScaleZ (_Precision f)
MinZ *= f; MaxZ *= f;
}
typedef BoundBox3<float> BoundBox3f;
typedef BoundBox3<double> BoundBox3d;
using BoundBox3f = BoundBox3<float>;
using BoundBox3d = BoundBox3<double>;
} // namespace Base

View File

@@ -36,7 +36,7 @@ namespace Base
{
class Matrix4D;
template <class _Precision> class Vector3;
typedef Vector3<float> Vector3f;
using Vector3f = Vector3<float>;
/** A Builder class for 3D representations on App level
* On the application level nothing is known of the visual representation of data.

View File

@@ -36,8 +36,8 @@
#include <FCGlobal.h>
// Python stuff
typedef struct _object PyObject;
typedef struct PyMethodDef PyMethodDef;
using PyObject = struct _object;
using PyMethodDef = struct PyMethodDef;
//FIXME: ISO C++11 requires at least one argument for the "..." in a variadic macro
#if defined(__clang__)
@@ -454,7 +454,7 @@ namespace Base {
} // namespace Base
//TODO: Get rid of this typedef
typedef unsigned int ConsoleMsgFlags;
using ConsoleMsgFlags = unsigned int;
namespace Base {

View File

@@ -36,8 +36,8 @@ struct vec_traits { };
template <>
struct vec_traits<Vector3f> {
typedef Vector3f vec_type;
typedef float float_type;
using vec_type = Vector3f;
using float_type = float;
vec_traits(const vec_type& v) : v(v){}
inline std::tuple<float_type,float_type,float_type> get() const {
return std::make_tuple(v.x, v.y, v.z);
@@ -48,8 +48,8 @@ private:
template <>
struct vec_traits<Vector3d> {
typedef Vector3d vec_type;
typedef double float_type;
using vec_type = Vector3d;
using float_type = double;
vec_traits(const vec_type& v) : v(v){}
inline std::tuple<float_type,float_type,float_type> get() const {
return std::make_tuple(v.x, v.y, v.z);
@@ -60,8 +60,8 @@ private:
template <>
struct vec_traits<Rotation> {
typedef Rotation vec_type;
typedef double float_type;
using vec_type = Rotation;
using float_type = double;
vec_traits(const vec_type& v) : v(v){}
inline std::tuple<float_type,float_type,float_type,float_type> get() const {
float_type q1,q2,q3,q4;
@@ -75,8 +75,8 @@ private:
// type with three floats
template <class _Vec, typename float_type>
_Vec make_vec(const std::tuple<float_type, float_type, float_type>&& t) {
typedef vec_traits<_Vec> traits_type;
typedef typename traits_type::float_type float_traits_type;
using traits_type = vec_traits<_Vec>;
using float_traits_type = typename traits_type::float_type;
return _Vec(float_traits_type(std::get<0>(t)),
float_traits_type(std::get<1>(t)),
float_traits_type(std::get<2>(t)));
@@ -85,8 +85,8 @@ _Vec make_vec(const std::tuple<float_type, float_type, float_type>&& t) {
// type with four floats
template <class _Vec, typename float_type>
_Vec make_vec(const std::tuple<float_type, float_type, float_type, float_type>&& t) {
typedef vec_traits<_Vec> traits_type;
typedef typename traits_type::float_type float_traits_type;
using traits_type = vec_traits<_Vec>;
using float_traits_type = typename traits_type::float_type;
return _Vec(float_traits_type(std::get<0>(t)),
float_traits_type(std::get<1>(t)),
float_traits_type(std::get<2>(t)),
@@ -96,8 +96,8 @@ _Vec make_vec(const std::tuple<float_type, float_type, float_type, float_type>&&
template <class _Vec1, class _Vec2>
inline _Vec1 convertTo(const _Vec2& v)
{
typedef vec_traits<_Vec2> traits_type;
typedef typename traits_type::float_type float_type;
using traits_type = vec_traits<_Vec2>;
using float_type = typename traits_type::float_type;
traits_type t(v);
auto tuple = t.get();
return make_vec<_Vec1, float_type>(std::move(tuple));

View File

@@ -31,7 +31,7 @@
#include "FileInfo.h"
typedef struct _object PyObject;
using PyObject = struct _object;
/* MACROS FOR THROWING EXCEPTIONS */

View File

@@ -29,7 +29,7 @@
#include <typeinfo>
// Python stuff
typedef struct _object PyObject;
using PyObject = struct _object;
namespace Base
{

View File

@@ -117,7 +117,7 @@ private:
namespace Py {
typedef PythonClassObject<Base::Vector2dPy> Vector2d;
using Vector2d = PythonClassObject<Base::Vector2dPy>;
inline Base::Vector2d toVector2d(PyObject *py) {
Base::Vector2dPy* py2d = Py::Vector2d(py).getCxxObject();
@@ -246,14 +246,14 @@ private:
};
// PyCXX wrapper classes Py::Matrix, Py::Rotation, Py::Placement, ...
typedef GeometryT<Base::BoundBox3d, Base::BoundBoxPy,
&Base::BoundBoxPy::getBoundBoxPtr> BoundingBox;
typedef GeometryT<Base::Matrix4D, Base::MatrixPy,
&Base::MatrixPy::getMatrixPtr> Matrix;
typedef GeometryT<Base::Rotation, Base::RotationPy,
&Base::RotationPy::getRotationPtr> Rotation;
typedef GeometryT<Base::Placement, Base::PlacementPy,
&Base::PlacementPy::getPlacementPtr> Placement;
using BoundingBox = GeometryT<Base::BoundBox3d, Base::BoundBoxPy,
&Base::BoundBoxPy::getBoundBoxPtr>;
using Matrix = GeometryT<Base::Matrix4D, Base::MatrixPy,
&Base::MatrixPy::getMatrixPtr>;
using Rotation = GeometryT<Base::Rotation, Base::RotationPy,
&Base::RotationPy::getRotationPtr>;
using Placement = GeometryT<Base::Placement, Base::PlacementPy,
&Base::PlacementPy::getPlacementPtr>;
}

View File

@@ -487,7 +487,7 @@ void Matrix4D::inverse ()
(*this) = clInvRotMat * clInvTrlMat;
}
typedef double * Matrix;
using Matrix = double *;
void Matrix_gauss(Matrix a, Matrix b)
{

View File

@@ -47,7 +47,7 @@ enum class ScaleType {
*/
class BaseExport Matrix4D
{
typedef float_traits<double> traits_type;
using traits_type = float_traits<double>;
public:
/// Default constructor

View File

@@ -100,9 +100,9 @@ class Subject
{
public:
typedef Observer<_MessageType> ObserverType;
typedef _MessageType MessageType;
typedef Subject<_MessageType> SubjectType;
using ObserverType = Observer<_MessageType>;
using MessageType = _MessageType;
using SubjectType = Subject<_MessageType>;
/**
* A constructor.

View File

@@ -33,7 +33,7 @@
#define BASE__PARAMETER_H
// Python stuff
typedef struct _object PyObject;
using PyObject = struct _object;
#ifdef FC_OS_MACOSX
#undef toupper
@@ -118,7 +118,7 @@ public:
/// test if a special sub group is in this group
bool HasGroup(const char* Name) const;
/// type of the handle
typedef Base::Reference<ParameterGrp> handle;
using handle = Base::Reference<ParameterGrp>;
/// remove a sub group from this group
void RemoveGrp(const char* Name);
/// rename a sub group from this group

View File

@@ -85,7 +85,7 @@ private:
Py::Object inst;
};
typedef std::list<ParameterGrpObserver*> ParameterGrpObserverList;
using ParameterGrpObserverList = std::list<ParameterGrpObserver*>;
class ParameterGrpPy : public Py::PythonExtension<ParameterGrpPy>
{

View File

@@ -135,7 +135,7 @@ PyObject* PersistencePy::restoreContent(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);
getPersistencePtr()->restoreFromStream(stream);
}

View File

@@ -326,7 +326,7 @@ public:
return StatusBits.test(NoTrack);
}
typedef void* PointerType;
using PointerType = void*;
private:
void setAttributeOf(const char* attr, PyObject* par);

View File

@@ -49,7 +49,7 @@ struct BaseExport QuantityFormat {
Scientific = 2
};
typedef int NumberOptions;
using NumberOptions = int;
NumberOptions option;
NumberFormat format;
int precision;

View File

@@ -266,7 +266,7 @@ protected:
unsigned int CharacterCount;
std::map<std::string,std::string> AttrMap;
typedef std::map<std::string,std::string> AttrMapType;
using AttrMapType = std::map<std::string,std::string>;
enum {
None = 0,

View File

@@ -812,7 +812,7 @@ struct EulerSequence_Parameters
EulerSequence_Parameters translateEulerSequence (const Rotation::EulerSequence theSeq)
{
typedef EulerSequence_Parameters Params;
using Params = EulerSequence_Parameters;
const bool F = false;
const bool T = true;

View File

@@ -27,7 +27,7 @@
#include <FCGlobal.h>
// forward declarations
typedef struct _object PyObject;
using PyObject = struct _object;
namespace Py {
class Object;

View File

@@ -38,7 +38,7 @@
class QByteArray;
class QIODevice;
class QBuffer;
typedef struct _object PyObject;
using PyObject = struct _object;
namespace Base {
@@ -255,11 +255,11 @@ protected:
class BaseExport PyStreambuf : public std::streambuf
{
typedef std::streambuf::int_type int_type;
typedef std::streambuf::pos_type pos_type;
typedef std::streambuf::off_type off_type;
typedef std::ios::seekdir seekdir;
typedef std::ios::openmode openmode;
using int_type = std::streambuf::int_type;
using pos_type = std::streambuf::pos_type;
using off_type = std::streambuf::off_type;
using seekdir = std::ios::seekdir;
using openmode = std::ios::openmode;
public:
enum Type {

View File

@@ -229,8 +229,8 @@ private:
// ----------------------------------------------------------------------------
class ConnectionBlocker {
typedef boost::signals2::connection Connection;
typedef boost::signals2::shared_connection_block ConnectionBlock;
using Connection = boost::signals2::connection;
using ConnectionBlock = boost::signals2::shared_connection_block;
ConnectionBlock blocker;
public:

View File

@@ -92,7 +92,7 @@ public:
static void *createInstanceByName(const char* TypeName, bool bLoadModule=false);
static void importModule(const char* TypeName);
typedef void * (*instantiationMethod)();
using instantiationMethod = void * (*)();
static Type fromName(const char *name);
static Type fromKey(unsigned int key);

View File

@@ -12,7 +12,7 @@
Delete="true">
<ForwardDeclarations>
namespace Base {
typedef Type BaseType;
using BaseType = Type;
}</ForwardDeclarations>
<Documentation>
<Author Licence="LGPL" Name="Juergen Riegel" EMail="FreeCAD@juergen-riegel.net" />

View File

@@ -29,11 +29,11 @@
#include "UnitsSchema.h"
#include "Quantity.h"
typedef struct _object PyObject;
typedef struct PyMethodDef PyMethodDef;
using PyObject = struct _object;
using PyMethodDef = struct PyMethodDef;
namespace Base {
typedef std::unique_ptr<UnitsSchema> UnitsSchemaPtr;
using UnitsSchemaPtr = std::unique_ptr<UnitsSchema>;
/**
* The UnitsApi

View File

@@ -59,7 +59,7 @@ struct float_traits { };
template <>
struct float_traits<float> {
typedef float float_type;
using float_type = float;
static inline float_type pi() { return F_PI; }
static inline float_type epsilon() { return FLT_EPSILON; }
static inline float_type maximum() { return FLT_MAX; }
@@ -67,7 +67,7 @@ struct float_traits<float> {
template <>
struct float_traits<double> {
typedef double float_type;
using float_type = double;
static inline float_type pi() { return D_PI; }
static inline float_type epsilon() { return DBL_EPSILON; }
static inline float_type maximum() { return DBL_MAX; }
@@ -78,8 +78,8 @@ template <class _Precision>
class Vector3
{
public:
typedef _Precision num_type;
typedef float_traits<num_type> traits_type;
using num_type = _Precision;
using traits_type = float_traits<num_type>;
static inline num_type epsilon() { return traits_type::epsilon(); }
/** @name Public data members */
@@ -248,8 +248,8 @@ inline Vector3<_Pr1> toVector(const Vector3<_Pr2>& v)
return Vector3<_Pr1>(static_cast<_Pr1>(v.x),static_cast<_Pr1>(v.y),static_cast<_Pr1>(v.z));
}
typedef Vector3<float> Vector3f;
typedef Vector3<double> Vector3d;
using Vector3f = Vector3<float>;
using Vector3d = Vector3<double>;
} // namespace Base

View File

@@ -90,7 +90,7 @@ public:
int finalization();
-
typedef @self.export.TwinPointer@* PointerType ;
using PointerType = @self.export.TwinPointer@*;
virtual PyObject *_repr(); // the representation
std::string representation() const;