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.
|
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
|
Nut has template alias
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
#ifdef NUT_SHARED_POINTER
|
#ifdef NUT_RAW_POINTER
|
||||||
template <typename T>
|
|
||||||
using RowList = QList<QSharedPointer<T>>;
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
using Row = QSharedPointer<T>;
|
|
||||||
#else
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using RowList = QList<T*>;
|
using RowList = QList<T*>;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using Row = T*;
|
using Row = T*;
|
||||||
|
#else
|
||||||
|
template <typename T>
|
||||||
|
using RowList = QList<QSharedPointer<T>>;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
using Row = QSharedPointer<T>;
|
||||||
#endif
|
#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
|
Ans also Nut::create<T>() method are defined for two mode
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
#ifdef NUT_SHARED_POINTER
|
#ifdef NUT_RAW_POINTER
|
||||||
template<class T>
|
|
||||||
inline Row<T> create(QObject *parent) {
|
|
||||||
return QSharedPointer<T>(new T(parent));
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline Row<T> create() {
|
inline Row<T> create() {
|
||||||
return new T;
|
return new T;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
template<class T>
|
||||||
|
inline Row<T> create(QObject *parent) {
|
||||||
|
return QSharedPointer<T>(new T(parent));
|
||||||
|
}
|
||||||
#endif
|
#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>();
|
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
|
#ifndef NUT_NAMESPACE_H
|
||||||
#define 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/QString>
|
||||||
#include <QtCore/QStringList>
|
#include <QtCore/QStringList>
|
||||||
|
|
@ -79,57 +84,57 @@ inline bool nutClassInfoInt(const QMetaClassInfo &classInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NUT_RAW_POINTER
|
#ifdef NUT_RAW_POINTER
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using RowList = QList<T*>;
|
using RowList = QList<T*>;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using RowSet = QSet<T*>;
|
using RowSet = QSet<T*>;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using Row = T*;
|
using Row = T*;
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline Row<T> create() {
|
inline Row<T> create() {
|
||||||
return new T;
|
return new T;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline T *get(const Row<T> row) {
|
inline T *get(const Row<T> row) {
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline T *get(const QSharedPointer<T> row) {
|
inline T *get(const QSharedPointer<T> row) {
|
||||||
return row.data();
|
return row.data();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
template <class T>
|
template <class T>
|
||||||
using RowList = QList<QSharedPointer<T>>;
|
using RowList = QList<QSharedPointer<T>>;
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
using RowSet = QSet<QSharedPointer<T>>;
|
using RowSet = QSet<QSharedPointer<T>>;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using Row = QSharedPointer<T>;
|
using Row = QSharedPointer<T>;
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline Row<T> create() {
|
inline Row<T> create() {
|
||||||
return QSharedPointer<T>(new T);
|
return QSharedPointer<T>(new T);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline Row<T> create(QObject *parent) {
|
inline Row<T> create(QObject *parent) {
|
||||||
return QSharedPointer<T>(new T(parent));
|
return QSharedPointer<T>(new T(parent));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline Row<T> createFrom(T *row) {
|
inline Row<T> createFrom(T *row) {
|
||||||
return QSharedPointer<T>(row);
|
return QSharedPointer<T>(row);
|
||||||
}
|
}
|
||||||
template<class T>
|
template<class T>
|
||||||
inline Row<T> createFrom(const QSharedPointer<T> row) {
|
inline Row<T> createFrom(const QSharedPointer<T> row) {
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NUT_END_NAMESPACE
|
NUT_END_NAMESPACE
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue