Skip to content

Commit

Permalink
Merge pull request #28 from Tightdb/ks-no-cpp-comments
Browse files Browse the repository at this point in the history
No C99/C++ comments allowed in Obj-C files (discounting Obj-C++ files)
  • Loading branch information
kspangsege committed Feb 25, 2014
2 parents 0b05a30 + 405d13b commit 52e2121
Show file tree
Hide file tree
Showing 14 changed files with 209 additions and 191 deletions.
23 changes: 11 additions & 12 deletions doc/ref/examples/ex_objc_group_intro.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @@Example: ex_objc_group_intro @@
/* @@Example: ex_objc_group_intro @@ */

#import <tightdb/objc/group.h>
#import <tightdb/objc/table.h>
Expand All @@ -18,30 +18,30 @@ int main()
{
@autoreleasepool {

// Creates a group and uses it to create a new table.
/* Creates a group and uses it to create a new table. */

TightdbGroup *group = [TightdbGroup group];
PeopleTable *table = [group getTable:@"people" withClass:[PeopleTable class]];

// Adds values to the table.
/* Adds values to the table. */

[table addName:@"Mary" Age:14];
[table addName:@"Joe" Age:17];

// Write the group (and the contained table) to a specified file.
/* Write the group (and the contained table) to a specified file. */

[[NSFileManager defaultManager] removeItemAtPath:@"filename.tightdb" error:nil];
[group write:@"filename.tightdb"];

// Adds another row to the table. Note the update is NOT persisted
// automatically (delete the old file and use write again).
/* Adds another row to the table. Note the update is NOT persisted
automatically (delete the old file and use write again). */

[table addName:@"Sam" Age:17];

[[NSFileManager defaultManager] removeItemAtPath:@"filename.tightdb" error:nil];
[group write:@"filename.tightdb"];

// Retrieves an in memory buffer from the group.
/* Retrieves an in memory buffer from the group. */

size_t size;
const char *buffer = [group writeToMem:&size];
Expand All @@ -54,14 +54,13 @@ int main()
NSLog(@"Name: %@", cursor.Name);
}

// Caution: Calling free(..) on the "buffer" is sometimes required to avoid leakage. However,
// the group that retrieves data from memeory takes responsibilty for the memory allocation in this example.

// free((char*)buffer); // not needed in this particular situation.
/* Caution: Calling free(..) on the "buffer" is sometimes required to avoid leakage. However,
the group that retrieves data from memeory takes responsibilty for the memory allocation in this example. */

/* free((char*)buffer); */ /* not needed in this particular situation. */
}
}



// @@EndExample@@
/* @@EndExample@@ */
26 changes: 13 additions & 13 deletions doc/ref/examples/ex_objc_query_dynamic_intro.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @@Example: ex_objc_query_dynamic_intro @@
/* @@Example: ex_objc_query_dynamic_intro @@ */

