fastdo  0.6.8
utilities.hpp
浏览该文件的文档.
1 #ifndef __UTILITIES_HPP__
2 #define __UTILITIES_HPP__
3 //
4 // utilities 提供基础的宏,模板,类,函数
5 //
6 
7 // 各平台条件编译宏检测
8 #include "system_detection.inl"
9 
10 #if _MSC_VER > 0 && _MSC_VER < 1201
11 #pragma warning( disable: 4786 )
12 #endif
13 #if _MSC_VER > 0
14 #pragma warning( disable : 4996 )
15 #endif
16 
17 #include <string>
18 #include <sstream>
19 #include <vector>
20 #include <map>
21 #include <tuple>
22 #include <queue>
23 #include <functional>
24 #include <algorithm>
25 #include <assert.h>
26 #include <stdlib.h>
27 #include <string.h>
28 
29 #if defined(OS_WIN)
30 #include <windows.h>
31 #endif
32 
34 namespace winux
35 {
36 // 一些宏定义 ----------------------------------------------------------------------------------
37 /* Dll相关宏定义:
38  WINUX_DLL_USE - 此宏开关表示有DLL参与,包括生成DLL或者导入DLL,不定义此宏和一般的使用源码没区别
39  WINUX_DLL_EXPORTS - 此宏开关表示是生成DLL(dllexport)还是导入DLL(dllimport),linux平台下忽略
40  WINUX_DLL - 标记函数、类、变量,用于标明其要从DLL导出还是导入,linux平台下忽略
41  WINUX_API - 标记函数调用约定,Win下Dll参与时为stdcall,否则为空白默认,linux平台下忽略
42  WINUX_FUNC_DECL - 标记函数声明
43  WINUX_FUNC_IMPL - 标记函数实现 */
44 #ifdef WINUX_DLL_USE
45  #if defined(_MSC_VER) || defined(WIN32)
46  #pragma warning( disable: 4251 )
47  #pragma warning( disable: 4275 )
48  #ifdef WINUX_DLL_EXPORTS
49  #define WINUX_DLL __declspec(dllexport)
50  #else
51  #define WINUX_DLL __declspec(dllimport)
52  #endif
53 
54  #define WINUX_API __stdcall
55  #else
56  #define WINUX_DLL
57  #define WINUX_API
58  #endif
59 #else
60  #define WINUX_DLL
61  #define WINUX_API
62 #endif
63 
64 #define WINUX_FUNC_DECL(ret) WINUX_DLL ret WINUX_API
65 #define WINUX_FUNC_IMPL(ret) ret WINUX_API
66 
67 #ifndef countof
68  #define countof(arr) ( sizeof(arr) / sizeof(arr[0]) )
69 #endif
70 
71 #ifndef TEXT
72  #ifdef UNICODE
73  #define TEXT(__x) L##__x
74  #else
75  #define TEXT(__x) __x
76  #endif
77 #endif
78 
79 // 禁止类的对象赋值/拷贝构造
80 // DISABLE_OBJECT_COPY
81 #define DISABLE_OBJECT_COPY( clsname ) private:\
82 clsname( clsname const & ) = delete;\
83 clsname & operator = ( clsname const & ) = delete;
84 
85 // C语言缓冲区转换为AnsiString二进制串
86 #define CBufferToAnsiString( buf, size ) winux::AnsiString( (char const *)(buf), (size_t)(size) )
87 // C语言缓冲区转换为Buffer对象
88 #define CBufferToBuffer( buf, size ) winux::Buffer( (void *)(buf), (size_t)(size), false )
89 // C语言缓冲区转换为Buffer对象(PEEK模式)
90 #define CBufferToBufferPeek( buf, size ) winux::Buffer( (void *)(buf), (size_t)(size), true )
91 
92 // 如果指针非NULL
93 // IF_PTR
94 #define IF_PTR(ptr) if ( (ptr) != NULL ) (ptr)
95 // ASSIGN_PTR
96 #define ASSIGN_PTR(ptr) if ( (ptr) != NULL ) (*(ptr))
97 
98 // 不使用一个变量
99 #ifndef UNUSED
100 #define UNUSED(s)
101 #endif
102 
103 // 给类添加一个属性,和相关的数据成员,自动添加get/set方法
104 #define DEFINE_ATTR_MEMBER( ty, name, memname ) \
105 public:\
106  ty const & get##name() const { return this->##memname; }\
107  void set##name( ty const & v ) { this->##memname = v; }\
108 private:\
109  ty memname;
110 
111 // 给类添加一个只读属性,和相关的数据成员,自动添加get方法
112 #define DEFINE_ATTR_MEMBER_READONLY( ty, name, memname ) \
113 public:\
114  ty const & get##name() const { return this->##memname; }\
115 private:\
116  ty memname;
117 
118 // 给类添加一个属性,自动添加get/set方法
119 #define DEFINE_ATTR( ty, name, getcode, setcode ) \
120 public:\
121  ty get##name() const { getcode; }\
122  void set##name( ty const & _VAL_ ) { setcode; }
124 // 给类添加一个只读属性,自动添加get方法
125 #define DEFINE_ATTR_READONLY( ty, name, getcode ) \
126 public:\
127  ty get##name() const { getcode; }
128 
129 // 给类定义一个NewInstance静态方法
130 #define DEFINE_FUNC_NEWINSTANCE( cls, ret, paramtypes, params ) \
131 inline static ret * NewInstance##paramtypes \
132 { \
133  return new cls##params;\
134 }
135 
136 // 给类定义一个自定义事件相关的成员和函数,默认实现
137 #define DEFINE_CUSTOM_EVENT(evtname, paramtypes, calledparams) \
138 public: \
139  using evtname##HandlerFunction = std::function< void paramtypes >; \
140  void on##evtname##Handler( evtname##HandlerFunction handler ) \
141  { \
142  this->_##evtname##Handler = handler; \
143  } \
144 protected: \
145  evtname##HandlerFunction _##evtname##Handler; \
146  virtual void on##evtname paramtypes \
147  { \
148  if ( this->_##evtname##Handler ) this->_##evtname##Handler calledparams; \
149  }
150 
151 // 给类定义一个自定义事件相关的成员和函数,带返回值并自己实现
152 #define DEFINE_CUSTOM_EVENT_RETURN_EX(ret, evtname, paramtypes) \
153 public: \
154  using evtname##HandlerFunction = std::function< ret paramtypes >; \
155  void on##evtname##Handler( evtname##HandlerFunction handler ) \
156  { \
157  this->_##evtname##Handler = handler; \
158  } \
159 protected: \
160  evtname##HandlerFunction _##evtname##Handler; \
161  virtual ret on##evtname paramtypes
162 
163 
164 // 判断GCC版本大于给定版本
165 #define GCC_VERSION_GREAT_THAN(Major,Minor,Patchlevel) \
166 ( __GNUC__ > Major || ( __GNUC__ == Major && ( __GNUC_MINOR__ > Minor || ( __GNUC_MINOR__ == Minor && __GNUC_PATCHLEVEL__ > Patchlevel ) ) ) )
167 
168 // WINUX基本类型 -----------------------------------------------------------------------------------
169 typedef int int32;
170 typedef unsigned int uint, uint32;
171 typedef unsigned long ulong;
172 typedef short int16;
173 typedef unsigned short ushort, uint16;
174 typedef char int8;
175 typedef unsigned char uint8;
176 
177 typedef char16_t char16;
178 typedef char32_t char32;
179 
180 typedef intptr_t offset_t, ssize_t;
181 typedef size_t usize_t;
182 
183 #if defined(CL_VC)
184 typedef wchar_t wchar;
185 typedef unsigned __int64 uint64;
186 typedef unsigned __int64 ulonglong;
187 typedef __int64 int64;
188 typedef __int64 longlong;
189 #else
190 typedef wchar_t wchar;
191 typedef unsigned long long uint64;
192 typedef unsigned long long ulonglong;
193 typedef long long int64;
194 typedef long long longlong;
195 #endif
196 
197 //#ifdef UNICODE
198 //typedef wchar tchar;
199 //#else
200 typedef char tchar;
201 //#endif
202 
203 #ifndef byte
204 typedef unsigned char byte;
205 #endif
206 
207 class Mixed;
208 // STL wrappers
209 template < typename _ChTy >
210 using XString = std::basic_string<_ChTy>;
211 
217 
218 template < typename _ChTy >
219 using XStringArray = std::vector< XString<_ChTy> >;
220 
228 
229 typedef std::map<String, String> StringStringMap;
230 typedef std::pair<String, String> StringStringPair;
231 
232 typedef std::vector<Mixed> MixedArray;
233 typedef std::map<String, Mixed> StringMixedMap;
234 typedef std::pair<String, Mixed> StringMixedPair;
235 //typedef std::map<Mixed, Mixed> MixedMixedMap;
236 //typedef std::pair<Mixed, Mixed> MixedMixedPair;
237 
238 // WINUX常用常量 ---------------------------------------------------------------------------
240 static constexpr size_t const npos = static_cast<size_t>(-1);
241 
242 // 模板元编程支持 ---------------------------------------------------------------------------
244 template < typename _Ty >
245 inline static constexpr _Ty InvertByteOrder( _Ty v )
246 {
247  _Ty v2 = 0;
248  for ( int i = 0; i < sizeof(_Ty); ++i ) v2 |= ( ( v >> i * 8 ) & 0xFFU ) << ( sizeof(_Ty) - 1 - i ) * 8;
249  return v2;
250 }
251 
253 inline static bool IsLittleEndian()
254 {
255  constexpr winux::uint16 judgeHostOrder = 0x0102;
256  return *(winux::byte*)&judgeHostOrder == 0x02;
257 }
258 
260 inline static bool IsBigEndian()
261 {
262  constexpr winux::uint16 judgeHostOrder = 0x0102;
263  return *(winux::byte*)&judgeHostOrder == 0x01;
264 }
265 
267 template < typename _MAP, typename _KEY >
268 inline bool isset( _MAP const & m, _KEY const & k )
269 {
270  return m.find(k) != m.end();
271 }
272 
274 template < typename _Ty >
275 std::vector<_Ty> ToArray( _Ty * arr, uint count )
276 {
277  return std::vector<_Ty>( arr, arr + count );
278 }
279 
280 template < typename _Ty, uint _N >
281 std::vector<_Ty> ToArray( _Ty (&arr)[_N] )
282 {
283  return std::vector<_Ty>( arr, arr + _N );
284 }
285 
289 template < typename _Fx, typename... _ArgType >
290 int VoidReturnInt( _Fx fn, _ArgType&& ...arg )
291 {
292  fn( std::forward<_ArgType>(arg)... );
293  return 1;
294 }
295 
297 template < uint64 n > struct Bin0
298 {
299  enum : uint64 { val = ( Bin0< n / 8 >::val << 1 ) + n % 8 };
300 };
301 template <> struct Bin0<0>
302 {
303  enum : uint64 { val = 0 };
304 };
305 
306 // 二进制数 macro包装
307 #define BinVal(x) winux::Bin0<0##x>::val
308 
309 // 引用参数包装
310 template < typename _Ty >
311 class RefParam
312 {
313  _Ty & _r;
314 public:
315  typedef _Ty ParamType;
316  typedef _Ty & ParamTypeRef;
317 
318  explicit RefParam( ParamTypeRef r ) : _r(r) { }
319  operator ParamTypeRef () { return _r; }
320 };
321 
323 template < typename _Ty >
324 RefParam<_Ty> Ref( _Ty & r )
325 {
326  return RefParam<_Ty>(r);
327 }
328 
330 template < size_t... _Index >
331 struct IndexSequence { };
332 
333 // 构建一个IndexSequence< 0, 1, 2, ..., _Num - 1 >
334 template < size_t _Num, typename _IdxSeq = IndexSequence<> >
336 
337 template < size_t _Num, size_t... _Index >
338 struct MakeIndexSequence< _Num, IndexSequence<_Index...> > : MakeIndexSequence< _Num - 1, IndexSequence< _Index..., sizeof...(_Index) > > { };
339 
340 template < size_t... _Index >
341 struct MakeIndexSequence< 0, IndexSequence<_Index...> >
342 {
343  using Type = IndexSequence<_Index...>;
344 };
345 
347 #include "func_traits.inl"
348 
350 #include "func_runable.inl"
351 
353 #include "func_invoker.inl"
354 
356 template < typename _PfnType, _PfnType pfn >
358 {
359  template < typename... _ArgType >
360  static typename FuncTraits<_PfnType>::ReturnType func( _ArgType&& ...arg )
361  {
362  return (*pfn)( std::forward<_ArgType>(arg)... );
363  }
364 };
365 
367 template < typename _KTy, typename _VTy >
369 {
370  std::map< _KTy, _VTy > * _m;
371 public:
372  MapAssigner( std::map< _KTy, _VTy > * m ) : _m(m) { }
373  MapAssigner & operator()( _KTy const & k, _VTy const & v )
374  {
375  (*_m)[k] = v;
376  //_m->insert( std::pair< _KTy, _VTy >( k, v ) );
377  return *this;
378  }
379  operator std::map< _KTy, _VTy > & () { return *_m; }
380 };
381 
383 template < typename _Ty >
385 {
386  std::vector<_Ty> * _a;
387 public:
388  ArrayAssigner( std::vector<_Ty> * a ) : _a(a) { }
389  ArrayAssigner & operator () ( _Ty const & v )
390  {
391  _a->push_back(v);
392  return *this;
393  }
394  operator std::vector<_Ty> & () { return *_a; }
395 };
396 
398 template < typename _KTy, typename _VTy >
399 MapAssigner< _KTy, _VTy > Assign( std::map< _KTy, _VTy > * m )
400 {
401  return MapAssigner< _KTy, _VTy >(m);
402 }
403 
405 template < typename _Ty >
406 ArrayAssigner<_Ty> Assign( std::vector<_Ty> * a )
407 {
408  return ArrayAssigner<_Ty>(a);
409 }
410 
416 template < typename _TargetCls >
418 {
419 private:
420  _TargetCls * _data;
421 
422  MembersWrapper( MembersWrapper const & other ) = delete;
423 public:
424  MembersWrapper() : _data(nullptr) { }
425 
427  MembersWrapper & operator = ( MembersWrapper const & other )
428  {
429  if ( &other != this )
430  {
431  *_data = *other._data;
432  }
433  return *this;
434  }
435 
436 #ifndef MOVE_SEMANTICS_DISABLED
438  {
439  _data = other._data;
440  other._data = nullptr;
441  }
443  MembersWrapper & operator = ( MembersWrapper && other )
444  {
445  if ( &other != this )
446  {
447  this->destroy();
448  _data = other._data;
449  other._data = nullptr;
450  }
451  return *this;
452  }
453 #endif
454 
456  void destroy()
457  {
458  if ( _data )
459  {
460  delete (_TargetCls *)_data;
461  _data = nullptr;
462  }
463  }
464 
466  template < typename... _ArgType >
467  void create( _ArgType&&... arg )
468  {
469  this->destroy();
470  _data = new _TargetCls( std::forward<_ArgType>(arg)... );
471  }
472 
473  _TargetCls * get() const
474  {
475  return _data;
476  }
477 
478  _TargetCls * operator -> ()
479  {
480  return _data;
481  }
482  _TargetCls const * operator -> () const
483  {
484  return _data;
485  }
486 
487  operator _TargetCls & ()
488  {
489  return *_data;
490  }
491  operator _TargetCls const & () const
492  {
493  return *_data;
494  }
495 
496  operator bool() const
497  {
498  return _data != nullptr;
499  }
500 };
501 
502 // ----------------------------------------------------------------------------------------
503 
505 class Error : public std::exception
506 {
507 private:
508  int _errType;
509  AnsiString _errStr;
510 public:
511  Error() throw() : _errType(0) { }
512  Error( int errType, AnsiString const & errStr ) throw() : _errType(errType), _errStr(errStr) { }
513  virtual ~Error() throw() { }
514  virtual int getErrType() const throw() { return _errType; }
515  virtual char const * what() const throw() { return _errStr.c_str(); }
516 };
517 
519 WINUX_FUNC_DECL(bool) ValueIsInArray( StringArray const & arr, String const & val, bool caseInsensitive = false );
520 
522 WINUX_FUNC_DECL(int) Random( int n1, int n2 );
523 
524 // -------------------------------------------------------------------------------
525 class GrowBuffer;
526 
529 {
530 public:
532  Buffer();
533 
537  Buffer( void const * buf, size_t size, bool isPeek = false );
538 
542  Buffer( AnsiString const & data, bool isPeek = false );
543 
544  virtual ~Buffer();
545 
546  Buffer( Buffer const & other );
547 
548  Buffer & operator = ( Buffer const & other );
549 
550 #ifndef MOVE_SEMANTICS_DISABLED
551 
552  Buffer( Buffer && other );
554  Buffer & operator = ( Buffer && other );
556  Buffer( GrowBuffer && other );
558  Buffer & operator = ( GrowBuffer && other );
559 #endif
560 
562  void setBuf( void const * buf, size_t size, size_t capacity, bool isPeek );
563 
565  void setBuf( void const * buf, size_t size, bool isPeek ) { this->setBuf( buf, size, size, isPeek ); }
566 
568  void alloc( size_t capacity, bool setDataSize = true );
569 
573  void realloc( size_t newCapacity );
574 
576  bool peekCopy( bool copyCapacity = false );
577 
579  void * detachBuf( size_t * size = nullptr );
580 
582  void free();
583 
585  void * getBuf() const { return _buf; }
586 
588  template < typename _Ty >
589  _Ty * getBuf() const { return reinterpret_cast<_Ty *>(_buf); }
590 
592  void * get() const { return _buf; }
593 
595  template < typename _Ty >
596  _Ty * get() const { return reinterpret_cast<_Ty *>(_buf); }
597 
599  winux::byte & operator [] ( size_t i ) { return reinterpret_cast<winux::byte *>(_buf)[i]; }
601  winux::byte const & operator [] ( size_t i ) const { return reinterpret_cast<winux::byte const *>(_buf)[i]; }
603  winux::byte & get( size_t i ) { return reinterpret_cast<winux::byte *>(_buf)[i]; }
605  winux::byte const & get( size_t i ) const { return reinterpret_cast<winux::byte const *>(_buf)[i]; }
606 
607  winux::byte * begin() { return reinterpret_cast<winux::byte *>(_buf); }
608  winux::byte * end() { return reinterpret_cast<winux::byte *>(_buf) + _dataSize; }
609  winux::byte const * begin() const { return reinterpret_cast<winux::byte *>(_buf); }
610  winux::byte const * end() const { return reinterpret_cast<winux::byte *>(_buf) + _dataSize; }
611 
613  size_t getSize() const { return _dataSize; }
614 
616  size_t size() const { return _dataSize; }
617 
619  void _setSize( size_t dataSize ) { _dataSize = ( dataSize > _capacity ? _capacity : dataSize ); }
620 
622  size_t getCapacity() const { return _capacity; }
623 
625  size_t capacity() const { return _capacity; }
626 
628  operator bool() const { return _buf != NULL; }
629 
631  template < typename _ChTy >
633  {
634  typedef typename XString<_ChTy>::value_type CharType;
635  return XString<_ChTy>( (CharType*)_buf, _dataSize / sizeof(CharType) );
636  }
637 
639  AnsiString toAnsi() const { return this->toString<AnsiString::value_type>(); }
640 
642  UnicodeString toUnicode() const { return this->toString<UnicodeString::value_type>(); }
643 
644 public:
645  static void * _Alloc( size_t size );
646  static void * _Realloc( void * p, size_t newSize );
647  static void _Free( void * p );
648 
649 protected:
650  void * _buf;
651  size_t _dataSize;
652  size_t _capacity;
653  bool _isPeek;
654 
655  friend class GrowBuffer;
656 };
657 
660 {
661 public:
663  explicit GrowBuffer( size_t capacity = 0 );
664  GrowBuffer( GrowBuffer const & other );
665  GrowBuffer & operator = ( GrowBuffer const & other );
666  explicit GrowBuffer( Buffer const & other );
667  GrowBuffer & operator = ( Buffer const & other );
668 
669 #ifndef MOVE_SEMANTICS_DISABLED
670 
671  GrowBuffer( GrowBuffer && other );
673  GrowBuffer & operator = ( GrowBuffer && other );
675  GrowBuffer( Buffer && other );
677  GrowBuffer & operator = ( Buffer && other );
678 #endif
679 
681  void append( void const * data, size_t size );
682 
684  void append( AnsiString const & data ) { this->append( data.c_str(), data.size() ); }
685 
687  void append( Buffer const & data ) { this->append( data.getBuf(), data.getSize() ); }
688 
690  template < typename _PodType, size_t _Size = sizeof(_PodType) >
691  void append( _PodType const & data ) { this->append( &data, _Size ); }
692 
694  template < typename _PodType, size_t _Count >
695  void append( _PodType const (&data)[_Count] ) { this->append( &data, _Count * sizeof(data[0]) ); }
696 
698  template < typename _PodType >
699  void append( std::initializer_list<_PodType> list )
700  {
701  for ( auto const & e : list )
702  {
703  this->append< _PodType, sizeof(e) >(e);
704  }
705  }
706 
708  void erase( size_t start, size_t count = (size_t)-1 );
709 
710 protected:
711  friend class Buffer;
712 };
713 
714 // 混合体相关 ------------------------------------------------------------------------------
716 class MixedError : public Error
717 {
718 public:
719  enum
720  {
726  };
727 
728  MixedError( int errType, AnsiString const & errStr ) throw() : Error( errType, errStr ) { }
729 };
730 
732 struct $a
733 {
734  std::initializer_list<Mixed> _list;
735  $a( std::initializer_list<Mixed> list ) : _list( std::move(list) )
736  {
737  }
738 };
739 
741 struct $c
742 {
743  std::initializer_list< std::pair< Mixed, Mixed > > _list;
744  $c( std::initializer_list< std::pair< Mixed, Mixed > > list ) : _list( std::move(list) )
745  {
746  }
747 };
748 
751 {
752 public:
753  enum MixedType : ushort
754  {
755  #define MixedType_ENUM_ITEM(item) item,
756  #define MixedType_ENUM_ITEMSTRING(item) #item,
757  #define MixedType_ENUM_ITEMLIST(_)\
758  _(MT_NULL)\
759  _(MT_BOOLEAN)\
760  _(MT_BYTE)\
761  _(MT_SHORT) _(MT_USHORT)\
762  _(MT_INT) _(MT_UINT)\
763  _(MT_LONG) _(MT_ULONG)\
764  _(MT_INT64) _(MT_UINT64)\
765  _(MT_FLOAT) _(MT_DOUBLE)\
766  _(MT_ANSI) _(MT_UNICODE)\
767  _(MT_ARRAY) \
768  _(MT_COLLECTION) \
769  _(MT_BINARY)
771  MixedType_ENUM_ITEMLIST(MixedType_ENUM_ITEM)
772  };
773 
775  static String const & TypeString( MixedType type );
777  class WINUX_DLL MixedLess
778  {
779  public:
780  bool operator () ( Mixed const & v1, Mixed const & v2 ) const;
781  };
783  typedef std::map< Mixed, Mixed, MixedLess > MixedMixedMap;
784  typedef MixedMixedMap::value_type MixedMixedPair;
786  MixedType _type;
787 
788  union
789  {
790  double _dblVal;
791  uint64 _ui64Val;
792  int64 _i64Val;
793  float _fltVal;
794  ulong _ulVal;
795  long _lVal;
796  uint _uiVal;
797  int _iVal;
798  ushort _ushVal;
799  short _shVal;
800  byte _btVal;
801  bool _boolVal;
802  struct // 字符串
803  {
804  union
805  {
806  AnsiString * _pStr;
807  UnicodeString * _pWStr;
808  };
809  };
810  struct // Array or Collection
811  {
812  MixedArray * _pArr;
813  MixedMixedMap * _pMap;
814  };
815  struct // 二进制数据
816  {
817  Buffer * _pBuf;
818  };
819  };
820 
821 public:
822  Mixed();
823  Mixed( AnsiString const & str );
824  Mixed( UnicodeString const & str );
825  Mixed( char const * str, size_t len = npos );
826  Mixed( wchar const * str, size_t len = npos );
827 
828  Mixed( bool boolVal );
829  Mixed( byte btVal );
830  Mixed( short shVal );
831  Mixed( ushort ushVal );
832  Mixed( int iVal );
833  Mixed( uint uiVal );
834  Mixed( long lVal );
835  Mixed( ulong ulVal );
836  Mixed( float fltVal );
837  Mixed( int64 i64Val );
838  Mixed( uint64 ui64Val );
839  Mixed( double dblVal );
840 
841  Mixed( Buffer const & buf );
842  Mixed( void const * binaryData, size_t size, bool isPeek = false );
843 
844  // Array构造函数 -----------------------------------------------------------------------
846  Mixed( Mixed * arr, size_t count );
847 
849  template < typename _Ty >
850  Mixed( std::vector<_Ty> const & arr )
851  {
852  _zeroInit();
853  this->_type = MT_ARRAY;
854  this->_pArr = new MixedArray( arr.size() );
855  size_t i;
856  for ( i = 0; i < arr.size(); ++i )
857  {
858  this->_pArr->at(i) = arr[i];
859  }
860  }
861 
863  template < typename _Ty, size_t _N >
864  Mixed( _Ty (&arr)[_N] )
865  {
866  _zeroInit();
867  this->_type = MT_ARRAY;
868  this->_pArr = new MixedArray(_N);
869  size_t i;
870  for ( i = 0; i < _N; ++i )
871  {
872  this->_pArr->at(i) = arr[i];
873  }
874  }
875 
877  Mixed( std::initializer_list<Mixed> list );
878 
880  Mixed( $a arr );
881 
882  // Collection构造函数 ------------------------------------------------------------------
884  template < typename _KTy, typename _VTy, typename _Pr, typename _Alloc >
885  Mixed( std::map< _KTy, _VTy, _Pr, _Alloc > const & m )
886  {
887  _zeroInit();
888  this->assign< _KTy, _VTy, _Pr, _Alloc >(m);
889  }
890 
892  template < typename _KTy, typename _VTy, size_t _Count >
893  Mixed( std::pair< _KTy, _VTy > (&pairs)[_Count] )
894  {
895  _zeroInit();
896  this->assign< _KTy, _VTy, _Count >(pairs);
897  }
898 
900  template < typename _KTy, typename _VTy, size_t _Count >
901  Mixed( _KTy (&keys)[_Count], _VTy (&vals)[_Count] )
902  {
903  _zeroInit();
904  this->assign< _KTy, _VTy, _Count >( keys, vals );
905  }
906 
908  Mixed( $c coll );
909 
911  ~Mixed();
912 
914  Mixed( Mixed const & other );
916  Mixed & operator = ( Mixed const & other );
917 
918 #ifndef MOVE_SEMANTICS_DISABLED
919 
920  Mixed( Mixed && other );
922  Mixed & operator = ( Mixed && other );
923 
924  Mixed( Buffer && buf );
925  void assign( Buffer && buf );
926 
927  Mixed( GrowBuffer && buf );
928  void assign( GrowBuffer && buf );
929 
930 #endif
931 
933  void free();
934 
936  MixedType type() const { return this->_type; }
938  String const & typeString() const { return TypeString(this->_type); }
939 
940  // 取得相关类型的引用 --------------------------------------------------------------------
941  template < typename _ChTy >
942  XString<_ChTy> & refString();
943  template < typename _ChTy >
944  XString<_ChTy> const & refString() const;
945  #include "mixed_ref_specified_type.inl"
946 
947  // 类型转换 ----------------------------------------------------------------------------
948  operator AnsiString() const;
949  operator UnicodeString() const;
950  operator Buffer() const;
951  operator bool() const;
952  operator byte() const;
953  operator short() const;
954  operator ushort() const;
955  operator int() const;
956  operator uint() const;
957  operator long() const;
958  operator ulong() const;
959  operator float() const;
960  operator int64() const;
961  operator uint64() const;
962  operator double() const;
963 
964  template < typename _ChTy >
965  XString<_ChTy> toString() const ; // { throw MixedError( MixedError::meCantConverted, AnsiString("Can't convert to ") + typeid(XString<_ChTy>).name() ); }
966  AnsiString toAnsi() const { return this->operator AnsiString(); }
967  UnicodeString toUnicode() const { return this->operator UnicodeString(); }
968  Buffer toBuffer() const { return this->operator Buffer(); }
969  bool toBool() const { return this->operator bool(); }
970  byte toByte() const { return this->operator winux::byte(); }
971  short toShort() const { return this->operator short(); }
972  ushort toUShort() const { return this->operator winux::ushort(); }
973  int toInt() const { return this->operator int(); }
974  uint toUInt() const { return this->operator winux::uint(); }
975  long toLong() const { return this->operator long(); }
976  ulong toULong() const { return this->operator winux::ulong(); }
977  float toFloat() const { return this->operator float(); }
978  int64 toInt64() const { return this->operator winux::int64(); }
979  uint64 toUInt64() const { return this->operator winux::uint64(); }
980  double toDouble() const { return this->operator double(); }
981 
982  // 比较操作符 --------------------------------------------------------------------------
983  bool operator == ( Mixed const & other ) const;
984  bool operator < ( Mixed const & other ) const;
985  bool operator != ( Mixed const & other ) const { return !this->operator == (other); }
986  bool operator > ( Mixed const & other ) const { return !this->operator <= (other); }
987  bool operator >= ( Mixed const & other ) const { return !this->operator < (other); }
988  bool operator <= ( Mixed const & other ) const { return this->operator < (other) || this->operator == (other); }
989 
990  // 判定特殊类型 -------------------------------------------------------------------------
991  bool isNull() const { return this->_type == MT_NULL; }
992  bool isArray() const { return this->_type == MT_ARRAY; }
993  bool isCollection() const { return this->_type == MT_COLLECTION; }
994  bool isContainer() const { return this->_type == MT_ARRAY || this->_type == MT_COLLECTION; }
995  bool isBinary() const { return this->_type == MT_BINARY; }
996  bool isNumeric() const { return this->_type > MT_NULL && this->_type < MT_ANSI; }
997  bool isInteger() const { return this->isNumeric() && this->_type != MT_FLOAT && this->_type != MT_DOUBLE; }
998  bool isAnsi() const { return this->_type == MT_ANSI; }
999  bool isUnicode() const { return this->_type == MT_UNICODE; }
1000  bool isString() const { return this->_type == MT_ANSI || this->_type == MT_UNICODE; }
1001 
1002  // 创建相关类型 -------------------------------------------------------------------------
1004  template < typename _ChTy >
1005  Mixed & createString();
1007  Mixed & createAnsi();
1009  Mixed & createUnicode();
1011  Mixed & createArray( size_t count = 0 );
1013  Mixed & createCollection();
1015  Mixed & createBuffer( size_t size = 0 );
1016 
1017  // Array/Collection有关的操作 ----------------------------------------------------------
1018 
1022  template < typename _Ty >
1023  size_t getArray( std::vector<_Ty> * arr ) const
1024  {
1025  if ( !this->isArray() && !this->isCollection() ) throw MixedError( MixedError::meUnexpectedType, TypeString(this->_type) + " can't support getArray()" );
1026  MixedArray::const_iterator it;
1027  for ( it = this->_pArr->begin(); it != this->_pArr->end(); ++it )
1028  arr->push_back(*it);
1029  return arr->size();
1030  }
1031 
1035  template < typename _KTy >
1036  size_t getKeys( std::vector<_KTy> * keys ) const
1037  {
1038  if ( !this->isCollection() ) throw MixedError( MixedError::meUnexpectedType, TypeString(this->_type) + " can't support getKeys()" );
1039  MixedArray::const_iterator it;
1040  for ( it = this->_pArr->begin(); it != this->_pArr->end(); ++it )
1041  keys->push_back(*it);
1042  return keys->size();
1043  }
1044 
1048  template < typename _KTy, typename _VTy >
1049  size_t getMap( std::map< _KTy, _VTy > * m ) const
1050  {
1051  if ( !this->isCollection() ) throw MixedError( MixedError::meUnexpectedType, TypeString(this->_type) + " can't support getMap()" );
1052  MixedMixedMap::const_iterator it;
1053  for ( it = this->_pMap->begin(); it != this->_pMap->end(); ++it )
1054  (*m)[(_KTy)it->first] = (_VTy)it->second;
1055  return m->size();
1056  }
1057 
1061  bool isEmpty() const { return this->getCount() == 0; }
1062 
1066  size_t getCount() const
1067  {
1068  if ( ( this->isArray() || this->isCollection() ) && this->_pArr != NULL )
1069  return this->_pArr->size();
1070  return 0;
1071  }
1072 
1074  Mixed & operator [] ( Mixed const & k );
1076  Mixed const & operator [] ( Mixed const & k ) const;
1078  template < typename _ChTy >
1079  Mixed & operator [] ( _ChTy const * k ) { return this->operator[]( Mixed(k) ); }
1081  template < typename _ChTy >
1082  Mixed const & operator [] ( _ChTy const * k ) const { return this->operator[]( Mixed(k) ); }
1083 
1085  template < typename _Ty >
1086  _Ty get( Mixed const & k, Mixed const & defval = Mixed() ) const { return (_Ty)this->get( k, defval ); }
1087 
1089  Mixed const & get( Mixed const & k, Mixed const & defval = Mixed() ) const;
1090 
1092  MixedMixedMap::value_type & getPair( size_t i );
1094  MixedMixedMap::value_type const & getPair( size_t i ) const;
1096  class CollectionAssigner
1097  {
1098  public:
1099  CollectionAssigner( Mixed * mx ) : _mx(mx) { }
1100  CollectionAssigner & operator()( Mixed const & k, Mixed const & v )
1101  {
1102  if ( _mx->isCollection() )
1103  {
1104  _mx->_addUniqueKey(k);
1105  _mx->_pMap->operator[](k) = v;
1106  }
1107  return *this;
1108  }
1109  operator Mixed & () { return *_mx; }
1110 
1111  private:
1112  Mixed * _mx;
1113  };
1114 
1118  CollectionAssigner addPair()
1119  {
1120  if ( this->_type != MT_COLLECTION ) this->createCollection();
1121  return CollectionAssigner(this);
1122  }
1123 
1125  Mixed & addPair( Mixed const & k, Mixed const & v );
1127  class ArrayAssigner
1128  {
1129  public:
1130  ArrayAssigner( Mixed * mx ) : _mx(mx) { }
1131  ArrayAssigner & operator()( Mixed const & v )
1132  {
1133  if ( _mx->isArray() )
1134  {
1135  _mx->_pArr->push_back(v);
1136  }
1137  return *this;
1138  }
1139  operator Mixed & () { return *_mx; }
1140 
1141  private:
1142  Mixed * _mx;
1143  };
1144 
1148  ArrayAssigner add()
1149  {
1150  if ( this->_type != MT_ARRAY ) this->createArray();
1151  return ArrayAssigner(this);
1152  }
1153 
1155  size_t add( Mixed const & v );
1156 
1158  size_t addUnique( Mixed const & v );
1159 
1161  void del( Mixed const & k );
1162 
1166  bool has( Mixed const & ek ) const;
1167 
1171  Mixed & merge( Mixed const & v );
1172 
1176  Mixed & reverse();
1177 
1178  // Buffer有关操作 --------------------------------------------------------------------------
1180  void alloc( size_t size, bool setDataSize = true );
1181 
1185  bool peekCopy( bool copyCapacity = false );
1186 
1190  size_t getSize() const;
1191 
1195  void * getBuf() const;
1196 
1197  // 赋值操作 -------------------------------------------------------------------------------
1198  void assign( char const * str, size_t len = npos );
1199  void assign( wchar const * str, size_t len = npos );
1200  void assign( bool boolVal );
1201  void assign( byte btVal );
1202  void assign( short shVal );
1203  void assign( ushort ushVal );
1204  void assign( int iVal );
1205  void assign( uint uiVal );
1206  void assign( long lVal );
1207  void assign( ulong ulVal );
1208  void assign( float fltVal );
1209  void assign( int64 i64Val );
1210  void assign( uint64 ui64Val );
1211  void assign( double dblVal );
1212 
1213  void assign( Buffer const & buf );
1215  void assign( void const * binaryData, size_t size, bool isPeek = false );
1217  void assign( Mixed * arr, size_t count );
1218 
1220  template < typename _Ty >
1221  void assign( std::vector<_Ty> const & arr )
1222  {
1223  this->free();
1224  this->_type = MT_ARRAY;
1225  this->_pArr = new MixedArray( arr.size() );
1226  size_t i;
1227  for ( i = 0; i < arr.size(); ++i )
1228  {
1229  this->_pArr->at(i) = arr[i];
1230  }
1231  }
1232 
1234  template < typename _Ty, size_t _N >
1235  void assign( _Ty (&arr)[_N] )
1236  {
1237  this->free();
1238  this->_type = MT_ARRAY;
1239  this->_pArr = new MixedArray(_N);
1240  size_t i;
1241  for ( i = 0; i < _N; ++i )
1242  {
1243  this->_pArr->at(i) = arr[i];
1244  }
1245  }
1246 
1248  void assign( std::initializer_list<Mixed> list );
1249 
1251  void assign( $a arr );
1252 
1254  template < typename _KTy, typename _VTy, typename _Pr, typename _Alloc >
1255  void assign( std::map< _KTy, _VTy, _Pr, _Alloc > const & m )
1256  {
1257  this->free();
1258  this->_type = MT_COLLECTION;
1259  this->_pArr = new MixedArray(); // 存放keys
1260  this->_pMap = new MixedMixedMap();
1261  typename std::map< _KTy, _VTy, _Pr, _Alloc >::const_iterator it;
1262  for ( it = m.begin(); it != m.end(); ++it )
1263  {
1264  this->_pArr->push_back(it->first);
1265  (*this->_pMap)[it->first] = it->second;
1266  }
1267  }
1268 
1270  template < typename _KTy, typename _VTy, size_t _Count >
1271  void assign( std::pair< _KTy, _VTy > (&pairs)[_Count] )
1272  {
1273  this->free();
1274  this->_type = MT_COLLECTION;
1275  this->_pArr = new MixedArray(); // 存放keys
1276  this->_pMap = new MixedMixedMap();
1277  size_t i;
1278  for ( i = 0; i < _Count; ++i )
1279  {
1280  this->_addUniqueKey(pairs[i].first);
1281  (*this->_pMap)[pairs[i].first] = pairs[i].second;
1282  }
1283  }
1284 
1286  template < typename _KTy, typename _VTy, size_t _Count >
1287  void assign( _KTy (&keys)[_Count], _VTy (&vals)[_Count] )
1288  {
1289  this->free();
1290  this->_type = MT_COLLECTION;
1291  this->_pArr = new MixedArray(); // 存放keys
1292  this->_pMap = new MixedMixedMap();
1293  size_t i;
1294  for ( i = 0; i < _Count; ++i )
1295  {
1296  this->_addUniqueKey(keys[i]);
1297  (*this->_pMap)[keys[i]] = vals[i];
1298  }
1299  }
1300 
1302  void assign( $c coll );
1303 
1304  // JSON相关操作 ------------------------------------------------------------------------
1305  String myJson( bool autoKeyQuotes = true, AnsiString const & spacer = "", AnsiString const & newline = "" ) const;
1306  String json() const;
1307  Mixed & json( String const & jsonStr );
1308 
1309  // 类型解析功能 -------------------------------------------------------------------------
1311  static bool ParseBool( AnsiString const & str, bool * boolVal );
1312  static bool ParseBool( UnicodeString const & str, bool * boolVal );
1314  static bool ParseULong( AnsiString const & str, ulong * ulVal );
1315  static bool ParseULong( UnicodeString const & str, ulong * ulVal );
1317  static bool ParseDouble( AnsiString const & str, double * dblVal );
1318  static bool ParseDouble( UnicodeString const & str, double * dblVal );
1320  static bool ParseUInt64( AnsiString const & str, uint64 * ui64Val );
1321  static bool ParseUInt64( UnicodeString const & str, uint64 * ui64Val );
1322 
1324  static Mixed & ParseJson( AnsiString const & str, Mixed * val );
1325 
1326 private:
1327  void _zeroInit();
1328  // MT_COLLECTION,给数组加入一个唯一键名
1329  void _addUniqueKey( Mixed const & k )
1330  {
1331  if ( this->_pMap->find(k) == this->_pMap->end() )
1332  this->_pArr->push_back(k);
1333  }
1334 };
1335 
1336 template <>
1337 inline XString<char> & Mixed::refString<char>()
1338 {
1339  return this->refAnsi();
1340 }
1341 
1342 template <>
1343 inline XString<char> const & Mixed::refString<char>() const
1344 {
1345  return this->refAnsi();
1346 }
1347 
1348 template <>
1349 inline XString<wchar> & Mixed::refString<wchar>()
1350 {
1351  return this->refUnicode();
1352 }
1353 
1354 template <>
1355 inline XString<wchar> const & Mixed::refString<wchar>() const
1356 {
1357  return this->refUnicode();
1358 }
1359 
1361 template <>
1362 inline XString<char> Mixed::toString<char>() const
1363 {
1364  return this->toAnsi();
1365 }
1366 
1368 template <>
1369 inline XString<wchar> Mixed::toString<wchar>() const
1370 {
1371  return this->toUnicode();
1372 }
1373 
1375 template <>
1376 inline Mixed & Mixed::createString<char>()
1377 {
1378  return this->createAnsi();
1379 }
1380 
1382 template <>
1383 inline Mixed & Mixed::createString<wchar>()
1384 {
1385  return this->createUnicode();
1386 }
1387 
1389 WINUX_FUNC_DECL(std::ostream &) operator << ( std::ostream & o, Mixed const & m );
1390 WINUX_FUNC_DECL(std::wostream &) operator << ( std::wostream & o, Mixed const & m );
1391 
1392 //std::istream & operator >> ( std::istream & o, Mixed const & m );
1393 //std::wistream & operator >> ( std::wistream & o, Mixed const & m );
1394 
1395 } // namespace winux
1396 
1397 #endif // __UTILITIES_HPP__
XString< char > AnsiString
Definition: utilities.hpp:212
XString< char32 > UnicodeString32
Definition: utilities.hpp:215
__int64 int64
Definition: utilities.hpp:187
static bool IsLittleEndian()
判断编译环境是否为小端序
Definition: utilities.hpp:253
XString< wchar > UnicodeString
Definition: utilities.hpp:213
函数包装,用来将不同调用约定的函数统一包装成默认约定
Definition: utilities.hpp:357
void * getBuf() const
暴露缓冲区指针
Definition: utilities.hpp:585
intptr_t ssize_t
Definition: utilities.hpp:180
char32_t char32
Definition: utilities.hpp:178
Mixed构造集合辅助类
Definition: utilities.hpp:741
AnsiString toAnsi() const
转换到AnsiString
Definition: utilities.hpp:639
Array赋值器
Definition: utilities.hpp:384
std::map< String, Mixed > StringMixedMap
Definition: utilities.hpp:233
bool _isPeek
是否为窥视模式
Definition: utilities.hpp:653
MapAssigner< _KTy, _VTy > Assign(std::map< _KTy, _VTy > *m)
给容器赋值
Definition: utilities.hpp:399
值是Null因此无法操作
Definition: utilities.hpp:722
void create(_ArgType &&...arg)
必须在使用者类的构造函数里第一个调用
Definition: utilities.hpp:467
#define WINUX_DLL
Definition: utilities.hpp:60
wchar_t wchar
Definition: utilities.hpp:184
winux::byte const * begin() const
Definition: utilities.hpp:609
std::initializer_list< std::pair< Mixed, Mixed > > _list
Definition: utilities.hpp:743
int VoidReturnInt(_Fx fn, _ArgType &&...arg)
调用一个返回void的函数或函数对象,返回一个数字
Definition: utilities.hpp:290
MembersWrapper(MembersWrapper &&other)
Definition: utilities.hpp:437
XStringArray< char16 > UnicodeString16Array
Definition: utilities.hpp:223
XString< tchar > String
Definition: utilities.hpp:216
$a(std::initializer_list< Mixed > list)
Definition: utilities.hpp:735
std::pair< String, Mixed > StringMixedPair
Definition: utilities.hpp:234
winux::byte * begin()
Definition: utilities.hpp:607
STL namespace.
XStringArray< char16 > Utf16StringArray
Definition: utilities.hpp:225
size_t capacity() const
获取容量大小
Definition: utilities.hpp:625
size_t _capacity
容量
Definition: utilities.hpp:652
XString< _ChTy > toString() const
转换到字符串
Definition: utilities.hpp:632
bool ValueIsInArray(StringArray const &arr, String const &val, bool caseInsensitive=false)
判断一个字符串值是否在一个字符串数组里,默认大小写敏感
二进制数,编译时计算, 0开头(基于8进制)
Definition: utilities.hpp:297
std::map< String, String > StringStringMap
Definition: utilities.hpp:229
void destroy()
必须在使用者类的析构函数里最后一个调用
Definition: utilities.hpp:456
virtual ~Error()
Definition: utilities.hpp:513
winux::byte * end()
Definition: utilities.hpp:608
size_t getSize() const
获取数据大小
Definition: utilities.hpp:613
std::vector< XString< _ChTy > > XStringArray
Definition: utilities.hpp:219
std::ostream & operator<<(std::ostream &o, ConsoleAttrT< _VarType > const &tr)
Definition: console.hpp:137
函数特征
Definition: utilities.hpp:8
Mixed构造数组辅助类
Definition: utilities.hpp:732
char tchar
Definition: utilities.hpp:200
_Ty * getBuf() const
暴露缓冲区指针
Definition: utilities.hpp:589
size_t usize_t
Definition: utilities.hpp:181
XString< char32 > Utf32String
Definition: utilities.hpp:215
int Random(int n1, int n2)
随机数,随机产生n1~n2的数字. 包括n1,n2本身
static constexpr size_t const npos
非位置,值为-1。
Definition: utilities.hpp:240
XStringArray< char > AnsiStringArray
Definition: utilities.hpp:221
std::vector< Mixed > MixedArray
Definition: utilities.hpp:232
缓冲区,表示内存中一块二进制数据(利用malloc/realloc进行内存分配)
Definition: utilities.hpp:528
std::map< Mixed, Mixed, MixedLess > MixedMixedMap
Definition: utilities.hpp:782
static bool IsBigEndian()
判断编译环境是否为大端序
Definition: utilities.hpp:260
XStringArray< char > Utf8StringArray
Definition: utilities.hpp:221
MixedMixedMap::value_type MixedMixedPair
Definition: utilities.hpp:783
char int8
Definition: utilities.hpp:174
void append(_PodType const &data)
添加数据:POD类型变量
Definition: utilities.hpp:691
XString< char > Utf8String
Definition: utilities.hpp:212
bool isset(_MAP const &m, _KEY const &k)
检测map中是否有该键的值
Definition: utilities.hpp:268
unsigned int uint
Definition: utilities.hpp:170
void _setSize(size_t dataSize)
设置数据大小,不能超过容量大小(不建议外部调用)
Definition: utilities.hpp:619
XStringArray< char32 > Utf32StringArray
Definition: utilities.hpp:226
__int64 longlong
Definition: utilities.hpp:188
MapAssigner(std::map< _KTy, _VTy > *m)
Definition: utilities.hpp:372
MixedError(int errType, AnsiString const &errStr)
Definition: utilities.hpp:728
$c(std::initializer_list< std::pair< Mixed, Mixed > > list)
Definition: utilities.hpp:744
#define WINUX_FUNC_DECL(ret)
Definition: utilities.hpp:64
void append(_PodType const (&data)[_Count])
添加数据:POD类型数组
Definition: utilities.hpp:695
Tuple参数序列
Definition: utilities.hpp:331
unsigned char byte
Definition: utilities.hpp:204
void append(AnsiString const &data)
添加数据:AnsiString对象
Definition: utilities.hpp:684
size_t _dataSize
数据的大小
Definition: utilities.hpp:651
virtual char const * what() const
Definition: utilities.hpp:515
高效的可增长缓冲区,1.33倍冗余量
Definition: utilities.hpp:659
unsigned __int64 ulonglong
Definition: utilities.hpp:186
MapAssigner & operator()(_KTy const &k, _VTy const &v)
Definition: utilities.hpp:373
char16_t char16
Definition: utilities.hpp:177
std::vector< _Ty > ToArray(_Ty *arr, uint count)
将C数组转换成vector
Definition: utilities.hpp:275
void append(Buffer const &data)
添加数据:Buffer对象
Definition: utilities.hpp:687
void setBuf(void const *buf, size_t size, bool isPeek)
设置缓冲区,当isPeek为false时拷贝数据缓冲区
Definition: utilities.hpp:565
UnicodeString toUnicode() const
转换到UnicodeString
Definition: utilities.hpp:642
int int32
Definition: utilities.hpp:169
XStringArray< wchar > UnicodeStringArray
Definition: utilities.hpp:222
Error(int errType, AnsiString const &errStr)
Definition: utilities.hpp:512
unsigned short ushort
Definition: utilities.hpp:173
XString< char16 > UnicodeString16
Definition: utilities.hpp:214
virtual int getErrType() const
Definition: utilities.hpp:514
不能转换到某种类型
Definition: utilities.hpp:723
混合体,能表示多种类型的值
Definition: utilities.hpp:750
unsigned short uint16
Definition: utilities.hpp:173
size_t getCapacity() const
获取容量大小
Definition: utilities.hpp:622
RefParam(ParamTypeRef r)
Definition: utilities.hpp:318
XStringArray< char32 > UnicodeString32Array
Definition: utilities.hpp:224
static FuncTraits< _PfnType >::ReturnType func(_ArgType &&...arg)
Definition: utilities.hpp:360
错误类
Definition: utilities.hpp:505
void append(std::initializer_list< _PodType > list)
添加数据:POD类型initializer_list
Definition: utilities.hpp:699
static constexpr _Ty InvertByteOrder(_Ty v)
反转字节序
Definition: utilities.hpp:245
std::initializer_list< Mixed > _list
Definition: utilities.hpp:734
void * _buf
缓冲区
Definition: utilities.hpp:650
std::basic_string< _ChTy > XString
Definition: utilities.hpp:210
RefParam< _Ty > Ref(_Ty &r)
向模板参数传递引用型参数
Definition: utilities.hpp:324
unsigned long ulong
Definition: utilities.hpp:171
std::pair< String, String > StringStringPair
Definition: utilities.hpp:230
unsigned __int64 uint64
Definition: utilities.hpp:185
unsigned int uint32
Definition: utilities.hpp:170
unsigned char uint8
Definition: utilities.hpp:175
意料外的类型,该类型不能执行这个操作
Definition: utilities.hpp:724
混合体错误
Definition: utilities.hpp:716
short int16
Definition: utilities.hpp:172
MAP赋值器
Definition: utilities.hpp:368
XStringArray< tchar > StringArray
Definition: utilities.hpp:227
size_t size() const
获取数据大小
Definition: utilities.hpp:616
XString< char16 > Utf16String
Definition: utilities.hpp:214
winux::byte const * end() const
Definition: utilities.hpp:610
跨平台基础功能库
Definition: archives.hpp:7
intptr_t offset_t
Definition: utilities.hpp:180
ArrayAssigner(std::vector< _Ty > *a)
Definition: utilities.hpp:388