Nearing completion of the TypeInfo template class…
Features include the following:
naming, e.g.
TypeInfo<int>::Name
character manipulation, e.g.
TypeInfo<char>::NullChar or TypeInfo<wchar_t>::NullChar, which equates to '\0' or L'\0'
type filtering, e.g.
TypeInfo<int*>::raw_type, which equates to int
TypeInfo<int*>::reference_type, which equates to int*&
TypeInfo<TypeInfo<int*>::raw_type>::reference_type, which equates to int&
TypeInfo<int&>::pointer_type, which equates to int*
Type ordering, e.g.
TypeInfo<short>::next_type, which equates to int
TypeInfo<double>::prev_type, which equates to float
TypeInfo class also provides many more features, such as IsInteger, IsDecimal, IsLarger, IsSmaller, IsSigned, etc.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is the C++ version implemented without using macros:
classTimePeriod{private:doubleseconds;public:Property<TimePeriod,double,ocl::ePropertyReadWrite/*this is the default if not specified*/>Hours;constdouble&GetHours()const{returnseconds/3600;}voidSetHours(constdouble&value){seconds=value*3600;}public:TimePeriod():Hours(this,&TimePeriod::GetHours,&TimePeriod::SetHours)};
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There are also some version of the C++ properties using macros.
classTimePeriod{private:doubleseconds;// property will be publicOCL_PROPERTY(TimePeriod,double,Hours);OCL_PROPERTY_GET(Hours){returnseconds/3600;}OCL_PROPERTY_SET(Hours){seconds=value*3600;}public:TimePeriod():OCL_PROPERTY_LINK(Hours)};
This is the C++ read-only version implemented using macros:
classTimePeriod{private:doubleseconds;// property will be publicOCL_PROPERTY_READONLY(TimePeriod,double,Hours){returnseconds/3600;}public:TimePeriod():OCL_PROPERTY_LINK(Hours)};
This is the C++ write-only version implemented using macros:
classTimePeriod{private:doubleseconds;// property will be publicOCL_PROPERTY_WRITEONLY(TimePeriod,double,Hours){seconds=value*3600;}public:TimePeriod():OCL_PROPERTY_LINK(Hours)};
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There is also a macro called OCL_PROPERTY_LINK_CLASS which can be used instead of using the Property constructor manually to initialise the property object.
e.g.
instead of:
TimePeriod() : Hours(this, &TimePeriod::GetHours, &TimePeriod::SetHours)
could use:
TimePeriod() : OCL_PROPERTY_LINK_CLASS(TimePeriod, Hours)
When using the property, it would be the same as C#, e.g.
Welcome to Activities
Just added some new data types into the data folder of the project.
Now have Pair, Triple, Quad, OneOfPair and OneOfType.
OneOfPair and OneOfType allow compile time boolean type selection.
sample code:
ocl::OneOfType<double, long, IsDecimal>::type value;
value = IsDecimal ? 1.5 : 1;
Nearing completion of the TypeInfo template class…
Features include the following:
naming, e.g.
character manipulation, e.g.
type filtering, e.g.
Type ordering, e.g.
TypeInfo class also provides many more features, such as IsInteger, IsDecimal, IsLarger, IsSmaller, IsSigned, etc.
http://cppocl.co.uk is now up and running, although under development.
Patience please, so much to do…
C++ properties have been re-implemented to be simpler to use.
This is the c# equivalent:
This is the C++ version implemented without using macros:
There are also some version of the C++ properties using macros.
This is the C++ read-only version implemented using macros:
This is the C++ write-only version implemented using macros:
There is also a macro called OCL_PROPERTY_LINK_CLASS which can be used instead of using the Property constructor manually to initialise the property object.
e.g.
instead of:
TimePeriod() : Hours(this, &TimePeriod::GetHours, &TimePeriod::SetHours)
could use:
TimePeriod() : OCL_PROPERTY_LINK_CLASS(TimePeriod, Hours)
When using the property, it would be the same as C#, e.g.
TimePeriod tp;
tp.Hours = 3;
double hrs = tp.Hours;
break points can then be used within the get and set methods if required, when debugging.