#import <tightdb/objc/table.h>
#import <tightdb/objc/tightdb.h>
Expand All @@ -8,64 +8,64 @@
int main()
{
@autoreleasepool {
// TODO: Update example to the cursor.
/* TODO: Update example to the cursor. */

// Creates a new table dynamically.
/* Creates a new table dynamically. */

TightdbTable *table = [[TightdbTable alloc] init];

size_t const NAME = [table addColumnWithType:tightdb_String andName:@"Name"];
size_t const AGE = [table addColumnWithType:tightdb_Int andName:@"Age"];
size_t const HIRED = [table addColumnWithType:tightdb_Bool andName:@"Hired"];

// Add some people.
/* Add some people. */

// Add rows and values.
/* Add rows and values. */

TightdbCursor *cursor;

// Row 0
/* Row 0 */

cursor = [table addRow];

[cursor setInt:23 inColumn:AGE];
[cursor setString:@"Joe" inColumn:NAME];
[cursor setBool:YES inColumn:HIRED];

// Row 1
/* Row 1 */

cursor = [table addRow];

[cursor setInt:32 inColumn:AGE];
[cursor setString:@"Simon" inColumn:NAME];
[cursor setBool:YES inColumn:HIRED];

// Row 2
/* Row 2 */

cursor = [table addRow];

[cursor setInt:12 inColumn:AGE];
[cursor setString:@"Steve" inColumn:NAME];
[cursor setBool:NO inColumn:HIRED];

// Row 3
/* Row 3 */

cursor = [table addRow];

[cursor setInt:59 inColumn:AGE];
[cursor setString:@"Nick" inColumn:NAME];
[cursor setBool:YES inColumn:HIRED];

// Set up a query to search for employees.
/* Set up a query to search for employees. */

TightdbQuery *q = [[[table where] column: AGE isBetweenInt:0 and_:60]
column: HIRED isEqualToBool:YES];

// Execute the query.
/* Execute the query. */

TightdbView *view = [q findAll];

// Print the names.
/* Print the names. */

for (TightdbCursor *c in view) {

Expand All @@ -79,4 +79,4 @@ int main()
}
}

// @@EndExample@@
/* @@EndExample@@ */
14 changes: 7 additions & 7 deletions doc/ref/examples/ex_objc_query_typed_intro.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// @@Example: ex_objc_query_typed_intro @@
/* @@Example: ex_objc_query_typed_intro @@ */

#import <tightdb/objc/table.h>
#import <tightdb/objc/tightdb.h>

// Defines a new table with two columns Name and Age.
/* Defines a new table with two columns Name and Age. */

TIGHTDB_TABLE_2(PeopleTable,
Name, String,
Expand All @@ -13,23 +13,23 @@ int main()
{
@autoreleasepool {

// Creates a new table of the type defined above.
/* Creates a new table of the type defined above. */

PeopleTable *table = [[PeopleTable alloc] init];

// Adds rows to the table.
/* Adds rows to the table. */

[table addName:@"Brian" Age:14];
[table addName:@"Joe" Age:17];
[table addName:@"Jack" Age:22];
[table addName:@"Sam" Age:34];
[table addName:@"Bob" Age:10];

// Create a query.
/* Create a query. */

PeopleTable_Query *query = [[[[table where].Age columnIsGreaterThan:20] or].Name columnIsEqualTo:@"Bob"];

// Iterate over the query result.
/* Iterate over the query result. */

for (PeopleTable_Cursor *curser in query) {
NSLog(@"Person matching query: %@", [curser Name]);
Expand All @@ -38,4 +38,4 @@ int main()
}
}

// @@EndExample@@
/* @@EndExample@@ */
18 changes: 9 additions & 9 deletions doc/ref/examples/ex_objc_sharedgroup_intro.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @@Example: ex_objc_sharedgroup_intro @@
/* @@Example: ex_objc_sharedgroup_intro @@ */

#import <tightdb/objc/group.h>
#import <tightdb/objc/group_shared.h>
Expand All @@ -14,33 +14,33 @@ int main()
{
@autoreleasepool {

// Creates a group and uses it to create a new table.
/* Creates a group and uses it to create a new table. */

TightdbSharedGroup *shared = [TightdbSharedGroup groupWithFilename:@"sharedgroup.tightdb"];

// A write transaction (with rollback if not first writer to employees table).
/* A write transaction (with rollback if not first writer to employees table). */

[shared writeTransaction:^(TightdbGroup *group) {

// Write transactions with the shared group are possible via the provided variable binding named group.
/* Write transactions with the shared group are possible via the provided variable binding named group. */

PeopleTable *table = [group getTable:@"employees" withClass:[PeopleTable class]];
if ([table count] > 0) {
NSLog(@"Not empty!");
return NO; // Rollback
return NO; /* Rollback */
}

[table addName:@"Bill" Age:53 Hired:YES];
NSLog(@"Row added!");
return YES; // Commit
return YES; /* Commit */

}];

// A read transaction
/* A read transaction */

[shared readTransaction:^(TightdbGroup *group) {

// Read transactions with the shared group are possible via the provided variable binding named group.
/* Read transactions with the shared group are possible via the provided variable binding named group. */

PeopleTable *table = [group getTable:@"employees" withClass:[PeopleTable class]];

Expand All @@ -53,4 +53,4 @@ int main()
}

}
// @@EndExample@@
/* @@EndExample@@ */
24 changes: 12 additions & 12 deletions doc/ref/examples/ex_objc_table_dynamic_intro.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @@Example: ex_objc_table_dynamic_intro @@
/* @@Example: ex_objc_table_dynamic_intro @@ */

#import <tightdb/objc/table.h>
#import <tightdb/objc/tightdb.h>
Expand All @@ -9,52 +9,52 @@ int main()
{
@autoreleasepool {

// Create a new table dynamically.
/* Create a new table dynamically. */

TightdbTable *table = [[TightdbTable alloc] init];

size_t const NAME = [table addColumnWithType:tightdb_String andName:@"Name"];
size_t const AGE = [table addColumnWithType:tightdb_Int andName:@"Age"];

// Add rows and values.
/* Add rows and values. */

TightdbCursor *cursor;

// Row 0
/* Row 0 */

cursor = [table addRow];

[cursor setInt:23 inColumn:AGE];
[cursor setString:@"Joe" inColumn:NAME];

// Row 1
/* Row 1 */

cursor = [table addRow];

[cursor setInt:32 inColumn:AGE];
[cursor setString:@"Simon" inColumn:NAME];

// Row 2
/* Row 2 */

cursor = [table addRow];

[cursor setInt:12 inColumn:AGE];
[cursor setString:@"Steve" inColumn:NAME];

// Row 3
/* Row 3 */

cursor = [table addRow];

[cursor setInt:100 inColumn:AGE];
[cursor setString:@"Nick" inColumn:NAME];

// Print using a cursor.
/* Print using a cursor. */

for (TightdbCursor *ite in table)
NSLog(@"Name: %@ Age: %lld", [ite getStringInColumn:NAME], [ite getIntInColumn:AGE]);


// Insert a row and print.
/* Insert a row and print. */

cursor = [table insertRowAtIndex:2];
[cursor setInt:21 inColumn:AGE];
Expand All @@ -67,7 +67,7 @@ int main()
NSLog(@"Name: %@ Age: %lld", [ite getStringInColumn:NAME], [ite getIntInColumn:AGE]);


// Update a few rows and print again.
/* Update a few rows and print again. */

cursor = [table cursorAtIndex:2];
[cursor setString:@"Now I'm UPDATED" inColumn:NAME];
Expand All @@ -80,7 +80,7 @@ int main()
for (TightdbCursor *ite in table)
NSLog(@"Name: %@ Age: %lld", [ite getStringInColumn:NAME], [ite getIntInColumn:AGE]);

// Index not existing.
/* Index not existing. */

TightdbCursor *c2 = [table cursorAtIndex:[table count]];
if (c2 != nil)
Expand All @@ -90,4 +90,4 @@ int main()
}
}

// @@EndExample@@
/* @@EndExample@@ */
8 changes: 4 additions & 4 deletions doc/ref/examples/ex_objc_table_typed_intro.m
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// @@Example: ex_objc_table_typed_intro @@
/* @@Example: ex_objc_table_typed_intro @@ */


#import <tightdb/objc/table.h>
#import <tightdb/objc/tightdb.h>


// Defines a new table with two columns Name and Age.
/* Defines a new table with two columns Name and Age. */

TIGHTDB_TABLE_2(PeopleTable,
Name, String,
Expand All @@ -16,7 +16,7 @@ int main()
{
@autoreleasepool {

// Creates a new table of the type defined above.
/* Creates a new table of the type defined above. */

PeopleTable *table = [[PeopleTable alloc] init];

Expand Down Expand Up @@ -58,4 +58,4 @@ int main()



// @@EndExample@@
/* @@EndExample@@ */
Loading

0 comments on commit 52e2121

Please sign in to comment.