📄 method_properties.hpp
字号:
{}
STLSOFT_DECLARE_TEMPLATE_PARAM_AS_FRIEND(C);
/// @}
/// \name Operators
/// @{
public:
operator reference_type() const
{
return (*PFn)();
}
/// @}
/// \name Members
/// @{
private:
value_type m_value;
/// @}
/// \name Not to be implemented
/// @{
private:
/// This method is hidden in order to prevent users of this class from
/// becoming familiar with using operator = on the property instances
/// from within the containing class, since doing so with
/// method_property_getset<> would result in an infinite loop.
class_type& operator =(reference_type value);
/// @}
};
/** \brief Implements static write-only Method Property
*
* \ingroup group__library__properties
*/
template< ss_typename_param_k V
, ss_typename_param_k R /* The reference type */
, ss_typename_param_k C
, void (*PFn)(R )
>
class static_method_property_set
: public internal_property<0, 1, 1>
{
/// \name Member Types
/// @{
public:
typedef V value_type;
typedef R reference_type;
typedef C container_type;
typedef static_method_property_set<V, R, C, PFn> class_type;
/// @}
/// \name Construction
/// @{
public:
static_method_property_set()
{}
ss_explicit_k static_method_property_set(reference_type value)
: m_value(value)
{}
STLSOFT_DECLARE_TEMPLATE_PARAM_AS_FRIEND(C);
/// @}
/// \name Operators
/// @{
public:
static_method_property_set& operator =(reference_type value)
{
(*PFn)(value);
return *this;
}
/// @}
/// \name Members
/// @{
private:
value_type m_value;
/// @}
};
/** \brief Implements static read-write Method Property
*
* \ingroup group__library__properties
*/
template< ss_typename_param_k V
, ss_typename_param_k RG
, ss_typename_param_k RS
, ss_typename_param_k C
, RG (*PFnGet)(void)
, void (*PFnSet)(RS )
>
class static_method_property_getset
: public internal_property<1, 1, 1>
{
/// \name Member Types
/// @{
public:
typedef V value_type;
typedef RG get_reference_type;
typedef RS set_reference_type;
typedef C container_type;
typedef static_method_property_getset<V, RG, RS, C, PFnGet, PFnSet> class_type;
STLSOFT_DECLARE_TEMPLATE_PARAM_AS_FRIEND(C);
/// @}
/// \name Construction
/// @{
public:
static_method_property_getset()
{}
ss_explicit_k static_method_property_getset(set_reference_type value)
: m_value(value)
{}
/// @}
/// \name Operators
/// @{
public:
operator get_reference_type() const
{
return (*PFnGet)();
}
static_method_property_getset& operator =(set_reference_type value)
{
(*PFnSet)(value);
return *this;
}
/// @}
/// \name Members
/// @{
private:
value_type m_value;
/// @}
};
/* /////////////////////////////////////////////////////////////////////////
* External static method property classes
*/
/** \brief Implements External static read-only Method Property
*
* \ingroup group__library__properties
*/
template< ss_typename_param_k R /* The reference type */
, R (*PFn)(void)
>
class static_method_property_get_external
: public external_property<1, 0, 1>
{
/// \name Member Types
/// @{
public:
typedef R reference_type;
typedef static_method_property_get_external<R, PFn> class_type;
/// @}
/// \name Operators
/// @{
public:
#if !defined(STLSOFT_COMPILER_IS_MSVC) || \
_MSC_VER > 1200
operator reference_type() const
{
return (*PFn)();
}
#else /* ? compiler */
operator R() const
{
R (*pfn)() = PFn;
return (*pfn)();
}
#endif /* compiler */
/// @}
/// \name Not to be implemented
/// @{
private:
/// This method is hidden in order to prevent users of this class from
/// becoming familiar with using operator = on the property instances
/// from within the containing class, since doing so with
/// method_property_getset<> would result in an infinite loop.
class_type& operator =(reference_type value);
/// @}
};
/** \brief Implements External static write-only Method Property.
*/
template< ss_typename_param_k R /* The reference type */
, void (*PFn)(R )
>
class static_method_property_set_external
: public external_property<0, 1, 1>
{
/// \name Member Types
/// @{
public:
typedef R reference_type;
typedef static_method_property_set_external<R, PFn> class_type;
/// @}
/// \name Operators
/// @{
public:
static_method_property_set_external& operator =(reference_type value)
{
(*PFn)(value);
return *this;
}
/// @}
};
/** \brief Implements External static read-write Method Property
*
* \ingroup group__library__properties
*/
template< ss_typename_param_k RG
, ss_typename_param_k RS
, RG (*PFnGet)(void)
, void (*PFnSet)(RS )
>
class static_method_property_getset_external
: public external_property<1, 1, 1>
{
/// \name Member Types
/// @{
public:
typedef RG get_reference_type;
typedef RS set_reference_type;
typedef static_method_property_getset_external<RG, RS, PFnGet, PFnSet> class_type;
/// @}
/// \name Operators
/// @{
public:
operator get_reference_type() const
{
return (*PFnGet)();
}
static_method_property_getset_external& operator =(set_reference_type value)
{
(*PFnSet)(value);
return *this;
}
/// @}
};
/* /////////////////////////////////////////////////////////////////////////
* IOStream compatibility
*/
// method_property_getset
template< ss_typename_param_k V
, ss_typename_param_k RG
, ss_typename_param_k RS
, ss_typename_param_k C
, ss_ptrdiff_t (*PFnOff)()
#ifdef STLSOFT_CF_MEM_FUNC_AS_TEMPLATE_PARAM_SUPPORT
, RG (C::*PFnGet)() const
, void (C::*PFnSet)(RS)
#endif /* STLSOFT_CF_MEM_FUNC_AS_TEMPLATE_PARAM_SUPPORT */
, ss_typename_param_k S
>
inline S& operator <<( S& s
#ifdef STLSOFT_CF_MEM_FUNC_AS_TEMPLATE_PARAM_SUPPORT
, method_property_getset<V, RG, RS, C, PFnOff, PFnGet, PFnSet> const& prop)
#else /* ? STLSOFT_CF_MEM_FUNC_AS_TEMPLATE_PARAM_SUPPORT */
, method_property_getset<V, RG, RS, C, PFnOff> const& prop)
#endif /* STLSOFT_CF_MEM_FUNC_AS_TEMPLATE_PARAM_SUPPORT */
{
s << static_cast<RG>(prop);
return s;
}
// method_property_get
template< ss_typename_param_k V
, ss_typename_param_k R
, ss_typename_param_k C
, ss_ptrdiff_t (*PFnOff)()
#ifdef STLSOFT_CF_MEM_FUNC_AS_TEMPLATE_PARAM_SUPPORT
, R (C::*PFnGet)() const
#endif /* STLSOFT_CF_MEM_FUNC_AS_TEMPLATE_PARAM_SUPPORT */
, ss_typename_param_k S
>
inline S& operator <<( S& s
#ifdef STLSOFT_CF_MEM_FUNC_AS_TEMPLATE_PARAM_SUPPORT
, method_property_get<V, R, C, PFnOff, PFnGet> const& prop)
#else /* ? STLSOFT_CF_MEM_FUNC_AS_TEMPLATE_PARAM_SUPPORT */
, method_property_get<V, R, C, PFnOff> const& prop)
#endif /* STLSOFT_CF_MEM_FUNC_AS_TEMPLATE_PARAM_SUPPORT */
{
s << static_cast<R>(prop);
return s;
}
// method_property_getset_external
template< ss_typename_param_k RG
, ss_typename_param_k RS
, ss_typename_param_k C
, ss_ptrdiff_t (*PFnOff)()
#ifdef STLSOFT_CF_MEM_FUNC_AS_TEMPLATE_PARAM_SUPPORT
, RG (C::*PFnGet)() const
, void (C::*PFnSet)(RS )
#endif /* STLSOFT_CF_MEM_FUNC_AS_TEMPLATE_PARAM_SUPPORT */
, ss_typename_param_k S
>
inline S& operator <<( S& s
#ifdef STLSOFT_CF_MEM_FUNC_AS_TEMPLATE_PARAM_SUPPORT
, method_property_getset_external<RG, RS, C, PFnOff, PFnGet, PFnSet> const& prop)
#else /* ? STLSOFT_CF_MEM_FUNC_AS_TEMPLATE_PARAM_SUPPORT */
, method_property_getset_external<RG, RS, C, PFnOff> const& prop)
#endif /* STLSOFT_CF_MEM_FUNC_AS_TEMPLATE_PARAM_SUPPORT */
{
s << static_cast<RG>(prop);
return s;
}
// method_property_get_external
template< ss_typename_param_k R
, ss_typename_param_k C
, ss_ptrdiff_t (*PFnOff)()
#ifdef STLSOFT_CF_MEM_FUNC_AS_TEMPLATE_PARAM_SUPPORT
, R (C::*PFnGet)() const
#endif /* STLSOFT_CF_MEM_FUNC_AS_TEMPLATE_PARAM_SUPPORT */
, ss_typename_param_k S
>
inline S& operator <<( S& s
#ifdef STLSOFT_CF_MEM_FUNC_AS_TEMPLATE_PARAM_SUPPORT
, method_property_get_external<R, C, PFnOff, PFnGet> const& prop)
#else /* ? STLSOFT_CF_MEM_FUNC_AS_TEMPLATE_PARAM_SUPPORT */
, method_property_get_external<R, C, PFnOff> const& prop)
#endif /* STLSOFT_CF_MEM_FUNC_AS_TEMPLATE_PARAM_SUPPORT */
{
s << static_cast<R>(prop);
return s;
}
/* ////////////////////////////////////////////////////////////////////// */
#ifndef _STLSOFT_NO_NAMESPACE
} // namespace stlsoft
#endif /* _STLSOFT_NO_NAMESPACE */
/* ////////////////////////////////////////////////////////////////////// */
#endif /* !STLSOFT_INCL_STLSOFT_PROPERTIES_HPP_METHOD_PROPERTIES */
/* ////////////////////////////////////////////////////////////////////// */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -