YSTest  PreAlpha_b400_20130424
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
ycommon.h
浏览该文件的文档.
1 /*
2  Copyright by FrankHB 2009 - 2013.
3 
4  This file is part of the YSLib project, and may only be used,
5  modified, and distributed under the terms of the YSLib project
6  license, LICENSE.TXT. By continuing to use, modify, or distribute
7  this file you indicate that you have read the license and
8  understand and accept it fully.
9 */
10 
32 #ifndef YCL_INC_ycommon_h_
33 #define YCL_INC_ycommon_h_ 1
34 
35 //平台定义。
36 #include "Platform.h"
37 
38 //平台无关部分。
39 #include <ydef.h>
40 #include <ystdex/cstdio.h>
41 #include <cstdlib>
42 #include <string>
43 
44 //平台相关部分。
45 //#include <unistd.h>
46 
48 namespace platform
49 {
50 
57 
58 
59 //断言。
60 #ifdef YB_USE_YASSERT
61 
62 #undef YAssert
63 
68 YF_API void
69 yassert(bool, const char*, const char*, int, const char*);
70 
71 #define YAssert(exp, message) \
72  platform::yassert(exp, #exp, message, __LINE__, __FILE__)
73 
74 #else
75 
76 #include <cassert>
77 # define YAssert(exp, message) assert(exp)
78 
79 #endif
80 
81 } // namespace platform;
82 
83 namespace platform_ex
84 {
85 
86 #if YCL_DS
87 
95 YF_API bool
96 AllowSleep(bool);
97 
98 #elif YCL_MINGW32
99 // TODO: Add more Windows specific APIs.
100 
102 
104 UTF8ToMBCS(const char*, std::size_t, int);
105 inline std::string
106 UTF8ToMBCS(const std::string& str, int cp)
107 {
108  return UTF8ToMBCS(str.c_str(), str.length(), cp);
109 }
110 
112 WCSToMBCS(const wchar_t*, std::size_t, int);
113 inline std::string
114 WCSToMBCS(const std::wstring& str, int cp)
115 {
116  return WCSToMBCS(str.c_str(), str.length(), cp);
117 }
119 
120 #else
121 # error Unsupport platform found!
122 #endif
123 
124 } // namespace platform_ex;
125 
126 #endif
127