YSTest: yftext.h 源文件

YSTest PreAlpha_b400_20130424 The YSLib Test Project

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

- 文件列表
- 文件成员

全部 类 命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义 组 页
yftext.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
28 #ifndef YSL_INC_CORE_YFTEXT_H_
29 #define YSL_INC_CORE_YFTEXT_H_ 1
30
31 #include "yfile.h"
32 #include "../Adaptor/ycont.h" // for string;
33
34 YSL_BEGIN
35
45 yconstexpr char BOM_UTF_16LE[]{"\xFF\xFE"};
46 yconstexpr char BOM_UTF_16BE[]{"\xFE\xFF"};
47 yconstexpr char BOM_UTF_8[]{"\xEF\xBB\xBF"};
48 yconstexpr char BOM_UTF_32LE[]{"\xFF\xFE\x00\x00"};
49 yconstexpr char BOM_UTF_32BE[]{"\x00\x00\xFE\xFF"};
51
52
54 class YF_API TextFile : public File
55 {
56 private:
57 size_t bl;
58
59 public:
65 Text::Encoding Encoding;
66
72 explicit
73 TextFile(const_path_t, std::ios_base::openmode = std::ios_base::in,
74 Text::Encoding = Text::CS_Default);
79 explicit
80 TextFile(const String&);
81
87 string
88 GetBOM() const;
89 DefGetter(const ynothrow, u8, BOMSize, bl)
90 DefGetter(const ynothrow, size_t, TextSize, GetSize() - GetBOMSize()) \
92 DefGetter(const ynothrow, size_t, TextPosition, GetPosition() - bl) \
94
100 size_t
101 CheckBOM(Text::Encoding&);
102
107 void
108 Locate(u32) const;
109
113 void
114 Rewind() const;
115
120 template<typename _tChar, typename... _tParams>
121 inline Text::ConversionResult
122 ReadChar(_tChar& c, _tParams&&... args) const
123 {
124 return MBCToUC(c, GetPtr(), Encoding, args...);
125 }
126
131 template<typename... _tParams>
132 inline Text::ConversionResult
133 SkipChar(_tParams&&... args) const
134 {
135 return MBCToUC(GetPtr(), Encoding, args...);
136 }
137
143 bool
144 Truncate(size_t) const override;
145 };
146
147 YSL_END
148
149 #endif
150