Fixed failing assertion in CBLQueryRow due to unset _database

Recent regression due to the view indexing optimizations.
Fixes #403
Fix #310 Mutated sub model not being saved issue

* Add the code that checks for 'CBLJSONEncoding' protocol and assign
OnMutate block if the value implements 'setOnMutate' in the
'impForSetterOfProperty' method.
* Add 'API_SaveMutatedSubModel' test.
Fixes #336 Assertion Failed : _asyncTaskCount >= 0

The issue is that the result of the onCompletion block of the
CBLMultipartUploader could be null when there was an error occurred.
Hence passing the result object of the block to the removeRemoteRequest
method is not correct and will result to an error that the finished
uploader will not be removed from the remote request array.

When the app is suspended in the background, the replication (pusher)
will stop all of the requests that are in the remote request array.
Calling stop on the finished uploader will cause the onCompletion block
to be called again and will lead to the ‘Assertion Failed :
_asyncTaskCount >= 0’ error when asyncTasksFinished: method is invoked
inside the onCompletion block.

The fix is to use the original uploader object to pass to
removeRemoteRequest method instead of using the result object from the
onCompletion block.
Fixes Puller bugs that can cause asyncTaskCount out of sync

* Similar to the fix for #336 to the Pusher, ensure that we pass the
right request object to the removeRemoteRequest method inside the
OnCompletion block of the CBLMultipartDownloader and CBLBulkDownloader.

* Correct result type of the CBLBulkDownloader’s onCompletion block.

* Call removeRemoteRequest to remove the CBLBulkDownloader object
inside the onCompletion block.
Write a test case for #319
Fixes #319 overriding the response content-type

Setting the response content-type to 'application/json' when the
response has a body object but there is no content-type value given.
Merge pull request #404 from couchbase/feature/issue_310

Fix #310 Mutated sub model not being saved issue
Merge pull request #407 from couchbase/feature/issue_336

Fix #336 Assertion Failed : _asyncTaskCount >= 0
Merge pull request #412 from couchbase/feature/issue_319

Fixes #319 overriding the response content-type
Don't make internal symbols public, in the iOS static library

For #413
Fixed the targets so the test apps can still access+run the unit tests.

The debug builds of the static framework need to export all
symbols publicly so that the test apps can call the unit tests.

For #413
Fixes #405 asyncTaskCount out of sync in Puller

* The issue happens in the continous mode where there is a permanent error occurred. The asyncTaskCount was decreased unexpectedly as a result of the continous flag was reset while stopping the replication due to the permanent error.

* Fix the issue by getting the continous flag before setting the error which could trigger the replication to stop if the error is a permanent error.

* Add CBL_Puller_Continuous_PermanentError Test that reflects the fix.
Add CBL iOS Test target to the CBLRouter_Tests
add logging of filter parameters for debugging
Fixes #405 Rework

Testing against ChangeTracker's continuous property instead of replicator._ continuous variable when syncing asyncTaskCount in CBL_Puller's startChangeTracker, changeTrackerStopped: and stop method.
Merge pull request #416 from couchbase/feature/issue_405

Fixes #405 asyncTaskCount out of sync in Puller
Add NS_REQUIRES_PROPERTY_DEFINITIONS declaration to CBLModel

This will catch a common bug where someone implementing a concrete
model class forgets to declare a document property as @dynamic.

The annotation will trigger a compiler warning in this situation, i.e.
whenever a subclass doesn't explicitly provide an @dynamic (or
@synthesize or accessor method) for a property it declares.
Type-check CBLModel getters for string/array/dict properties

CBLModel dynamic properties of type NSString, NSArray, NSDictionary, NSNumber
now type-check the value in the document. If it's not of the correct type, the
property value will be nil.
This is very useful when dealing with other platforms or apps that are in the habit of
setting empty properties to a JSON 'null' value instead of just leaving them out.
Fixes #419
Fixes #354 Return 404 for unknown resources

* Fixes CBL_Router to return 404 instead of 400 for unknown resourcess.

* Fixes CBLRouter_tests accordingly.
Fixes #163 REST total_rows should return number of rows in the view

* Add total_docs column to views table and set its default value to -1 (means 'unknown' for the old version of the api that do not have this fix)

* Add totalDocs property to CBLView() category. The totalDocs property will first try to get the value from views.total_docs columns and if the value is '-1', it will count the number of docs from the maps table, update the value to views.total_docs and return.

* Update the views.total_rows every time when the view's index is updated.

* Update CBL_Router's handler to return view.totalDocs for the total_rows attribute in query responses.

* Add CBL_View_TotalDocs test case and fix CBL_Router_Views accordingly.