1 /***************************************************************************** 2 3 ArrayMultiType.h 4 Author: Laurent de Soras, 2015 5 6 --- Legal stuff --- 7 8 This program is free software. It comes without any warranty, to 9 the extent permitted by applicable law. You can redistribute it 10 and/or modify it under the terms of the Do What The Fuck You Want 11 To Public License, Version 2, as published by Sam Hocevar. See 12 http://sam.zoy.org/wtfpl/COPYING for more details. 13 14 *Tab=3***********************************************************************/ 15 16 17 18 #pragma once 19 #if ! defined (fmtcl_ArrayMultiType_HEADER_INCLUDED) 20 #define fmtcl_ArrayMultiType_HEADER_INCLUDED 21 22 #if defined (_MSC_VER) 23 #pragma warning (4 : 4250) 24 #endif 25 26 27 28 /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 29 30 #include "fstb/def.h" 31 32 #include <vector> 33 34 #include <cstddef> 35 #include <cstdint> 36 37 38 39 namespace fmtcl 40 { 41 42 43 44 class ArrayMultiType 45 { 46 47 /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 48 49 public: 50 51 ArrayMultiType () = default; ~ArrayMultiType()52 virtual ~ArrayMultiType () {} 53 54 template <class T> 55 void set_type (); 56 void resize (size_t length); 57 template <class T> 58 fstb_FORCEINLINE T & 59 use (int pos); 60 template <class T> 61 fstb_FORCEINLINE const T & 62 use (int pos) const; 63 inline size_t get_size () const; 64 65 66 67 /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 68 69 protected: 70 71 72 73 /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 74 75 private: 76 77 std::vector <uint8_t> 78 _arr; 79 size_t _length = 0; 80 int _data_len = 0; // Element size in bytes. 0 = not set 81 82 83 84 /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 85 86 private: 87 88 ArrayMultiType (const ArrayMultiType &other) = delete; 89 ArrayMultiType & 90 operator = (const ArrayMultiType &other) = delete; 91 bool operator == (const ArrayMultiType &other) const = delete; 92 bool operator != (const ArrayMultiType &other) const = delete; 93 94 }; // class ArrayMultiType 95 96 97 98 } // namespace fmtcl 99 100 101 102 #include "fmtcl/ArrayMultiType.hpp" 103 104 105 106 #endif // fmtcl_ArrayMultiType_HEADER_INCLUDED 107 108 109 110 /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ 111