YSTest: ContentType.h 源文件

YSTest PreAlpha_b900_20201012 The YSLib Test Project

ContentType.h
浏览该文件的文档.
1 /*
2 © 2013-2015 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_ContentType_h_
29 #define YSL_INC_Service_ContentType_h_ 1
30
31 #include "YModules.h"
32 #include YFM_YSLib_Core_ValueNode
33 #include <ystdex/path.hpp>
34
35 namespace YSLib
36 {
37
44 class YF_API MIMEBiMapping
45 {
46 public:
47 using ExtensionType = string;
48 using MIMEType = ystdex::path<vector<string>>;
49 using ExtensionMap = multimap<ExtensionType, MIMEType>;
50 using MIMEMap = multimap<MIMEType, ExtensionType>;
51
52 private:
53 ExtensionMap ext_map;
54 MIMEMap inv_map;
55
56 public:
57 DefDeCtor(MIMEBiMapping)
58 template<typename _tIn>
59 MIMEBiMapping(_tIn first, _tIn last)
60 {
61 std::for_each(first, last, [this](decltype(*first) pr){
62 *this += pr;
63 });
64 }
65 template<typename _type>
66 MIMEBiMapping(std::initializer_list<_type> il)
67 : MIMEBiMapping(il.begin(), il.end())
68 {}
69
70 DefDeMoveCtor(MIMEBiMapping)
71
72 void
73 operator+=(const pair<ExtensionType, MIMEType>&);
74 void
75 operator+=(const pair<MIMEType, ExtensionType>&);
76
77 void
78 operator-=(const pair<ExtensionType, MIMEType>&);
79 void
80 operator-=(const pair<MIMEType, ExtensionType>&);
81
82 DefGetter(const ynothrow, const ExtensionMap&, ExtensionMap, ext_map)
83 DefGetter(const ynothrow, const MIMEMap&, MIMEMap, inv_map)
84 };
85
86
91 YF_API void
92 AddMIMEItems(MIMEBiMapping&, const ValueNode&, MIMEBiMapping::MIMEType&& = {});
93
94 } // namespace YSLib;
95
96 #endif
97
path.hpp
抽象路径模板。
YSLib::MIMEBiMapping::DefDeCtor
DefDeCtor(MIMEBiMapping) template< typename _tIn > MIMEBiMapping(_tIn first
YSLib::MIMEBiMapping::MIMEMap
multimap< MIMEType, ExtensionType > MIMEMap
Definition: ContentType.h:50
YSLib::AddMIMEItems
YF_API void AddMIMEItems(MIMEBiMapping &, const ValueNode &, MIMEBiMapping::MIMEType &&={})
根据 NPLA1 节点内容增加 MIME 映射。
Definition: ContentType.cpp:62
ystdex::path
一般路径模板。
Definition: path.hpp:268
YF_API
#define YF_API
Definition: Platform.h:56
YSLib::MIMEBiMapping::DefDeMoveCtor
DefDeMoveCtor(MIMEBiMapping) void operator+
YSLib::MIMEBiMapping::ext_map
ExtensionMap ext_map
Definition: ContentType.h:53
YSLib::MIMEBiMapping::DefGetter
DefGetter(const ynothrow, const ExtensionMap &, ExtensionMap, ext_map) DefGetter(const ynothrow
ystdex::cpp2017::end
auto end(_tRange &c) -> decltype(c.end())
Definition: range.hpp:345
YSLib::ValueNode
值类型节点。
Definition: ValueNode.h:73
YSLib::MIMEBiMapping::inv_map
MIMEMap inv_map
Definition: ContentType.h:54
YSLib::MIMEBiMapping::ExtensionType
string ExtensionType
Definition: ContentType.h:47
YSLib::MIMEBiMapping
MIME 和文件扩展名双向映射。
Definition: ContentType.h:45
YSLib::MIMEBiMapping::MIMEBiMapping
MIMEBiMapping(std::initializer_list< _type > il)
Definition: ContentType.h:66
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:46
platform::containers::multimap
std::multimap< _tKey, _tMapped, _fComp, _tAlloc > multimap
Definition: Container.h:118
YModules.h
YSLib 用户界面模块配置文件。
YSLib::ynothrow
YB_PURE const _type size_t n ynothrow
Definition: YCoreUtilities.h:169
DefGetter
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:241
const
const Decapsulate const Decapsulate &y ynothrow ContextNode &ctx const
Definition: NPLA1Forms.cpp:1629
ystdex::cpp2017::string
basic_string< char > string
Definition: string.hpp:772
YSLib::MIMEBiMapping::ExtensionMap
multimap< ExtensionType, MIMEType > ExtensionMap
Definition: ContentType.h:49
ystdex::cpp2017::begin
auto begin(_tRange &c) -> decltype(c.begin())
Definition: range.hpp:323