Skip to content

Commit

Permalink
few lines of doc & travis build only master branch
Browse files Browse the repository at this point in the history
  • Loading branch information
HamedMasafi committed Jun 20, 2019
1 parent 126f214 commit 97a9424
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 19 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#Based on https://github.com/pcolby/libqtaws/blob/master/.travis.yml
language: cpp

branches:
only:
- master

os:
- linux
- osx
Expand Down
Binary file added .vscode/ipch/38f51fe5930ec860/mmap_address.bin
Binary file not shown.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ Badge](https://api.codacy.com/project/badge/Grade/f3802610beb946068f6cd2c2b6608a
- Table join detect
- Suppor every Qt types. [Full list](doc/datatypes.md)

[Getting start](doc/start.md)
##Getting start
* [Sample codes](doc/start.md)
* [Shared pointer and regular mode](sharedpointer.md)
* [Create database class](database.md)
* [Create table class](table.md)
* [Using queries](query.md)
* [Supported data types](datatypes.md)

### Donate
Butcoin address: 1Dn1WHKkaxanXe4cTGDk4cFRRABxLUpEVj
Expand Down
4 changes: 2 additions & 2 deletions doc/query.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ auto count = q.count(Post::idField());
## Checking field exists in list of values
```cpp
auto post = db.posts().query()
->setWhete(Post::idField().in(QList<int>() << 1 << 2 << 3 << 4) || Post::isAccepted())
->where(Post::idField().in(QList<int>() << 1 << 2 << 3 << 4) || Post::isAccepted())
->first();
```
Or
```cpp
auto post = db.posts().query()
->setWhete(Post::idField().in({1, 2, 3, 4}) || Post::isAccepted())
->where(Post::idField().in({1, 2, 3, 4}) || Post::isAccepted())
->first();
```
59 changes: 59 additions & 0 deletions doc/sharedpointer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
Nut can compile in *shared pointer* mode or *regular* mode

In *shared pointer* mode reqults of queries is QList<QSharedPointer<T>> and in *regular* mode results are QList<T*>

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

Nut has template alias

```cpp
#ifdef NUT_SHARED_POINTER
template <class T>
using RowList = QList<QSharedPointer<T>>;

template <typename T>
using Row = QSharedPointer<T>;
#else
template <typename T>
using RowList = QList<T*>;

template <typename T>
using Row = T*;
#endif
```

In other words these types are defined by this table:

| Mode | Nut::Row | Nut::RowList |
|------ |----- |--------- |
|Regular|T* | QList\<T\*\> |
|Shared pointer|QSharedPointer\<T\> | QList\<QSharedPointer\<T\>\> |

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
template<class T>
inline Row<T> create() {
return new T;
}
#endif
```

So you can use the Nut::create function without considering in what way the library is being compiled. Example:
```cpp
auto post = Nut::create<Post>();
```

In above example if *NUT_SHARED_POINTER* is defined *post* is *QSharedPointer<Post>* else is *Post\**

I recommand use *NUT_SHARED_POINTER* always!
16 changes: 0 additions & 16 deletions doc/start.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
Welcome to the Nut wiki!

# What is Nut

Nut is advanced, Powerful and easy to use ORM for Qt5

## Sample Codes
### Read data from database:

```cpp
Expand Down Expand Up @@ -50,12 +43,3 @@ if(post) {
}
```
## How to use nut
* [Create database class](database.md)
* [Create table class](table.md)
* [Using queries](query.md)
* [SUpported data types](datatypes.md)

0 comments on commit 97a9424

Please sign in to comment.