YSTest  PreAlpha_b500_20140530
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
ContentType.h
浏览该文件的文档.
1 /*
2  © 2013 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 #include YFM_YSLib_Adaptor_YContainer
35 
36 namespace YSLib
37 {
38 
46 {
47 public:
50  using ExtensionMap = multimap<ExtensionType, MIMEType>;
51  using MIMEMap = multimap<MIMEType, ExtensionType>;
52 
53 private:
56 
57 public:
59  template<typename _tIn>
60  MIMEBiMapping(_tIn first, _tIn last)
61  {
62  std::for_each(first, last, [this](decltype(*first)& pr){
63  *this += pr;
64  });
65  }
66  template<typename _type>
67  MIMEBiMapping(std::initializer_list<_type> il)
68  : MIMEBiMapping(il.begin(), il.end())
69  {}
70 
72 
73  void
74  operator+=(const pair<ExtensionType, MIMEType>&);
75  void
76  operator+=(const pair<MIMEType, ExtensionType>&);
77 
78  void
79  operator-=(const pair<ExtensionType, MIMEType>&);
80  void
81  operator-=(const pair<MIMEType, ExtensionType>&);
82 
83  DefGetter(const ynothrow, const ExtensionMap&, ExtensionMap, ext_map)
84  DefGetter(const ynothrow, const MIMEMap&, MIMEMap, inv_map)
85 };
86 
87 
92 YF_API void
93 AddMIMEItems(MIMEBiMapping&, const ValueNode&, MIMEBiMapping::MIMEType&& = {});
94 
95 } // namespace YSLib;
96 
97 #endif
98 
ExtensionMap ext_map
Definition: ContentType.h:54
multimap< ExtensionType, MIMEType > ExtensionMap
Definition: ContentType.h:50
static auto first(const _tIterator &i) -> decltype((i->first))
Definition: iterator.hpp:759
#define DefDeCtor(_t)
Definition: YBaseMacro.h:131
一般路径模板。
Definition: path.hpp:149
抽象路径模板。
#define YF_API
Definition: Platform.h:64
MIMEBiMapping(std::initializer_list< _type > il)
Definition: ContentType.h:67
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:180
MIME 和文件扩展名双向映射。
Definition: ContentType.h:45
#define DefDeMoveCtor(_t)
Definition: YBaseMacro.h:141
#define ynothrow
YSLib 无异常抛出保证:若支持 noexcept 关键字, 指定特定的 noexcept 异常规范。
Definition: ydef.h:514
GSStringTemplate< char >::basic_string string
Definition: ycont.h:164
值类型节点。
Definition: ValueNode.h:45
multimap< MIMEType, ExtensionType > MIMEMap
Definition: ContentType.h:51
YF_API void AddMIMEItems(MIMEBiMapping &, const ValueNode &, MIMEBiMapping::MIMEType &&={})
根据 NPLA1 节点内容增加 MIME 映射。
Definition: ContentType.cpp:62