28 #ifndef YSL_INC_Service_File_h_
29 #define YSL_INC_Service_File_h_ 1
32 #include YFM_YSLib_Core_YCoreUtilities
34 #include YFM_YSLib_Adaptor_YTextBase
65 File(
const char*,
const char* =
"rb");
67 File(
const char*, std::ios_base::openmode);
97 DefGetter(const ynothrow, ptrdiff_t, Position, std::ftell(
fp))
104 PDefH(
int, Seek, ptrdiff_t offset,
int whence) const
111 PDefH(
int, CheckEOF, ) const
139 PDefH(
int, Flush, ) const
152 Open(const
char*, const
char* = "rb");
155 Open(const
char*, std::ios_base::openmode);
159 Open(const String&, std::ios_base::openmode);
169 PDefH(
size_t, Read,
void* ptr,
size_t size = 1U,
size_t nmemb = 1U) const
170 ImplRet(std::fread(ptr, size, nmemb, fp))
175 PDefH(
void, Rewind, ) const
185 Truncate(
size_t) const;
194 PDefH(
size_t, Write,
void* ptr,
size_t size = 1U,
size_t nmemb = 1U) const
195 ImplRet(std::fwrite(ptr, size, nmemb, fp))
208 template<typename _tChar>
210 operator>>(
File&
f, typename std::char_traits<_tChar>::char_type&
c)
212 YAssert(
bool(f),
"Invalid file found.");
214 c = std::fgetc(f.GetPtr());
221 template<
typename _tString>
225 YAssert(
bool(f),
"Invalid file found.");
229 while((c = std::fgetc(f.GetPtr())) > 0 && !std::iswspace(c))
241 YAssert(
bool(f),
"Invalid file found.");
242 std::fputc(c, f.GetPtr());
252 YAssert(
bool(f),
"Invalid file found.");
253 std::fputs(str, f.GetPtr());
261 template<
typename _tString>
265 YAssert(
bool(f),
"Invalid file found.");
266 std::fputs(reinterpret_cast<const char*>(str.c_str()), f.GetPtr());
std::FILE ConversionState fp
File & operator>>(File &f, _tString &str)
从指定文件读空白符分隔的字符串。
#define DefGetter(_q, _t, _n,...)
不可复制对象:禁止派生类调用默认原型的复制构造函数和复制赋值操作符。
YSLib 标准字符串(使用 UCS-2 作为内部编码)。
#define ynothrow
YSLib 无异常抛出保证:若支持 noexcept 关键字, 指定特定的 noexcept 异常规范。
char16_t ucs2_t
UCS-2 字符类型。
#define DefCvt(_q, _t,...)
File & operator<<(File &f, const Configuration &conf)
#define YAssert(_expr, _msg)