YSTest  PreAlpha_b500_20140530
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
ContentType.cpp
浏览该文件的文档.
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 #include "YSLib/Service/YModules.h"
29 #include YFM_YSLib_Service_ContentType
30 
31 namespace YSLib
32 {
33 
34 void
35 MIMEBiMapping::operator+=(const pair<ExtensionType, MIMEType>& pr)
36 {
37  ext_map.insert(pr),
38  inv_map.insert(make_pair(pr.second, pr.first));
39 }
40 void
41 MIMEBiMapping::operator+=(const pair<MIMEType, ExtensionType>& pr)
42 {
43  ext_map.insert(make_pair(pr.second, pr.first)),
44  inv_map.insert(pr);
45 }
46 
47 void
48 MIMEBiMapping::operator-=(const pair<ExtensionType, MIMEType>& pr)
49 {
50  ext_map.insert(pr),
51  inv_map.insert(make_pair(pr.second, pr.first));
52 }
53 void
54 MIMEBiMapping::operator-=(const pair<MIMEType, ExtensionType>& pr)
55 {
56  ext_map.insert(make_pair(pr.second, pr.first)),
57  inv_map.insert(pr);
58 }
59 
60 
61 void
64 {
65  if(node.GetContainerPtr())
66  for(auto& nd : node)
67  try
68  {
69  pth.push_back(nd.GetName());
70  AddMIMEItems(m, nd, std::move(pth));
71  pth.pop_back();
72  }
73  catch(ystdex::bad_any_cast&)
74  {}
75  else
76  try
77  {
78  m += make_pair(Access<string>(node), !pth.empty()
80  pth.cbegin(), std::prev(pth.cend())} : pth);
81  }
82  catch(ystdex::bad_any_cast&)
83  {}
84 }
85 
86 } // namespace YSLib;
87 
ExtensionMap ext_map
Definition: ContentType.h:54
动态泛型转换失败异常。
Definition: any.h:741
YF_API bool IsPrefixedIndex(const string &, char= '$')
判断字符串是否是一个指定字符和非负整数的组合。
Definition: ValueNode.cpp:107
一般路径模板。
Definition: path.hpp:149
void operator-=(const pair< ExtensionType, MIMEType > &)
Definition: ContentType.cpp:48
void operator+=(const pair< MIMEType, ExtensionType > &)
Definition: ContentType.cpp:35
MIME 和文件扩展名双向映射。
Definition: ContentType.h:45
值类型节点。
Definition: ValueNode.h:45
YF_API void AddMIMEItems(MIMEBiMapping &, const ValueNode &, MIMEBiMapping::MIMEType &&={})
根据 NPLA1 节点内容增加 MIME 映射。
Definition: ContentType.cpp:62