YSTest
PreAlpha_b400_20130424
The YSLib Test Project
首页
相关页面
模块
命名空间
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
cstdio.h
浏览该文件的文档.
1
/*
2
Copyright by FrankHB 2011 - 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
28
#ifndef YB_INC_ystdex_cstdio_h_
29
#define YB_INC_ystdex_cstdio_h_ 1
30
31
#include "../ydef.h"
32
#include <cstdio>
33
#include <ios>
// for std::ios_base::openmode;
34
#include <iterator>
35
#include "
memory.hpp
"
// for ystdex::is_undereferenceable;
36
37
namespace
ystdex
38
{
39
45
typedef
char
*
path_t
;
46
typedef
const
char
*
const_path_t
;
48
55
YB_API
bool
56
fexists
(
const
char
*)
ynothrow
;
57
58
59
/*
60
\brief ISO C/C++ 标准输入输出接口打开模式转换。
61
\see ISO C++11 Table 132 。
62
\note 忽略 std::ios_base::ate 。
63
\since build 326
64
*/
65
YB_API
const
char
*
66
openmode_conv
(std::ios_base::openmode)
ynothrow
;
67
/*
68
\brief ISO C/C++ 标准输入输出接口打开模式转换。
69
\return 若失败(包括空参数情形)为 std::ios_base::openmode() ,否则为对应的值。
70
\see ISO C11 7.21.5.3/3 。
71
\note 顺序严格限定。
72
\note 支持 x 转换。
73
\since build 326
74
*/
75
YB_API
std::ios_base::openmode
76
openmode_conv
(const
char
*) ynothrow;
77
78
83
class
YB_API
ifile_iterator
: public std::iterator<std::input_iterator_tag,
84
byte
, ptrdiff_t, const byte*, const byte&>
85
{
86
protected
:
87
typedef
std::iterator<std::input_iterator_tag,
88
byte
, ptrdiff_t,
const
byte*,
const
byte&>
traits_type
;
89
90
public
:
91
typedef
byte
char_type
;
92
typedef
std::FILE
istream_type
;
93
94
private
:
95
istream_type*
stream
;
96
char_type
value
;
97
98
public
:
105
yconstfn
106
ifile_iterator
()
107
: stream(), value()
108
{}
114
ifile_iterator
(istream_type& s)
115
: stream(&s)
116
{
117
++*
this
;
118
}
122
yconstfn
123
ifile_iterator
(
const
ifile_iterator
&) =
default
;
124
~
ifile_iterator
() =
default
;
125
126
yconstfn
reference
127
operator*
()
const
128
{
129
return
value;
130
}
131
132
yconstfn
pointer
133
operator->()
const
134
{
135
return
&**
this
;
136
}
137
138
/*
139
\brief 前置自增。
140
\pre 断言:流指针非空。
141
\return 自身引用。
142
\note 当读到 EOF 时置流指针为空指针。
143
144
使用 std::fgetc 读字符。
145
*/
146
ifile_iterator
&
147
operator++();
148
/*
149
\brief 后置自增。
150
\pre 断言:同前置自增。
151
\return 迭代器副本。
152
153
读入字符。
154
*/
155
ifile_iterator
156
operator++(
int
)
157
{
158
const
auto
i(*
this
);
159
160
++*
this
;
161
return
i;
162
}
163
164
friend
yconstfn
bool
165
operator==
(
const
ifile_iterator
& x,
const
ifile_iterator
& y)
166
{
167
return
x.
stream
== y.
stream
;
168
}
169
170
yconstfn
istream_type*
171
get_stream()
const
172
{
173
return
stream;
174
}
175
};
176
177
yconstfn
bool
178
operator!=
(
const
ifile_iterator
& x,
const
ifile_iterator
& y)
179
{
180
return
!(x == y);
181
}
182
183
189
inline
bool
190
is_undereferenceable
(
const
ifile_iterator
& i)
191
{
192
return
!i.
get_stream
();
193
}
194
195
}
// namespace ystdex;
196
197
#endif
198
YBase
include
ystdex
cstdio.h
生成于 2013年 四月 24日 星期三 18:41:27 , 为 YSTest使用
1.8.2