YSTest  PreAlpha_b400_20130424
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
Helper Functions

助手功能。 更多...

Helper Functions 的协作图:

模块

 Get Unique Pointer
 使用指定类型指针构造 std::unique_ptr 实例。
 
 

函数

template<bool _bIsPositive, typename _tScalar >
_tScalar & ystdex::xcrease (_tScalar &_x)
 编译期选择自增/自减运算。
 
template<bool _bIsPositive, typename _tScalar1 , typename _tScalar2 >
_tScalar1 & ystdex::delta_assign (_tScalar1 &_x, _tScalar2 &_y)
 编译期选择加法/减法复合赋值运算。
 
template<typename _tIterator1 , typename _tIterator2 >
auto ystdex::make_move_iterator_pair (_tIterator1 it1, _tIterator2 it2) -> decltype(std::make_pair(std::make_move_iterator(it1), std::make_move_iterator(it2)))
 取转移迭代器对。
 
template<typename _tRange >
auto ystdex::make_move_iterator_pair (_tRange &c) -> decltype(ystdex::make_move_iterator_pair(begin(c), end(c)))
 取指定序列范围(包含序列容器及内建数组等)的转移迭代器对。
 
template<typename _tIterator , typename _fTransformer >
transformed_iterator< typename
array_ref_decay< _tIterator >
::type, _fTransformer > 
ystdex::make_transform (_tIterator &&i, _fTransformer &&f)
 创建转换迭代器。
 
template<typename _type , typename... _tParams>
std::unique_ptr< _type > ystdex::make_unique (_tParams &&...args)
 使用 new 和指定参数构造指定类型的 std::unique_ptr 实例。
 
template<typename _type , typename... _tParams>
std::shared_ptr< _type > ystdex::make_shared (_tParams &&...args)
 使用 new 和指定参数构造指定类型的 std::shared_ptr 实例。
 
template<typename _type >
decay< _type >::type ystdex::decay_copy (_type &&arg)
 退化复制。
 
template<typename _type >
qualified_decay< _type >::type ystdex::decay_forward (_type &&arg)
 退化传递。
 
Drawing::FontCache & FetchDefaultFontCache () ynothrow
 取默认字体缓存。
 
shared_ptr< Shell > YSLib::FetchShellHandle () ynothrow
 取当前应用程序线程空间中活动的 Shell 句柄。
 
bool YSLib::Activate (const shared_ptr< Shell > &hShl)
 激活 Shell 对象:控制权转移给此对象以维持单线程运行。
 
template<typename _type >
ValueObject YSLib::MakeValueObjectByPtr (_type *p)
 使用指针构造 ValueObject 实例。
 
template<VisualEvent _vID>
GEvent< void(typename
EventTypeMapping< _vID >
::HandlerType::EventArgsType)> & 
YSLib::UI::FetchEvent (VisualEventMap &m)
 取控件事件。
 
template<VisualEvent _vID>
GEvent< void(typename
EventTypeMapping< _vID >
::HandlerType::EventArgsType)> & 
YSLib::UI::FetchEvent (AController &controller)
 取部件事件。
 
template<VisualEvent _vID>
GEvent< void(typename
EventTypeMapping< _vID >
::HandlerType::EventArgsType)> & 
YSLib::UI::FetchEvent (IWidget &wgt)
 取部件事件。
 
void YSLib::UI::RequestFocus (IWidget &wgt)
 向部件容器释放获得焦点,成功后向自身发送 GotFocus 事件。
 
void YSLib::UI::ReleaseFocus (IWidget &wgt)
 释放焦点,成功后向自身发送 LostFocus 事件。
 
IWidget * YSLib::UI::FetchContainerPtr (const IWidget &wgt)
 取部件的容器指针。
 
IWidget * YSLib::UI::FetchFocusingPtr (IWidget &wgt)
 取焦点对象指针。
 
const Point & YSLib::UI::GetLocationOf (const IWidget &wgt)
 取部件位置。
 
