fastdo  0.6.16
http_Vars.hpp
浏览该文件的文档.
1 #ifndef __HTTP_VARS_HPP__
2 #define __HTTP_VARS_HPP__
3 
4 namespace http
5 {
8 {
9  vemNone = 0,
10  vemName = 1,
11  vemValue = 2,
12  vemAll = 3,
13 };
14 
17 {
18 public:
22  Vars( winux::String const & varsData = "" );
23 
27  Vars( winux::Mixed const & vars );
28 
33  Vars( winux::Mixed * pVars, bool isNewAlloc = false );
34 
35  Vars( Vars const & other );
36  Vars & operator = ( Vars const & other );
37 
38  Vars( Vars && other );
39  Vars & operator = ( Vars && other );
40 
42  virtual ~Vars();
43 
45  void clear();
46 
48  winux::String toString( VarEncodeMode mode = vemAll ) const;
49 
50  winux::Mixed const & operator [] ( winux::String const & name ) const { return (*_pVars)[name]; }
51  winux::Mixed & operator [] ( winux::String const & name ) { return (*_pVars)[name]; }
52 
53  bool has( winux::String const & name ) const { return _pVars->has(name); }
54 
56  winux::Mixed & createVar( winux::String const & k );
57 
59  Vars & parse( winux::String const & varsData );
60 
64  template < typename _Ty >
65  _Ty get( winux::String const & name, _Ty defval = _Ty() ) const
66  {
67  return this->has(name) ? (*_pVars)[name].to<_Ty>() : std::move(defval);
68  }
69 
70  winux::Mixed & getVars() { return *_pVars; }
71  winux::Mixed const & getVars() const { return *_pVars; }
72 
73  winux::Mixed & exposeVars() { return *_pVars; }
74  winux::Mixed const & exposeVars() const { return *_pVars; }
75 
76 private:
77  winux::Mixed * _pVars; // 指向Mixed(Collection)
78  bool _isNewAlloc; // 是否为新分配的Mixed变量
79 };
80 
81 
82 } // namespace http
83 
84 
85 #endif // __HTTP_VARS_HPP__
#define HTTPWRAPPER_DLL
Definition: http_base.hpp:24
XString< tchar > String
Definition: utilities.hpp:261
bool has(winux::String const &name) const
Definition: http_Vars.hpp:53
winux::Mixed const & getVars() const
Definition: http_Vars.hpp:71
HTTP协议的相关简单类封装
Definition: http_base.hpp:32
变量类。可转为application/x-www-form-urlencoded类型字符串。可用于解析和设置get/post变量 ...
Definition: http_Vars.hpp:16
名称和值部分一起编码
Definition: http_Vars.hpp:12
VarEncodeMode
变量编码模式
Definition: http_Vars.hpp:7
值部分编码
Definition: http_Vars.hpp:11
winux::Mixed & exposeVars()
Definition: http_Vars.hpp:73
winux::Mixed & getVars()
Definition: http_Vars.hpp:70
混合体,能表示多种类型的值
Definition: utilities.hpp:1440
winux::Mixed const & exposeVars() const
Definition: http_Vars.hpp:74
不编码
Definition: http_Vars.hpp:9
名称部分编码
Definition: http_Vars.hpp:10