update doc

This commit is contained in:
Hamed Masafi 2020-08-12 19:02:32 +04:30
parent 54d78c3b60
commit ca9fa939a4
2 changed files with 62 additions and 57 deletions

View File

@ -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!

View File

@ -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>