32#ifndef _QX_GENERIC_CONTAINER_H_
33#define _QX_GENERIC_CONTAINER_H_
55{
private:
void dummy()
const { ; } };
65template <
typename Key,
typename Value>
79 std::pair<type_key, type_value>
m_pair;
102 template <
bool bIsPointer ,
typename T,
int dummy>
106 template <
typename T,
int dummy>
108 {
static inline T
get() {
return T(); } };
110 template <
bool bIsPointer ,
typename T,
typename U,
int dummy>
112 {
static inline U &
get(T & t) {
return (* t); } };
114 template <
typename T,
typename U,
int dummy>
116 {
static inline U &
get(T & t) {
return t; } };
123#define QX_TRAIT_GENERIC_CONTAINER_TYPEDEF(TypeContainer, TypeKey, TypeValue) \
124typedef qx::trait::generic_container_item< TypeKey, TypeValue > type_item; \
125typedef typename type_item::type_key type_key; \
126typedef typename type_item::type_value type_value; \
127typedef typename type_item::type_value_qx type_value_qx; \
128typedef typename TypeContainer::iterator type_iterator;
134template <
typename Container,
typename Item>
140 static inline
long size(const Container & t) {
return static_cast<long>(t.size()); }
141 static inline void clear(Container & t) { t.clear(); }
142 static inline void reserve(Container & t,
long l) { t.reserve(l); }
143 static inline type_item
createItem() {
return type_item(type_item::newKey(), type_item::newValue()); }
144 static inline Item *
insertItem(Container & t, type_item & item) { t.push_back(item.value());
return (& t.back()); }
145 static inline type_iterator
end(Container & t) {
return t.end(); }
147 static inline type_iterator
begin(Container & t, type_item & item)
148 {
if (t.size() <= 0) {
return t.end(); }; item.value(* t.begin());
return t.begin(); }
150 static inline type_iterator
next(Container & t, type_iterator itr, type_item & item)
151 { itr++;
if (itr == t.end()) {
return t.end(); }; item.value(* itr);
return itr; }
155template <
typename Container,
typename Item>
161 static inline
long size(const Container & t) {
return static_cast<long>(t.size()); }
162 static inline void clear(Container & t) { t.clear(); }
163 static inline void reserve(Container & t,
long l) { Q_UNUSED(t); Q_UNUSED(l); }
164 static inline type_item
createItem() {
return type_item(type_item::newKey(), type_item::newValue()); }
165 static inline Item *
insertItem(Container & t, type_item & item) { t.push_back(item.value());
return (& t.back()); }
166 static inline type_iterator
end(Container & t) {
return t.end(); }
168 static inline type_iterator
begin(Container & t, type_item & item)
169 {
if (t.size() <= 0) {
return t.end(); }; item.value(* t.begin());
return t.begin(); }
171 static inline type_iterator
next(Container & t, type_iterator itr, type_item & item)
172 { itr++;
if (itr == t.end()) {
return t.end(); }; item.value(* itr);
return itr; }
176template <
typename Container,
typename Item>
182 static inline
long size(const Container & t) {
return static_cast<long>(t.size()); }
183 static inline void clear(Container & t) { t.clear(); }
184 static inline void reserve(Container & t,
long l) { Q_UNUSED(t); Q_UNUSED(l); }
185 static inline type_item
createItem() {
return type_item(type_item::newKey(), type_item::newValue()); }
186 static inline Item *
insertItem(Container & t, type_item & item) {
return const_cast<Item *
>(& (* (t.insert(item.value()).first))); }
187 static inline type_iterator
end(Container & t) {
return t.end(); }
189 static inline type_iterator
begin(Container & t, type_item & item)
190 {
if (t.size() <= 0) {
return t.end(); }; item.value(* t.begin());
return t.begin(); }
192 static inline type_iterator
next(Container & t, type_iterator itr, type_item & item)
193 { itr++;
if (itr == t.end()) {
return t.end(); }; item.value(* itr);
return itr; }
197template <
typename Container,
typename Item>
203 static inline
long size(const Container & t) {
return static_cast<long>(t.size()); }
204 static inline void clear(Container & t) { t.clear(); }
205 static inline void reserve(Container & t,
long l) { Q_UNUSED(t); Q_UNUSED(l); }
206 static inline type_item
createItem() {
return type_item(type_item::newKey(), type_item::newValue()); }
207 static inline Item *
insertItem(Container & t, type_item & item) {
return const_cast<Item *
>(& (* (t.insert(item.value())))); }
208 static inline type_iterator
end(Container & t) {
return t.end(); }
210 static inline type_iterator
begin(Container & t, type_item & item)
211 {
if (t.size() <= 0) {
return t.end(); }; item.value(* t.begin());
return t.begin(); }
213 static inline type_iterator
next(Container & t, type_iterator itr, type_item & item)
214 { itr++;
if (itr == t.end()) {
return t.end(); }; item.value(* itr);
return itr; }
218template <
typename Container,
typename Key,
typename Value>
224 static inline
long size(const Container & t) {
return static_cast<long>(t.size()); }
225 static inline void clear(Container & t) { t.clear(); }
226 static inline void reserve(Container & t,
long l) { t.reserve(l); }
227 static inline type_item
createItem() {
return type_item(type_item::newKey(), type_item::newValue()); }
228 static inline Value *
insertItem(Container & t, type_item & item) {
return (& (t.insert(std::make_pair(item.key(), item.value())).first->second)); }
229 static inline type_iterator
end(Container & t) {
return t.end(); }
231 static inline type_iterator
begin(Container & t, type_item & item)
232 {
if (t.size() <= 0) {
return t.end(); }; item.value(* t.begin().second); item.key(* t.begin().first);
return t.begin(); }
234 static inline type_iterator
next(Container & t, type_iterator itr, type_item & item)
235 { itr++;
if (itr == t.end()) {
return t.end(); }; item.value(* itr.second); item.key(* itr.first);
return itr; }
239template <
typename Container,
typename Key,
typename Value>
245 static inline
long size(const Container & t) {
return static_cast<long>(t.size()); }
246 static inline void clear(Container & t) { t.clear(); }
247 static inline void reserve(Container & t,
long l) { Q_UNUSED(t); Q_UNUSED(l); }
248 static inline type_item
createItem() {
return type_item(type_item::newKey(), type_item::newValue()); }
249 static inline Value *
insertItem(Container & t, type_item & item) {
return (& (t.insert(std::make_pair(item.key(), item.value())).first->second)); }
250 static inline type_iterator
end(Container & t) {
return t.end(); }
252 static inline type_iterator
begin(Container & t, type_item & item)
253 {
if (t.size() <= 0) {
return t.end(); }; item.value(* t.begin().second); item.key(* t.begin().first);
return t.begin(); }
255 static inline type_iterator
next(Container & t, type_iterator itr, type_item & item)
256 { itr++;
if (itr == t.end()) {
return t.end(); }; item.value(* itr.second); item.key(* itr.first);
return itr; }
260template <
typename Container,
typename Key,
typename Value>
266 static inline
long size(const Container & t) {
return static_cast<long>(t.size()); }
267 static inline void clear(Container & t) { t.clear(); }
268 static inline void reserve(Container & t,
long l) { t.reserve(l); }
269 static inline type_item
createItem() {
return type_item(type_item::newKey(), type_item::newValue()); }
270 static inline Value *
insertItem(Container & t, type_item & item) {
return (& (t.insert(std::make_pair(item.key(), item.value()))->second)); }
271 static inline type_iterator
end(Container & t) {
return t.end(); }
273 static inline type_iterator
begin(Container & t, type_item & item)
274 {
if (t.size() <= 0) {
return t.end(); }; item.value(* t.begin().second); item.key(* t.begin().first);
return t.begin(); }
276 static inline type_iterator
next(Container & t, type_iterator itr, type_item & item)
277 { itr++;
if (itr == t.end()) {
return t.end(); }; item.value(* itr.second); item.key(* itr.first);
return itr; }
281template <
typename Container,
typename Key,
typename Value>
287 static inline
long size(const Container & t) {
return static_cast<long>(t.size()); }
288 static inline void clear(Container & t) { t.clear(); }
289 static inline void reserve(Container & t,
long l) { t.reserve(l); }
290 static inline type_item
createItem() {
return type_item(type_item::newKey(), type_item::newValue()); }
291 static inline Value *
insertItem(Container & t, type_item & item) {
return (& (t.insert(item.key(), item.value()).value())); }
292 static inline type_iterator
end(Container & t) {
return t.end(); }
294 static inline type_iterator
begin(Container & t, type_item & item)
295 {
if (t.size() <= 0) {
return t.end(); }; item.value(* t.begin().value()); item.key(* t.begin().key());
return t.begin(); }
297 static inline type_iterator
next(Container & t, type_iterator itr, type_item & item)
298 { itr++;
if (itr == t.end()) {
return t.end(); }; item.value(* itr.value()); item.key(* itr.key());
return itr; }
316template <
typename Key,
typename Value>
320#ifdef _QX_ENABLE_BOOST
330template <
typename Key,
typename Value>
334template <
typename Key,
typename Value>
348template <
typename Key,
typename Value>
352template <
typename Key,
typename Value>
356#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
362#if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0))
376#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
386template <
typename Key,
typename Value>
390template <
typename Key,
typename Value>
394template <
typename Key,
typename Value>
398template <
typename Key,
typename Value>
402template <
typename Key,
typename Value>
408 static inline
long size(const
qx::
QxCollection<Key, Value> & t) {
return static_cast<long>(t.size()); }
#define QX_TEMPLATE_T_P1(T, P1)
#define QX_TEMPLATE_T_P1_P2(T, P1, P2)
qx::QxCollection<Key, Value> : QxOrm thread-safe container (keep insertion order + quick access by in...
bool insert(const Key &key, const Value &value)
Add element 'value' at the end of the list indexed by 'key'.
const_reference_key getKeyByIndex(long index) const
Return the key associated with the element at index position 'index'.
long size() const
Return the number of items in the list (same as 'count()')
const_reference_value getByKey(const Key &key) const
Return the item associated with the 'key'.
void reserve(long size)
Request that the capacity of the allocated storage space for the items of the container be at least e...
iterator begin()
Return an STL-style iterator pointing to the first item in the list.
void clear()
Remove all items from the list.
iterator end()
Return an STL-style iterator pointing to the imaginary item after the last item in the list.
const_reference_value getByIndex(long index) const
Return the item at index position 'index'.
qx::trait::construct_ptr<T>::get(T & t, bool bReset = false) : instantiate (or reset) a new pointer,...
#define QX_TRAIT_GENERIC_CONTAINER_TYPEDEF(TypeContainer, TypeKey, TypeValue)
qx::trait::is_smart_ptr<T>::value : return true if T is a smart-pointer of boost, Qt or QxOrm librari...
Root namespace for all QxOrm library features.
qx::trait::remove_attr<T>::type : return a type without pointer, const, reference and/or volatile att...
qx::trait::remove_smart_ptr<T>::type : return a type without smart-pointer attribute from boost,...
static void get(T &t, bool bReset=false)
static type_iterator next(Container &t, type_iterator itr, type_item &item)
static type_iterator begin(Container &t, type_item &item)
static type_iterator end(Container &t)
static Value * insertItem(Container &t, type_item &item)
static type_item createItem()
static long size(const Container &t)
static void clear(Container &t)
static void reserve(Container &t, long l)
static type_iterator begin(Container &t, type_item &item)
static void reserve(Container &t, long l)
static Value * insertItem(Container &t, type_item &item)
static type_item createItem()
static type_iterator next(Container &t, type_iterator itr, type_item &item)
static void clear(Container &t)
static long size(const Container &t)
static type_iterator end(Container &t)
static void reserve(Container &t, long l)
static long size(const Container &t)
static type_iterator end(Container &t)
static type_iterator begin(Container &t, type_item &item)
static void clear(Container &t)
static Value * insertItem(Container &t, type_item &item)
static type_item createItem()
static type_iterator next(Container &t, type_iterator itr, type_item &item)
static Value * insertItem(Container &t, type_item &item)
static type_iterator begin(Container &t, type_item &item)
static long size(const Container &t)
static type_iterator next(Container &t, type_iterator itr, type_item &item)
static type_iterator end(Container &t)
static type_item createItem()
static void reserve(Container &t, long l)
static void clear(Container &t)
static type_item createItem()
static type_iterator begin(Container &t, type_item &item)
static long size(const Container &t)
static Item * insertItem(Container &t, type_item &item)
static type_iterator next(Container &t, type_iterator itr, type_item &item)
static type_iterator end(Container &t)
static void clear(Container &t)
static void reserve(Container &t, long l)
static type_iterator next(Container &t, type_iterator itr, type_item &item)
static type_iterator begin(Container &t, type_item &item)
static void reserve(Container &t, long l)
static type_iterator end(Container &t)
static long size(const Container &t)
static void clear(Container &t)
static type_item createItem()
static Item * insertItem(Container &t, type_item &item)
static void clear(Container &t)
static type_iterator next(Container &t, type_iterator itr, type_item &item)
static type_iterator end(Container &t)
static Item * insertItem(Container &t, type_item &item)
static type_iterator begin(Container &t, type_item &item)
static type_item createItem()
static void reserve(Container &t, long l)
static long size(const Container &t)
static type_item createItem()
static long size(const Container &t)
static type_iterator end(Container &t)
static void reserve(Container &t, long l)
static type_iterator next(Container &t, type_iterator itr, type_item &item)
static type_iterator begin(Container &t, type_item &item)
static Item * insertItem(Container &t, type_item &item)
static void clear(Container &t)
static type_item createItem()
static void clear(qx::QxCollection< Key, Value > &t)
static Value * insertItem(qx::QxCollection< Key, Value > &t, type_item &item)
static type_iterator next(qx::QxCollection< Key, Value > &t, type_iterator itr, type_item &item)
static void reserve(qx::QxCollection< Key, Value > &t, long l)
static type_iterator begin(qx::QxCollection< Key, Value > &t, type_item &item)
static type_iterator end(qx::QxCollection< Key, Value > &t)
~generic_container_item()
void value(const Value &value)
type_value_qx & value_qx()
std::pair< type_key, type_value > m_pair
const type_value_qx & value_qx() const
qx::trait::remove_smart_ptr< type_value_qx_tmp >::type type_value_qx
const type_value & value() const
static type_value newValue()
qx::trait::remove_attr< Value >::type type_value_qx_tmp
generic_container_item(const Key &key, const Value &value)
const type_key & key() const
qx::trait::generic_container<T> : provide some tools to manage all containers without knowing its typ...
qx::trait::is_smart_ptr<T>::value : return true if T is a smart-pointer of boost, Qt or QxOrm librari...