const Size & YSLib::UI::GetSizeOf (const IWidget &wgt)
 取部件大小。
 
template<typename _type , size_t _vN>
size_t ystdex::arrlen (_type(&)[_vN])
 计算指定数组类型对象的长度。
 
template<typename _type , size_t _vN>
size_t ystdex::arrlen (_type(&&)[_vN])
 
template<class _type , class _tHandle >
_type & HandleToReference (_tHandle h) ythrow(std
 句柄转换:对象引用。
 
template<class _tShell >
_tShell & FetchShell ()
 取指定 Shell 句柄对应的 Shell 引用 。
 
template<class _tShl >
shared_ptr< Shell > FetchStored ()
 取全局 Shell 句柄。
 
template<class _tShl >
void ReleaseStored ()
 释放全局 Shell 。
 
bool IsNowShell (const shared_ptr< Shell > &hShl)
 判断句柄指定的 Shell 是否为当前线程空间中运行的 Shell 。
 
errno_t NowShellTo (const shared_ptr< Shell > &hShl)
 向句柄指定的 Shell 对象转移线程控制权。
 
template<class _tShl >
errno_t NowShellToNew ()
 向新建 Shell 对象转移控制权。
 
template<class _tShl >
errno_t NowShellToStored ()
 向全局 Shell 管理器的对象转移控制权。
 
void SetShellTo (const shared_ptr< Shell > &hShl, Messaging::Priority prior=0x80)
 通过主消息队列向指定 Shell 对象转移控制权。
 
template<class _tShl >
void SetShellToNew ()
 通过主消息队列向新建 Shell 对象转移控制权。
 
template<class _tShl >
void SetShellToStored ()
 通过主消息队列向全局 Shell 管理器内的对象转移控制权。
 
template<class _tShl >
void CallStoredAtOnce ()
 封装向全局 Shell 管理器内的对象转移控制权。
 
template<class _tShl >
void CallStored ()
 封装通过消息队列向全局 Shell 管理器内的对象转移控制权。
 
void ResetDesktop (Desktop &dsk, Devices::Screen &scr)
 复位桌面。
 
Color GenerateRandomColor ()
 
template<typename _tOut , typename _tGen >
void ScrDraw (_tOut buf, _tGen &&f)
 全屏幕描点。
 
shared_ptr< Image > CreateSharedScreenImage (ConstBitmapPtr p)
 新建屏幕图像。
 
template<typename _tPixel >
_tPixel * CreateRawBitmap (const _tPixel *s, size_t n)
 使用 new 分配空间并复制无压缩位图。
 
YF_API void RemoveGlobalTasks ()
 从全局消息队列中移除所有后台消息。
 
yconstexpr const char * DefaultTimeFormat ("%04u-%02u-%02u %02u:%02u:%02u")
 默认时间格式字符串。
 
YF_API const char * TranslateTime (const std::tm &, const char *=DefaultTimeFormat)
 格式化时间字符串。
 
YF_API const char * TranslateTime (const std::time_t &, const char *=DefaultTimeFormat) ythrow(GeneralEvent)
 
auto YSLib::begin (ValueNode &node) -> decltype(node.GetBegin())
 迭代器包装,用于 range-based for 。
 
auto YSLib::begin (const ValueNode &node) -> decltype(node.GetBegin())
 
auto YSLib::end (ValueNode &node) -> decltype(node.GetEnd())
 
auto YSLib::end (const ValueNode &node) -> decltype(node.GetEnd())
 

详细描述

助手功能。

自从
build 243

仅帮助简化编码形式或确定接口,并不包含编译期之后逻辑功能实现的代码设施。

函数说明

bool YSLib::Activate ( const shared_ptr< Shell > &  hShl)
inline

激活 Shell 对象:控制权转移给此对象以维持单线程运行。

前置条件
断言: bool(hShl)
警告
不保证线程安全性。

在文件 yapp.h135 行定义.

参考 FetchAppInstance(),h , 以及 YAssert.

参考自 YSLib::UI::Console::Console(),Execute(),YSL_BEGIN::Init(),NowShellTo(),ShlTextReader::OnKeyDown() , 以及 YSLib::UI::InputTimer::Refresh().

函数调用图:

这是这个函数的调用关系图:

template<typename _type , size_t _vN>
size_t ystdex::arrlen ( _type(&)  [_vN])
inline

计算指定数组类型对象的长度。

自从
build 291

在文件 utility.hpp142 行定义.

参考自 FetchEncodingString() , 以及 ShlTextReader::SettingSession::SettingSession().

这是这个函数的调用关系图:

template<typename _type , size_t _vN>
size_t ystdex::arrlen ( _type(&&)  [_vN])
inline

在文件 utility.hpp148 行定义.

auto YSLib::begin ( ValueNode &  node) -> decltype(node.GetBegin())
inline

迭代器包装,用于 range-based for 。

自从
build 330

在文件 ValueNode.h184 行定义.

参考 YSLib::ValueNode::GetBegin().

参考自 ystdex::erase_all(),ystdex::erase_all_if(),YSLib::IO::Path::GetRelativePath(),ystdex::make_move_iterator_pair(),YSLib::Messaging::MessageQueue::Peek(),YSLib::Messaging::MessageQueue::Pop() , 以及 ystdex::split().

函数调用图:

这是这个函数的调用关系图:

auto YSLib::begin ( const ValueNode &  node) -> decltype(node.GetBegin())
inline

在文件 ValueNode.h189 行定义.

参考 YSLib::ValueNode::GetBegin().

函数调用图:

template<class _tShl >
void CallStored ( )
inline

封装通过消息队列向全局 Shell 管理器内的对象转移控制权。

自从
早于 build 132

在文件 ShellHelper.h287 行定义.

template<class _tShl >
void CallStoredAtOnce ( )
inline

封装向全局 Shell 管理器内的对象转移控制权。

自从
早于 build 132

在文件 ShellHelper.h276 行定义.

template<typename _tPixel >
_tPixel* CreateRawBitmap ( const _tPixel *  s,
size_t  n 
)

使用 new 分配空间并复制无压缩位图。

自从
build 213

在文件 ShellHelper.h350 行定义.

参考 YB_LIKELY.

shared_ptr<Image> CreateSharedScreenImage ( ConstBitmapPtr  p)
inline

新建屏幕图像。

自从
build 213

在文件 ShellHelper.h339 行定义.

参考 MainScreenHeight , 以及 MainScreenWidth.

template<typename _type >
decay<_type>::type ystdex::decay_copy ( _type &&  arg)

退化复制。

参见
ISO C++11 30.2.6[thread.decaycopy] 。
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3255.html
自从
build 337

在文件 utility.hpp114 行定义.

参考自 ystdex::make_array(),YSLib::MakeNode() , 以及 YSLib::UnpackToNode().

这是这个函数的调用关系图:

template<typename _type >
qualified_decay<_type>::type ystdex::decay_forward ( _type &&  arg)

退化传递。

注解
类似 decay_copy ,但仅对函数或数组及其引用类型退化,不复制其它值。
自从
build 383

在文件 utility.hpp128 行定义.

参考自 ystdex::seq_apply() , 以及 ystdex::unseq_apply().

这是这个函数的调用关系图:

yconstexpr const char* DefaultTimeFormat ( "%04u-%02u-%02u %02u:%02u:%02u"  )

默认时间格式字符串。

自从
build 307
template<bool _bIsPositive, typename _tScalar1 , typename _tScalar2 >
_tScalar1& ystdex::delta_assign ( _tScalar1 &  _x,
_tScalar2 &  _y 
)
inline

编译期选择加法/减法复合赋值运算。

自从
build 284

在文件 functional.hpp353 行定义.

auto YSLib::end ( ValueNode &  node) -> decltype(node.GetEnd())
inline
auto YSLib::end ( const ValueNode &  node) -> decltype(node.GetEnd())
inline

在文件 ValueNode.h200 行定义.

参考 YSLib::ValueNode::GetEnd().

函数调用图:

Drawing::FontCache& FetchDefaultFontCache ( )
inline

取默认字体缓存。

自从
build 398

在文件 GUIApplication.h152 行定义.

参考 FetchGlobalInstance() , 以及 GUIApplication::GetFontCache().

参考自 FetchDefaultTypeface(),FetchFontFamilyNames() , 以及 YSLib::Drawing::FontCache::GetDefaultTypefacePtr().

函数调用图:

这是这个函数的调用关系图:

template<VisualEvent _vID>
GEvent<void( typename EventTypeMapping<_vID>::HandlerType ::EventArgsType)>& YSLib::UI::FetchEvent ( VisualEventMap &  m)

取控件事件。

注解
需要确保 EventTypeMapping 中有对应的 EventType ,否则无法匹配此函数模板。
若控件事件不存在则自动添加空事件。

在文件 ycontrol.h137 行定义.

参考 EventT , 以及 GetEvent().

函数调用图:

template<VisualEvent _vID>
GEvent<void( typename EventTypeMapping<_vID>::HandlerType ::EventArgsType)>& YSLib::UI::FetchEvent ( AController &  controller)

取部件事件。

模板参数
_vID指定事件类型。
参数
controller指定部件的控制器。
异常
BadControl异常中立:无事件映射表:由 GetController 抛出。
注解
需要确保 EventTypeMapping 中有对应的 EventType ,否则无法匹配此函数模板。
若控件事件不存在则自动添加空事件。
自从
build 195

在文件 ycontrol.h154 行定义.

参考 EventT , 以及 YSLib::UI::AController::GetItemRef().

函数调用图:

template<VisualEvent _vID>
GEvent<void( typename EventTypeMapping<_vID>::HandlerType ::EventArgsType)>& YSLib::UI::FetchEvent ( IWidget &  wgt)
inline

取部件事件。

模板参数
_vID指定事件类型。
参数
wgt指定部件。
异常
BadControl异常中立:无事件映射表:由 GetController 抛出。
注解
需要确保 EventTypeMapping 中有对应的 EventType ,否则无法匹配此函数模板。
若控件事件不存在则自动添加空事件。
自从
build 237

在文件 ycontrol.h171 行定义.

参考 YSLib::UI::IWidget::GetController().

函数调用图:

IWidget* YSLib::UI::FetchFocusingPtr ( IWidget &  wgt)
inline

取焦点对象指针。

返回
若为保存了子部件中的焦点对象的容器则返回指针,否则返回 nullptr
自从
build 239

在文件 ywidget.h141 行定义.

参考 YSLib::UI::View::FocusingPtr , 以及 YSLib::UI::IWidget::GetView().

参考自 ClearFocusingOf(),IsFocused(),YSLib::UI::Panel::operator-=() , 以及 YSLib::UI::GUIState::ResponseKey().

函数调用图:

这是这个函数的调用关系图:

template<class _tShell >
_tShell& FetchShell ( )
inline

取指定 Shell 句柄对应的 Shell 引用 。

自从
build 205

在文件 ShellHelper.h159 行定义.

参考 YSLib::FetchShellHandle() , 以及 YAssert.

函数调用图:

shared_ptr<Shell> YSLib::FetchShellHandle ( )
inline

取当前应用程序线程空间中活动的 Shell 句柄。

警告
应用程序实例初始化前不保证线程安全性。

在文件 yapp.h123 行定义.

参考 FetchAppInstance().

参考自 FetchShell().

函数调用图:

这是这个函数的调用关系图:

template<class _tShl >
shared_ptr<Shell> FetchStored ( )
inline

取全局 Shell 句柄。

自从
build 195

在文件 ShellHelper.h177 行定义.

Color GenerateRandomColor ( )
inline
自从
build 360

在文件 ShellHelper.h313 行定义.

参考自 GetDesktopDownHandle().

这是这个函数的调用关系图:

template<class _type , class _tHandle >
_type& HandleToReference ( _tHandle  h)
inline

句柄转换:对象引用。

自从
早于 build 132

在文件 ShellHelper.h144 行定义.

参考 h,ystdex::raw() , 以及 YB_LIKELY.

函数调用图:

bool IsNowShell ( const shared_ptr< Shell > &  hShl)
inline

判断句柄指定的 Shell 是否为当前线程空间中运行的 Shell 。

自从
早于 build 132

在文件 ShellHelper.h199 行定义.

参考 FetchAppInstance().

函数调用图:

template<typename _tIterator1 , typename _tIterator2 >
auto ystdex::make_move_iterator_pair ( _tIterator1  it1,
_tIterator2  it2 
) -> decltype( std::make_pair(std::make_move_iterator(it1), std::make_move_iterator(it2)))
inline

取转移迭代器对。

自从
build 337

在文件 iterator.hpp108 行定义.

参考自 ystdex::make_move_iterator_pair().

这是这个函数的调用关系图:

template<typename _tRange >
auto ystdex::make_move_iterator_pair ( _tRange &  c) -> decltype(ystdex::make_move_iterator_pair(begin(c), end(c)))
inline

取指定序列范围(包含序列容器及内建数组等)的转移迭代器对。

注解
使用 ADL beginend 指定范围迭代器。
自从
build 337

在文件 iterator.hpp122 行定义.

参考 YSLib::begin(),YSLib::end() , 以及 ystdex::make_move_iterator_pair().

函数调用图:

template<typename _type , typename... _tParams>
std::shared_ptr<_type> ystdex::make_shared ( _tParams &&...  args)
inline

使用 new 和指定参数构造指定类型的 std::shared_ptr 实例。

模板参数
_type被指向类型。
注解
不同于 std::make_shared ,不依赖于具体 allocator 和 deleter 类型信息。
std::make_shared 的具体实现一般会导致目标文件增大。
自从
build 298

在文件 memory.hpp242 行定义.

template<typename _tIterator , typename _fTransformer >
transformed_iterator<typename array_ref_decay<_tIterator>::type, _fTransformer> ystdex::make_transform ( _tIterator &&  i,
_fTransformer &&  f 
)
inline

创建转换迭代器。

注解
使用 ADL 。
自从
build 288

在文件 iterator.hpp555 行定义.

参考 yforward.

参考自 ystdex::operator|().

这是这个函数的调用关系图:

template<typename _type , typename... _tParams>
std::unique_ptr<_type> ystdex::make_unique ( _tParams &&...  args)
inline

使用 new 和指定参数构造指定类型的 std::unique_ptr 实例。

模板参数
_type被指向类型。
参见
http://herbsutter.com/gotw/_102/
自从
build 293
待办事项:
其它 deleter 的重载。

在文件 memory.hpp227 行定义.

template<typename _type >
ValueObject YSLib::MakeValueObjectByPtr ( _type *  p)
inline

使用指针构造 ValueObject 实例。

自从
build 233

在文件 yobject.h399 行定义.

参考自 DeclResource().

这是这个函数的调用关系图:

errno_t NowShellTo ( const shared_ptr< Shell > &  hShl)
inline

向句柄指定的 Shell 对象转移线程控制权。

自从
早于 build 132

在文件 ShellHelper.h209 行定义.

参考 YSLib::Activate().

参考自 ShlReader::Exit(),GetDesktopDownHandle(),NowShellToNew() , 以及 NowShellToStored().

函数调用图:

这是这个函数的调用关系图:

template<class _tShl >
errno_t NowShellToNew ( )
inline

向新建 Shell 对象转移控制权。

自从
早于 build 132

在文件 ShellHelper.h220 行定义.

参考 NowShellTo().

函数调用图:

template<class _tShl >
errno_t NowShellToStored ( )
inline

向全局 Shell 管理器的对象转移控制权。

自从
早于 build 132

在文件 ShellHelper.h231 行定义.

参考 NowShellTo().

函数调用图:

void YSLib::UI::ReleaseFocus ( IWidget &  wgt)
inline

释放焦点,成功后向自身发送 LostFocus 事件。

在文件 yfocus.h93 行定义.

参考 ReleaseFocusFrom().

参考自 Hide(),YSLib::UI::MenuHost::HideRaw() , 以及 ReleaseFocusCascade().

函数调用图:

这是这个函数的调用关系图:

template<class _tShl >
void ReleaseStored ( )
inline

释放全局 Shell 。

自从
build 195

在文件 ShellHelper.h188 行定义.

YF_API void RemoveGlobalTasks ( )

从全局消息队列中移除所有后台消息。

自从
build 320

在文件 ShellHelper.cpp72 行定义.

参考 FetchGlobalInstance().

函数调用图:

void YSLib::UI::RequestFocus ( IWidget &  wgt)
inline

向部件容器释放获得焦点,成功后向自身发送 GotFocus 事件。

在文件 yfocus.h83 行定义.

参考 RequestFocusFrom().

参考自 OnTouchDown_RequestToTopFocused(),RequestFocusCascade(),Show() , 以及 YSLib::UI::MenuHost::ShowRaw().

函数调用图:

这是这个函数的调用关系图:

void ResetDesktop ( Desktop &  dsk,
Devices::Screen &  scr 
)
inline

复位桌面。

自从
build 396

销毁每个桌面并在原存储位置创建新的对象。

在文件 ShellHelper.h300 行定义.

参考 YSLib::UI::Styles::Desktop.

参考自 ResetDSDesktops().

这是这个函数的调用关系图:

template<typename _tOut , typename _tGen >
void ScrDraw ( _tOut  buf,
_tGen &&  f 
)

全屏幕描点。

注解
颜色由坐标决定。
自从
build 360

在文件 ShellHelper.h327 行定义.

参考 MainScreenHeight,MainScreenWidth,yforward , 以及 yunseq().

参考自 FetchImage().

函数调用图:

这是这个函数的调用关系图:

void SetShellTo ( const shared_ptr< Shell > &  hShl,
Messaging::Priority  prior = 0x80 
)
inline

通过主消息队列向指定 Shell 对象转移控制权。

自从
早于 build 132

在文件 ShellHelper.h241 行定义.

参考自 SetShellToNew() , 以及 SetShellToStored().

这是这个函数的调用关系图:

template<class _tShl >
void SetShellToNew ( )
inline

通过主消息队列向新建 Shell 对象转移控制权。

自从
早于 build 132

在文件 ShellHelper.h254 行定义.

参考 SetShellTo().

函数调用图:

template<class _tShl >
void SetShellToStored ( )
inline

通过主消息队列向全局 Shell 管理器内的对象转移控制权。

自从
早于 build 132

在文件 ShellHelper.h265 行定义.

参考 SetShellTo().

函数调用图:

YF_API const char* TranslateTime ( const std::tm &  ,
const char *  = DefaultTimeFormat 
)

格式化时间字符串。

自从
build 307

在文件 ShellHelper.cpp100 行定义.

参考自 TranslateTime().

这是这个函数的调用关系图:

YF_API const char* TranslateTime ( const std::time_t &  ,
const char *  = DefaultTimeFormat 
)

在文件 ShellHelper.cpp110 行定义.

参考 TranslateTime() , 以及 YB_UNLIKELY.

函数调用图:

template<bool _bIsPositive, typename _tScalar >
_tScalar& ystdex::xcrease ( _tScalar &  _x)
inline

编译期选择自增/自减运算。

在文件 functional.hpp341 行定义.