YSTest: TextFile.h 源文件

YSTest PreAlpha_b700_20160611 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

TextFile.h
浏览该文件的文档.
1 /*
2 © 2009-2016 FrankHB.
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 YSL_INC_Service_TextFile_h_
29 #define YSL_INC_Service_TextFile_h_ 1
30
31 #include "YModules.h"
32 #include YFM_YSLib_Service_File // for string, File;
33
34 namespace YSLib
35 {
36
37 namespace Text
38 {
39
48 YB_NONNULL(1, 2) Text::Encoding
49 VerifyEncoding(std::FILE*, char*, size_t, size_t, Encoding = CS_Default);
50 YB_NONNULL(2) Text::Encoding
51 VerifyEncoding(std::istream&, char*, size_t, size_t, Encoding = CS_Default);
53
54
64 yconstexpr const char BOM_UTF_16LE[]{"\xFF\xFE"};
65 yconstexpr const char BOM_UTF_16BE[]{"\xFE\xFF"};
66 yconstexpr const char BOM_UTF_8[]{"\xEF\xBB\xBF"};
67 yconstexpr const char BOM_UTF_32LE[]{"\xFF\xFE\x00\x00"};
68 yconstexpr const char BOM_UTF_32BE[]{"\x00\x00\xFE\xFF"};
70
77 inline YB_NONNULL(1, 2) PDefH(bool, CheckBOM, const char* buf, const char* str,
78 size_t n)
79 ImplRet(std::char_traits<char>::compare(buf, str, n) == 0)
80 template<size_t _vN>
81 inline YB_NONNULL(1) bool
82 CheckBOM(const char* buf, const char(&str)[_vN])
83 {
84 return CheckBOM(buf, str, _vN - 1);
85 }
87
89
90
96 YF_API YB_NONNULL(1) pair<Encoding, size_t>
97 DetectBOM(const char*);
103 YF_API pair<Encoding, size_t>
104 DetectBOM(string_view);
114 YF_API pair<Encoding, size_t>
115 DetectBOM(std::istream&, size_t, Encoding = CS_Default);
117
124 YF_API size_t
125 WriteBOM(std::ostream&, Text::Encoding);
126
127 } // namespace Text;
128
129 } // namespace YSLib;
130
131 #endif
132
ystdex::string_view
basic_string_view< char > string_view
Definition: string_view.hpp:415
yconstexpr
#define yconstexpr
指定编译时常量表达式。
Definition: ydef.h:653
YSLib::Text::buf
const char * buf
Definition: TextFile.h:77
YSLib::Text::VerifyEncoding
Encoding VerifyEncoding(std::FILE *fp, char *s, size_t buflen, size_t txt_len, Encoding enc)
Definition: TextFile.cpp:40
YSLib::Text::BOM_UTF_8
yconstexpr const char BOM_UTF_8[]
Definition: TextFile.h:66
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:45
YSLib::PDefH
PDefH(Environment &, FetchEnvironment,) ImplRet(FetchGlobalInstance().GetEnvironmentRef()) inline PDefH(GUIHost &
取单一环境对象引用。
YSLib::Text::BOM_UTF_32LE
yconstexpr const char BOM_UTF_32LE[]
Definition: TextFile.h:67
CHRLib::CS_Default
yconstexpr const Encoding CS_Default(CharSet::UTF_8)
默认字符编码。
YSLib::Text::BOM_UTF_32BE
yconstexpr const char BOM_UTF_32BE[]
Definition: TextFile.h:68
CHRLib::CharSet::Encoding
Encoding
字符流编码标识。
Definition: Encoding.h:58
YSLib::Text::BOM_UTF_16LE
YB_NONNULL(1, 2) Text YB_NONNULL(2) Text yconstexpr const char BOM_UTF_16LE[]
验证流的编码。
Definition: TextFile.h:64
YModules.h
std
Definition: memory.hpp:1100
YSLib::Text::WriteBOM
YF_API size_t WriteBOM(std::ostream &, Text::Encoding)
写入指定编码的 BOM 。
Definition: TextFile.cpp:129
YSLib::Text::DetectBOM
YF_API size_t DetectBOM(const char *)
Definition: TextFile.cpp:72
YSLib::Text::str
const char const char * str
Definition: TextFile.h:77
YSLib::Text::YB_NONNULL
YB_NONNULL(1, 2) PDefH(bool
检查缓冲区是否具有指定的 BOM 。
YSLib::Text::CheckBOM
CheckBOM
Definition: TextFile.h:77
YSLib::Text::BOM_UTF_16BE
yconstexpr const char BOM_UTF_16BE[]
Definition: TextFile.h:65
Text
YF_API
#define YF_API
Definition: Platform.h:56
YSLib::Text::ImplRet
const char const char size_t n ImplRet(std::char_traits< char >::compare(buf, str, n)==0) template< size_t _vN > inline YB_NONNULL(1) bool CheckBOM(const char *buf
platform::n
size_t n
Definition: YCLib/FileSystem.cpp:321