update doc
This commit is contained in:
parent
54d78c3b60
commit
ca9fa939a4
|
|
@ -4,23 +4,23 @@ In *shared pointer* mode results of queries is QList<QSharedPointer<T>> and in *
|
|||
|
||||
Almost in every case shared pointer mode is better, But nut support regular mode for backward comptability.
|
||||
|
||||
To compiling in *shared pointer* define **NUT_SHARED_POINTER** macro
|
||||
By default _Nut_ compiles in shared pointer mode, to switch to ols raw pointer mode you must define **NUT_RAW_POINTER** macro
|
||||
|
||||
Nut has template alias
|
||||
|
||||
```cpp
|
||||
#ifdef NUT_SHARED_POINTER
|
||||
template <typename T>
|
||||
using RowList = QList<QSharedPointer<T>>;
|
||||
|
||||
template <typename T>
|
||||
using Row = QSharedPointer<T>;
|
||||
#else
|
||||
#ifdef NUT_RAW_POINTER
|
||||
template <typename T>
|
||||
using RowList = QList<T*>;
|
||||
|
||||
template <typename T>
|
||||
using Row = T*;
|
||||
#else
|
||||
template <typename T>
|
||||
using RowList = QList<QSharedPointer<T>>;
|
||||
|
||||
template <typename T>
|
||||
using Row = QSharedPointer<T>;
|
||||
#endif
|
||||
```
|
||||
|
||||
|
|
@ -36,16 +36,16 @@ For the integration of your source, you can use these aliases.
|
|||
Ans also Nut::create<T>() method are defined for two mode
|
||||
|
||||
```cpp
|
||||
#ifdef NUT_SHARED_POINTER
|
||||
template<class T>
|
||||
inline Row<T> create(QObject *parent) {
|
||||
return QSharedPointer<T>(new T(parent));
|
||||
}
|
||||
#else
|
||||
#ifdef NUT_RAW_POINTER
|
||||
template<class T>
|
||||
inline Row<T> create() {
|
||||
return new T;
|
||||
}
|
||||
#else
|
||||
template<class T>
|
||||
inline Row<T> create(QObject *parent) {
|
||||
return QSharedPointer<T>(new T(parent));
|
||||
}
|
||||
#endif
|
||||
```
|
||||
|
||||
|
|
@ -54,6 +54,6 @@ So you can use the Nut::create function without considering in what way the libr
|
|||
auto post = Nut::create<Post>();
|
||||
```
|
||||
|
||||
In above example if *NUT_SHARED_POINTER* is defined *post* is *QSharedPointer<Post>* else is *Post\**
|
||||
In above example if *NUT_RAW_POINTER* is defined *post* is *Post\** else is *QSharedPointer<Post>*
|
||||
|
||||
I recommand use *NUT_SHARED_POINTER* always!
|
||||
I recommand use shared pointer mode (default) always!
|
||||
|
|
|
|||
|
|
@ -1,7 +1,12 @@
|
|||
#ifndef NUT_NAMESPACE_H
|
||||
#define NUT_NAMESPACE_H
|
||||
|
||||
#include <QtNut/nut_config.h>
|
||||
#ifndef NUT_GLOBAL_H
|
||||
# error "Do not include nut_namespace.h header directly!"
|
||||
#endif
|
||||
|
||||
//avoid ide warnings
|
||||
#include <QtNut/nut_global.h>
|
||||
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QStringList>
|
||||
|
|
@ -79,57 +84,57 @@ inline bool nutClassInfoInt(const QMetaClassInfo &classInfo,
|
|||
}
|
||||
|
||||
#ifdef NUT_RAW_POINTER
|
||||
template <typename T>
|
||||
using RowList = QList<T*>;
|
||||
template <typename T>
|
||||
using RowList = QList<T*>;
|
||||
|
||||
template <typename T>
|
||||
using RowSet = QSet<T*>;
|
||||
template <typename T>
|
||||
using RowSet = QSet<T*>;
|
||||
|
||||
template <typename T>
|
||||
using Row = T*;
|
||||
template <typename T>
|
||||
using Row = T*;
|
||||
|
||||
template<class T>
|
||||
inline Row<T> create() {
|
||||
return new T;
|
||||
}
|
||||
template<class T>
|
||||
inline Row<T> create() {
|
||||
return new T;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T *get(const Row<T> row) {
|
||||
return row;
|
||||
}
|
||||
template<class T>
|
||||
inline T *get(const Row<T> row) {
|
||||
return row;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T *get(const QSharedPointer<T> row) {
|
||||
return row.data();
|
||||
}
|
||||
template<class T>
|
||||
inline T *get(const QSharedPointer<T> row) {
|
||||
return row.data();
|
||||
}
|
||||
#else
|
||||
template <class T>
|
||||
using RowList = QList<QSharedPointer<T>>;
|
||||
template <class T>
|
||||
using RowList = QList<QSharedPointer<T>>;
|
||||
|
||||
template <class T>
|
||||
using RowSet = QSet<QSharedPointer<T>>;
|
||||
template <class T>
|
||||
using RowSet = QSet<QSharedPointer<T>>;
|
||||
|
||||
template <typename T>
|
||||
using Row = QSharedPointer<T>;
|
||||
template <typename T>
|
||||
using Row = QSharedPointer<T>;
|
||||
|
||||
template<class T>
|
||||
inline Row<T> create() {
|
||||
return QSharedPointer<T>(new T);
|
||||
}
|
||||
template<class T>
|
||||
inline Row<T> create() {
|
||||
return QSharedPointer<T>(new T);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Row<T> create(QObject *parent) {
|
||||
return QSharedPointer<T>(new T(parent));
|
||||
}
|
||||
template<class T>
|
||||
inline Row<T> create(QObject *parent) {
|
||||
return QSharedPointer<T>(new T(parent));
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Row<T> createFrom(T *row) {
|
||||
return QSharedPointer<T>(row);
|
||||
}
|
||||
template<class T>
|
||||
inline Row<T> createFrom(const QSharedPointer<T> row) {
|
||||
return row;
|
||||
}
|
||||
template<class T>
|
||||
inline Row<T> createFrom(T *row) {
|
||||
return QSharedPointer<T>(row);
|
||||
}
|
||||
template<class T>
|
||||
inline Row<T> createFrom(const QSharedPointer<T> row) {
|
||||
return row;
|
||||
}
|
||||
#endif
|
||||
|
||||
NUT_END_NAMESPACE
|
||||
|
|
|
|||
Loading…
Reference in New Issue