diff --git a/TightDB.vcxproj b/TightDB.vcxproj index 9c2f3bd5e1e..218ad325767 100644 --- a/TightDB.vcxproj +++ b/TightDB.vcxproj @@ -599,6 +599,7 @@ + diff --git a/TightDB.vcxproj.filters b/TightDB.vcxproj.filters index c469b739b56..d1266af6e00 100644 --- a/TightDB.vcxproj.filters +++ b/TightDB.vcxproj.filters @@ -283,6 +283,9 @@ src\include + + src\include + src\include diff --git a/changelog.txt b/changelog.txt index 903b8b523e3..387c6d13cff 100644 --- a/changelog.txt +++ b/changelog.txt @@ -13,6 +13,10 @@ Format: ================== +2013-02-06 (Kristian Spangsege) ++ New enum DataType replaces ColumnType throughout the public API. + + 2013-01-27 (Kristian Spangsege) + New Group::Group(unattached_tag) added. Same for SharedGroup. + New Group::open(...) methods added. Same for SharedGroup. @@ -25,6 +29,7 @@ Format: - Group::set_shared() removed. - SharedGroup::is_valid() removed. Errors are now reported as exceptions from the constructor. + 2013-01-11 (Kristian Spangsege) + Simplified open-mode for Group constructor. - Group::is_valid() removed. Errors are now reported as exceptions from the constructor. @@ -37,10 +42,12 @@ Format: + Mixed::set_int() added (same for other value types except subtables). + Removed two-argument Mixed constructor for binary data since its signature is expected to be used for strings that are not zero-terminated. + 2013-01-08 (Brian Munkholm) ---------- + New: Added a bunch of methods to support two new column types: float and double. + 2012-12-16 (Kristian Spangsege) ---------- + my_table[i].foo.get() added for all column types except subtables. This is to avoid having to repeat the explicit column type in cast expressions when the actual value is needed. diff --git a/doc/Tutorial/dyntable.cpp b/doc/Tutorial/dyntable.cpp index 044ca39f9e6..ea37a6f1610 100644 --- a/doc/Tutorial/dyntable.cpp +++ b/doc/Tutorial/dyntable.cpp @@ -8,7 +8,7 @@ using namespace std; int main(int argc, char *argv[]) { Table t; - t.add_column(COLUMN_TYPE_STRING, "name"); + t.add_column(type_String, "name"); size_t name_ndx = t.get_column_index("name"); t.add_empty_row(); @@ -18,7 +18,7 @@ int main(int argc, char *argv[]) { t.set_string(name_ndx, 1, "Joe"); // forgot about age - t.add_column(COLUMN_TYPE_INT, "age"); + t.add_column(type_Int, "age"); size_t age_ndx = t.get_column_index("age"); t.set_int(age_ndx, 0, 32); t.set_int(age_ndx, 1, 18); diff --git a/doc/ref_cpp/data/dyn_table_ref.yaml b/doc/ref_cpp/data/dyn_table_ref.yaml index 838f741a7af..fbb323501ed 100644 --- a/doc/ref_cpp/data/dyn_table_ref.yaml +++ b/doc/ref_cpp/data/dyn_table_ref.yaml @@ -225,7 +225,7 @@ CATEGORIES : TYPES : size_t DESCR : The column index. RETURN: - TYPES : ColumnType + TYPES : DataType DESCR : The column type. EXAMPLES: - CODE : ex_cpp_dyn_table_get_column_type @@ -354,7 +354,7 @@ CATEGORIES : const char* get_string(size_t column_ndx, size_t row_ndx) const; BinaryData get_binary(size_t column_ndx, size_t row_ndx) const; Mixed get_mixed(size_t column_ndx, size_t row_ndx) const; - ColumnType get_mixed_type(size_t column_ndx, size_t row_ndx) const + DataType get_mixed_type(size_t column_ndx, size_t row_ndx) const TableRef get_subtable(size_t column_ndx, size_t row_ndx); ConstTableRef get_subtable(size_t column_ndx, size_t row_ndx) const; @@ -367,7 +367,7 @@ CATEGORIES : TYPES : size_t DESCR : The row index. RETURN: - TYPES : [bool, int64_t, time_t, const char*, BinaryData, Mixed, ColumnType] + TYPES : [bool, int64_t, time_t, const char*, BinaryData, Mixed, DataType] DESCR : The value. EXAMPLES: - CODE : ex_cpp_dyn_table_get_xxx diff --git a/doc/ref_cpp/data/dyn_view_ref.yaml b/doc/ref_cpp/data/dyn_view_ref.yaml index 878cb908662..4ca53f17e2a 100644 --- a/doc/ref_cpp/data/dyn_view_ref.yaml +++ b/doc/ref_cpp/data/dyn_view_ref.yaml @@ -186,7 +186,7 @@ CATEGORIES : const char* get_string(size_t column_ndx, size_t row_ndx) const; BinaryData get_binary(size_t column_ndx, size_t row_ndx) const; Mixed get_mixed(size_t column_ndx, size_t row_ndx) const; - ColumnType get_mixed_type(size_t column_ndx, size_t row_ndx) const + DataType get_mixed_type(size_t column_ndx, size_t row_ndx) const TableRef get_subtable(size_t column_ndx, size_t row_ndx); ConstTableRef get_subtable(size_t column_ndx, size_t row_ndx) const; CONST : True @@ -198,7 +198,7 @@ CATEGORIES : TYPES : size_t DESCR : The row index. RETURN: - TYPES : [bool, int64_t, time_t, const char*, BinaryData, Mixed, ColumnType, TableRef, ConstTableRef] + TYPES : [bool, int64_t, time_t, const char*, BinaryData, Mixed, DataType, TableRef, ConstTableRef] DESCR : The value. EXAMPLES: - CODE : ex_cpp_dyn_view_get_xxx diff --git a/doc/ref_cpp/data/mixed_ref.yaml b/doc/ref_cpp/data/mixed_ref.yaml index 50679af1faf..4c6e0219e39 100644 --- a/doc/ref_cpp/data/mixed_ref.yaml +++ b/doc/ref_cpp/data/mixed_ref.yaml @@ -56,7 +56,7 @@ CATEGORIES: This method retrieves the real type of a Mixed variable. CONST : True RETURN: - TYPES : ColumnType + TYPES : DataType DESCR : The type. EXAMPLES: - CODE : ex_cpp_mixed_get_type diff --git a/doc/ref_cpp/data/typed_view_ref.yaml b/doc/ref_cpp/data/typed_view_ref.yaml index a28912f1087..2ca9808c87c 100644 --- a/doc/ref_cpp/data/typed_view_ref.yaml +++ b/doc/ref_cpp/data/typed_view_ref.yaml @@ -128,7 +128,7 @@ CATEGORIES : const char* get_string(size_t row_ndx) const; BinaryData get_binary(size_t row_ndx) const; Mixed get_mixed(size_t row_ndx) const; - ColumnType get_mixed_type(size_t row_ndx) const + DataType get_mixed_type(size_t row_ndx) const TableRef get_subtable(size_t row_ndx); ConstTableRef get_subtable(size_t row_ndx) const; CONST : True @@ -137,7 +137,7 @@ CATEGORIES : TYPES : size_t DESCR : The row index. RETURN: - TYPES : [bool, int64_t, time_t, const char*, BinaryData, Mixed, ColumnType, TableRef, ConstTableRef] + TYPES : [bool, int64_t, time_t, const char*, BinaryData, Mixed, DataType, TableRef, ConstTableRef] DESCR : The value. EXAMPLES: - CODE : ex_cpp_typed_view_get_xxx diff --git a/doc/ref_cpp/examples/ex_query_dynamic_avg.cpp b/doc/ref_cpp/examples/ex_query_dynamic_avg.cpp index 690bbc97a21..e591f6ae079 100644 --- a/doc/ref_cpp/examples/ex_query_dynamic_avg.cpp +++ b/doc/ref_cpp/examples/ex_query_dynamic_avg.cpp @@ -19,8 +19,8 @@ int main() TableRef table = group.get_table("test"); Spec& s = table->get_spec(); - s.add_column(COLUMN_TYPE_STRING, "Name"); - s.add_column(COLUMN_TYPE_INT, "Age"); + s.add_column(type_String, "Name"); + s.add_column(type_Int, "Age"); table->update_from_spec(); table->add_empty_row(3); @@ -44,4 +44,4 @@ int main() assert(avg == (27 + 44) / 2.0); // @@EndShow@@ } -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_dynamic_beginswith.cpp b/doc/ref_cpp/examples/ex_query_dynamic_beginswith.cpp index 8a72075f665..3409cf3f354 100644 --- a/doc/ref_cpp/examples/ex_query_dynamic_beginswith.cpp +++ b/doc/ref_cpp/examples/ex_query_dynamic_beginswith.cpp @@ -10,7 +10,7 @@ int main() TableRef table = group.get_table("test"); Spec& s = table->get_spec(); - s.add_column(COLUMN_TYPE_STRING, "Name"); + s.add_column(type_String, "Name"); table->update_from_spec(); table->add_empty_row(5); @@ -41,4 +41,4 @@ int main() #endif // @@EndShow@@ } -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_dynamic_between.cpp b/doc/ref_cpp/examples/ex_query_dynamic_between.cpp index 199a2b767e3..b07db90f627 100644 --- a/doc/ref_cpp/examples/ex_query_dynamic_between.cpp +++ b/doc/ref_cpp/examples/ex_query_dynamic_between.cpp @@ -20,8 +20,8 @@ int main() TableRef table = group.get_table("test"); Spec& s = table->get_spec(); - s.add_column(COLUMN_TYPE_STRING, "name"); - s.add_column(COLUMN_TYPE_INT, "age"); + s.add_column(type_String, "name"); + s.add_column(type_Int, "age"); table->update_from_spec(); table->add_empty_row(); @@ -46,4 +46,4 @@ int main() assert(!strcmp(view.get_string(0, 1), "Peter")); // @@EndShow@@ } -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_dynamic_constructor.cpp b/doc/ref_cpp/examples/ex_query_dynamic_constructor.cpp index 3bacf175f34..15bf9f94e31 100644 --- a/doc/ref_cpp/examples/ex_query_dynamic_constructor.cpp +++ b/doc/ref_cpp/examples/ex_query_dynamic_constructor.cpp @@ -13,4 +13,4 @@ int main() Query q = table->where(); // @@EndShow@@ } -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_dynamic_contains.cpp b/doc/ref_cpp/examples/ex_query_dynamic_contains.cpp index fe62d029fd2..4d34d4b92eb 100644 --- a/doc/ref_cpp/examples/ex_query_dynamic_contains.cpp +++ b/doc/ref_cpp/examples/ex_query_dynamic_contains.cpp @@ -10,7 +10,7 @@ int main() TableRef table = group.get_table("test"); Spec& s = table->get_spec(); - s.add_column(COLUMN_TYPE_STRING, "Name"); + s.add_column(type_String, "Name"); table->update_from_spec(); table->add_empty_row(5); @@ -39,4 +39,4 @@ int main() #endif // @@EndShow@@ } -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_dynamic_count.cpp b/doc/ref_cpp/examples/ex_query_dynamic_count.cpp index 93a26b6cd38..1a550930a28 100644 --- a/doc/ref_cpp/examples/ex_query_dynamic_count.cpp +++ b/doc/ref_cpp/examples/ex_query_dynamic_count.cpp @@ -34,4 +34,4 @@ int main() assert(count3 == 1); } // @@EndFold@@ -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_dynamic_delete.cpp b/doc/ref_cpp/examples/ex_query_dynamic_delete.cpp index cb9c177f751..f97b495b09a 100644 --- a/doc/ref_cpp/examples/ex_query_dynamic_delete.cpp +++ b/doc/ref_cpp/examples/ex_query_dynamic_delete.cpp @@ -20,8 +20,8 @@ int main() TableRef table = group.get_table("test"); Spec& s = table->get_spec(); - s.add_column(COLUMN_TYPE_STRING, "name"); - s.add_column(COLUMN_TYPE_INT, "age"); + s.add_column(type_String, "name"); + s.add_column(type_Int, "age"); table->update_from_spec(); table->add_empty_row(); @@ -48,4 +48,4 @@ int main() assert(table->size() == 1); // @@EndShow@@ } -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_dynamic_endswith.cpp b/doc/ref_cpp/examples/ex_query_dynamic_endswith.cpp index 03ae8eb0ea2..0be59fd6387 100644 --- a/doc/ref_cpp/examples/ex_query_dynamic_endswith.cpp +++ b/doc/ref_cpp/examples/ex_query_dynamic_endswith.cpp @@ -10,7 +10,7 @@ int main() TableRef table = group.get_table("test"); Spec& s = table->get_spec(); - s.add_column(COLUMN_TYPE_STRING, "Name"); + s.add_column(type_String, "Name"); table->update_from_spec(); table->add_empty_row(5); @@ -41,4 +41,4 @@ int main() #endif // @@EndShow@@ } -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_dynamic_equal.cpp b/doc/ref_cpp/examples/ex_query_dynamic_equal.cpp index b8b5ef5549d..a667589ef4f 100644 --- a/doc/ref_cpp/examples/ex_query_dynamic_equal.cpp +++ b/doc/ref_cpp/examples/ex_query_dynamic_equal.cpp @@ -11,11 +11,11 @@ int main() TableRef table = group.get_table("test"); Spec& s = table->get_spec(); - s.add_column(COLUMN_TYPE_STRING, "name"); - s.add_column(COLUMN_TYPE_INT, "age"); - s.add_column(COLUMN_TYPE_BOOL, "male"); - s.add_column(COLUMN_TYPE_DATE, "hired"); - s.add_column(COLUMN_TYPE_BINARY, "photo"); + s.add_column(type_String, "name"); + s.add_column(type_Int, "age"); + s.add_column(type_Bool, "male"); + s.add_column(type_Date, "hired"); + s.add_column(type_Binary, "photo"); table->update_from_spec(); // @@EndFold@@ @@ -54,4 +54,4 @@ int main() assert(view5.size() == 1 && !strcmp(view5.get_string(0, 0), "Mary")); } // @@EndFold@@ -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_dynamic_find_all.cpp b/doc/ref_cpp/examples/ex_query_dynamic_find_all.cpp index 54023765405..77e3cde3619 100644 --- a/doc/ref_cpp/examples/ex_query_dynamic_find_all.cpp +++ b/doc/ref_cpp/examples/ex_query_dynamic_find_all.cpp @@ -20,8 +20,8 @@ int main() TableRef table = group.get_table("test"); Spec& s = table->get_spec(); - s.add_column(COLUMN_TYPE_STRING, "name"); - s.add_column(COLUMN_TYPE_INT, "age"); + s.add_column(type_String, "name"); + s.add_column(type_Int, "age"); table->update_from_spec(); table->add_empty_row(); @@ -54,4 +54,4 @@ int main() assert(!strcmp(view.get_string(0, 1), "Peter")); // @@EndShow@@ } -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_dynamic_find_next.cpp b/doc/ref_cpp/examples/ex_query_dynamic_find_next.cpp index 3e5a806692e..3ef97e66100 100644 --- a/doc/ref_cpp/examples/ex_query_dynamic_find_next.cpp +++ b/doc/ref_cpp/examples/ex_query_dynamic_find_next.cpp @@ -20,8 +20,8 @@ int main() TableRef table = group.get_table("test"); Spec& s = table->get_spec(); - s.add_column(COLUMN_TYPE_STRING, "name"); - s.add_column(COLUMN_TYPE_INT, "age"); + s.add_column(type_String, "name"); + s.add_column(type_Int, "age"); table->update_from_spec(); table->add_empty_row(); @@ -53,4 +53,4 @@ int main() assert(match == size_t(-1)); // @@EndShow@@ } -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_dynamic_greater.cpp b/doc/ref_cpp/examples/ex_query_dynamic_greater.cpp index 9833af3ed90..9f660fe99ff 100644 --- a/doc/ref_cpp/examples/ex_query_dynamic_greater.cpp +++ b/doc/ref_cpp/examples/ex_query_dynamic_greater.cpp @@ -20,8 +20,8 @@ int main() TableRef table = group.get_table("test"); Spec& s = table->get_spec(); - s.add_column(COLUMN_TYPE_STRING, "name"); - s.add_column(COLUMN_TYPE_INT, "age"); + s.add_column(type_String, "name"); + s.add_column(type_Int, "age"); table->update_from_spec(); table->add_empty_row(); @@ -46,4 +46,4 @@ int main() assert(!strcmp(view.get_string(0, 1), string("Peter"))); // @@EndShow@@ } -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_dynamic_greater_equal.cpp b/doc/ref_cpp/examples/ex_query_dynamic_greater_equal.cpp index af9cb7b9d46..b0b997c5f26 100644 --- a/doc/ref_cpp/examples/ex_query_dynamic_greater_equal.cpp +++ b/doc/ref_cpp/examples/ex_query_dynamic_greater_equal.cpp @@ -20,8 +20,8 @@ int main() TableRef table = group.get_table("test"); Spec& s = table->get_spec(); - s.add_column(COLUMN_TYPE_STRING, "name"); - s.add_column(COLUMN_TYPE_INT, "age"); + s.add_column(type_String, "name"); + s.add_column(type_Int, "age"); table->update_from_spec(); table->add_empty_row(); @@ -46,4 +46,4 @@ int main() assert(!strcmp(view.get_string(0, 1), "Peter")); // @@EndShow@@ } -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_dynamic_group.cpp b/doc/ref_cpp/examples/ex_query_dynamic_group.cpp index a85fbc7f3cf..8aa1acde4dc 100644 --- a/doc/ref_cpp/examples/ex_query_dynamic_group.cpp +++ b/doc/ref_cpp/examples/ex_query_dynamic_group.cpp @@ -22,8 +22,8 @@ int main() TableRef table = group.get_table("test"); Spec& s = table->get_spec(); - s.add_column(COLUMN_TYPE_STRING, "name"); - s.add_column(COLUMN_TYPE_INT, "age"); + s.add_column(type_String, "name"); + s.add_column(type_Int, "age"); table->update_from_spec(); table->add_empty_row(); @@ -57,4 +57,4 @@ int main() assert(!strcmp(view.get_string(0, 2), "Alice")); // @@EndShow@@ } -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_dynamic_intro.cpp b/doc/ref_cpp/examples/ex_query_dynamic_intro.cpp index e17e42b4ce2..27b8218b0d7 100644 --- a/doc/ref_cpp/examples/ex_query_dynamic_intro.cpp +++ b/doc/ref_cpp/examples/ex_query_dynamic_intro.cpp @@ -20,8 +20,8 @@ int main() TableRef table = group.get_table("test"); Spec& s = table->get_spec(); - s.add_column(COLUMN_TYPE_STRING, "name"); - s.add_column(COLUMN_TYPE_INT, "age"); + s.add_column(type_String, "name"); + s.add_column(type_Int, "age"); table->update_from_spec(); table->add_empty_row(); @@ -45,4 +45,4 @@ int main() assert(!strcmp(view.get_string(0, 0), "Peter")); // @@EndShow@@ } -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_dynamic_less.cpp b/doc/ref_cpp/examples/ex_query_dynamic_less.cpp index 4a3e2eb1140..889f0e703c8 100644 --- a/doc/ref_cpp/examples/ex_query_dynamic_less.cpp +++ b/doc/ref_cpp/examples/ex_query_dynamic_less.cpp @@ -20,8 +20,8 @@ int main() TableRef table = group.get_table("test"); Spec& s = table->get_spec(); - s.add_column(COLUMN_TYPE_STRING, "name"); - s.add_column(COLUMN_TYPE_INT, "age"); + s.add_column(type_String, "name"); + s.add_column(type_Int, "age"); table->update_from_spec(); table->add_empty_row(); @@ -45,4 +45,4 @@ int main() assert(!strcmp(view.get_string(0, 0), "Alice")); // @@EndShow@@ } -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_dynamic_less_equal.cpp b/doc/ref_cpp/examples/ex_query_dynamic_less_equal.cpp index bb026f6e683..6327f348afc 100644 --- a/doc/ref_cpp/examples/ex_query_dynamic_less_equal.cpp +++ b/doc/ref_cpp/examples/ex_query_dynamic_less_equal.cpp @@ -20,8 +20,8 @@ int main() TableRef table = group.get_table("test"); Spec& s = table->get_spec(); - s.add_column(COLUMN_TYPE_STRING, "name"); - s.add_column(COLUMN_TYPE_INT, "age"); + s.add_column(type_String, "name"); + s.add_column(type_Int, "age"); table->update_from_spec(); table->add_empty_row(); @@ -46,4 +46,4 @@ int main() assert(!strcmp(view.get_string(0, 1), "Peter")); // @@EndShow@@ } -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_dynamic_max.cpp b/doc/ref_cpp/examples/ex_query_dynamic_max.cpp index a5015ad8871..1e858ac506a 100644 --- a/doc/ref_cpp/examples/ex_query_dynamic_max.cpp +++ b/doc/ref_cpp/examples/ex_query_dynamic_max.cpp @@ -19,8 +19,8 @@ int main() TableRef table = group.get_table("test"); Spec& s = table->get_spec(); - s.add_column(COLUMN_TYPE_STRING, "Name"); - s.add_column(COLUMN_TYPE_INT, "Age"); + s.add_column(type_String, "Name"); + s.add_column(type_Int, "Age"); table->update_from_spec(); table->add_empty_row(); diff --git a/doc/ref_cpp/examples/ex_query_dynamic_min.cpp b/doc/ref_cpp/examples/ex_query_dynamic_min.cpp index 50b9a997db3..9f4e24fd25c 100644 --- a/doc/ref_cpp/examples/ex_query_dynamic_min.cpp +++ b/doc/ref_cpp/examples/ex_query_dynamic_min.cpp @@ -19,8 +19,8 @@ int main() TableRef table = group.get_table("test"); Spec& s = table->get_spec(); - s.add_column(COLUMN_TYPE_STRING, "Name"); - s.add_column(COLUMN_TYPE_INT, "Age"); + s.add_column(type_String, "Name"); + s.add_column(type_Int, "Age"); table->update_from_spec(); table->add_empty_row(); diff --git a/doc/ref_cpp/examples/ex_query_dynamic_not_equal.cpp b/doc/ref_cpp/examples/ex_query_dynamic_not_equal.cpp index d6cb52b9801..870dda54a71 100644 --- a/doc/ref_cpp/examples/ex_query_dynamic_not_equal.cpp +++ b/doc/ref_cpp/examples/ex_query_dynamic_not_equal.cpp @@ -19,8 +19,8 @@ int main() TableRef table = group.get_table("test"); Spec& s = table->get_spec(); - s.add_column(COLUMN_TYPE_STRING, "name"); - s.add_column(COLUMN_TYPE_INT, "age"); + s.add_column(type_String, "name"); + s.add_column(type_Int, "age"); table->update_from_spec(); table->add_empty_row(); @@ -43,4 +43,4 @@ int main() assert(!strcmp(view.get_string(0, 0), "Alice")); // @@EndShow@@ } -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_dynamic_or.cpp b/doc/ref_cpp/examples/ex_query_dynamic_or.cpp index a3e4122bc09..649b3818f9b 100644 --- a/doc/ref_cpp/examples/ex_query_dynamic_or.cpp +++ b/doc/ref_cpp/examples/ex_query_dynamic_or.cpp @@ -22,8 +22,8 @@ int main() TableRef table = group.get_table("test"); Spec& s = table->get_spec(); - s.add_column(COLUMN_TYPE_STRING, "name"); - s.add_column(COLUMN_TYPE_INT, "age"); + s.add_column(type_String, "name"); + s.add_column(type_Int, "age"); table->update_from_spec(); table->add_empty_row(4); @@ -49,4 +49,4 @@ int main() assert(!strcmp(view.get_string(0, 1), "Jack")); // @@EndShow@@ } -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_dynamic_sum.cpp b/doc/ref_cpp/examples/ex_query_dynamic_sum.cpp index efffb8ec6ce..5ec432fc364 100644 --- a/doc/ref_cpp/examples/ex_query_dynamic_sum.cpp +++ b/doc/ref_cpp/examples/ex_query_dynamic_sum.cpp @@ -19,8 +19,8 @@ int main() TableRef table = group.get_table("test"); Spec& s = table->get_spec(); - s.add_column(COLUMN_TYPE_STRING, "Name"); - s.add_column(COLUMN_TYPE_INT, "Age"); + s.add_column(type_String, "Name"); + s.add_column(type_Int, "Age"); table->update_from_spec(); table->add_empty_row(); diff --git a/doc/ref_cpp/examples/ex_query_typed_avg.cpp b/doc/ref_cpp/examples/ex_query_typed_avg.cpp index 1395d943f35..d364361135a 100644 --- a/doc/ref_cpp/examples/ex_query_typed_avg.cpp +++ b/doc/ref_cpp/examples/ex_query_typed_avg.cpp @@ -32,4 +32,4 @@ int main() assert(avg2 == (60.0 + 70.0) / 2.0); } // @@EndFold@@ -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_typed_beginswith.cpp b/doc/ref_cpp/examples/ex_query_typed_beginswith.cpp index 1a1da3b1320..8adbc2d23c2 100644 --- a/doc/ref_cpp/examples/ex_query_typed_beginswith.cpp +++ b/doc/ref_cpp/examples/ex_query_typed_beginswith.cpp @@ -37,4 +37,4 @@ int main() // @@Fold@@ } // @@EndFold@@ -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_typed_between.cpp b/doc/ref_cpp/examples/ex_query_typed_between.cpp index df93ca10383..a1a8e0fa98f 100644 --- a/doc/ref_cpp/examples/ex_query_typed_between.cpp +++ b/doc/ref_cpp/examples/ex_query_typed_between.cpp @@ -33,4 +33,4 @@ int main() assert(view5.size() == 1 && !strcmp(view5[0].name, "Jack")); } // @@EndFold@@ -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_typed_constructor.cpp b/doc/ref_cpp/examples/ex_query_typed_constructor.cpp index f881a9d1523..287e5fc0ebe 100644 --- a/doc/ref_cpp/examples/ex_query_typed_constructor.cpp +++ b/doc/ref_cpp/examples/ex_query_typed_constructor.cpp @@ -19,4 +19,4 @@ void main() // Expected result assert(query.count() == 3); } -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_typed_count.cpp b/doc/ref_cpp/examples/ex_query_typed_count.cpp index 4eeedc4501b..dcb9650988d 100644 --- a/doc/ref_cpp/examples/ex_query_typed_count.cpp +++ b/doc/ref_cpp/examples/ex_query_typed_count.cpp @@ -35,4 +35,4 @@ int main() // @@Fold@@ } // @@EndFold@@ -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_typed_equal.cpp b/doc/ref_cpp/examples/ex_query_typed_equal.cpp index 1fa4e897003..560afc580c9 100644 --- a/doc/ref_cpp/examples/ex_query_typed_equal.cpp +++ b/doc/ref_cpp/examples/ex_query_typed_equal.cpp @@ -54,4 +54,4 @@ int main() // assert(view6.size() == 1 && view6[0].name == "Bob"); } // @@EndFold@@ -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_typed_find_all.cpp b/doc/ref_cpp/examples/ex_query_typed_find_all.cpp index 257d46aeec0..df9cd7e51fb 100644 --- a/doc/ref_cpp/examples/ex_query_typed_find_all.cpp +++ b/doc/ref_cpp/examples/ex_query_typed_find_all.cpp @@ -61,4 +61,4 @@ int main() assert(view4[1].name == "Peter"); } // @@EndFold@@ -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_typed_find_next.cpp b/doc/ref_cpp/examples/ex_query_typed_find_next.cpp index 19841fcbb73..98cf466239d 100644 --- a/doc/ref_cpp/examples/ex_query_typed_find_next.cpp +++ b/doc/ref_cpp/examples/ex_query_typed_find_next.cpp @@ -36,4 +36,4 @@ int main() // @@Fold@@ } // @@EndFold@@ -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_typed_greater.cpp b/doc/ref_cpp/examples/ex_query_typed_greater.cpp index 5d0c79860f8..335fb1f102c 100644 --- a/doc/ref_cpp/examples/ex_query_typed_greater.cpp +++ b/doc/ref_cpp/examples/ex_query_typed_greater.cpp @@ -24,4 +24,4 @@ int main() assert(!strcmp(view1[1].name, "Jack")); } // @@EndExample@@ -// @@EndFold@@ \ No newline at end of file +// @@EndFold@@ diff --git a/doc/ref_cpp/examples/ex_query_typed_greater_equal.cpp b/doc/ref_cpp/examples/ex_query_typed_greater_equal.cpp index bcebca08cd2..8c644d7682e 100644 --- a/doc/ref_cpp/examples/ex_query_typed_greater_equal.cpp +++ b/doc/ref_cpp/examples/ex_query_typed_greater_equal.cpp @@ -24,4 +24,4 @@ int main() assert(!strcmp(view1[1].name, "Jack")); } // @@EndExample@@ -// @@EndFold@@ \ No newline at end of file +// @@EndFold@@ diff --git a/doc/ref_cpp/examples/ex_query_typed_group.cpp b/doc/ref_cpp/examples/ex_query_typed_group.cpp index 218119b09cb..6f55a945cc3 100644 --- a/doc/ref_cpp/examples/ex_query_typed_group.cpp +++ b/doc/ref_cpp/examples/ex_query_typed_group.cpp @@ -34,4 +34,4 @@ void main() assert(!strcmp(view[2].name, "Alice")); } // @@EndFold@@ -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_typed_intro.cpp b/doc/ref_cpp/examples/ex_query_typed_intro.cpp index fa1b812a864..40028afd14e 100644 --- a/doc/ref_cpp/examples/ex_query_typed_intro.cpp +++ b/doc/ref_cpp/examples/ex_query_typed_intro.cpp @@ -22,4 +22,4 @@ void main() assert(!strcmp(view1[0].name, "Mary")); assert(!strcmp(view1[1].name, "Joe")); } -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_typed_less.cpp b/doc/ref_cpp/examples/ex_query_typed_less.cpp index ff2ad9e1642..cbd8bae7fb2 100644 --- a/doc/ref_cpp/examples/ex_query_typed_less.cpp +++ b/doc/ref_cpp/examples/ex_query_typed_less.cpp @@ -23,4 +23,4 @@ int main() assert(!strcmp(view1[0].name, "Mary")); } // @@Fold@@ -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_typed_max.cpp b/doc/ref_cpp/examples/ex_query_typed_max.cpp index 2fbe5b9a415..d3494158c93 100644 --- a/doc/ref_cpp/examples/ex_query_typed_max.cpp +++ b/doc/ref_cpp/examples/ex_query_typed_max.cpp @@ -29,4 +29,4 @@ void main() assert(weight == 40); } // @@EndFold@@ -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_typed_min.cpp b/doc/ref_cpp/examples/ex_query_typed_min.cpp index 0644f78e4f7..0b159d27dfe 100644 --- a/doc/ref_cpp/examples/ex_query_typed_min.cpp +++ b/doc/ref_cpp/examples/ex_query_typed_min.cpp @@ -31,4 +31,4 @@ void main() } // @@EndFold@@ -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_typed_not_equal.cpp b/doc/ref_cpp/examples/ex_query_typed_not_equal.cpp index 48e9fc74dc1..207fce75e78 100644 --- a/doc/ref_cpp/examples/ex_query_typed_not_equal.cpp +++ b/doc/ref_cpp/examples/ex_query_typed_not_equal.cpp @@ -27,4 +27,4 @@ int main() assert(view2.size() == 1 && !strcmp(view2[0].name, "Mary")); } // @@EndFold@@ -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_typed_or.cpp b/doc/ref_cpp/examples/ex_query_typed_or.cpp index 8569acd8565..340c8a4ac29 100644 --- a/doc/ref_cpp/examples/ex_query_typed_or.cpp +++ b/doc/ref_cpp/examples/ex_query_typed_or.cpp @@ -26,4 +26,4 @@ int main() assert(!strcmp(view[1].name, "Joe")); } // @@EndFold@@ -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/doc/ref_cpp/examples/ex_query_typed_sum.cpp b/doc/ref_cpp/examples/ex_query_typed_sum.cpp index c639c667373..b7bea00c313 100644 --- a/doc/ref_cpp/examples/ex_query_typed_sum.cpp +++ b/doc/ref_cpp/examples/ex_query_typed_sum.cpp @@ -25,4 +25,4 @@ int main() assert(weight == 75); } // @@EndFold@@ -// @@EndExample@@ \ No newline at end of file +// @@EndExample@@ diff --git a/src/tightdb/Makefile b/src/tightdb/Makefile index 00541d07b79..32d3ba2779d 100644 --- a/src/tightdb/Makefile +++ b/src/tightdb/Makefile @@ -4,10 +4,10 @@ GENERATED_SOURCES = $(TABLE_MACROS_HPP) INST_HEADERS = config.h meta.hpp assert.hpp exceptions.hpp terminate.hpp type_list.hpp tuple.hpp \ safe_int_ops.hpp unique_ptr.hpp bind_ptr.hpp string_buffer.hpp file.hpp pthread_helpers.hpp \ -utf8.hpp utilities.hpp alloc.hpp alloc_slab.hpp array.hpp array_string.hpp column_type.hpp \ -column_fwd.hpp column.hpp column_tpl.hpp spec.hpp date.hpp binary_data.hpp mixed.hpp table.hpp \ -table_ref.hpp table_basic_fwd.hpp table_accessors.hpp table_basic.hpp table_view.hpp \ -table_view_basic.hpp $(TABLE_MACROS_HPP) group.hpp group_shared.hpp query.hpp \ +utf8.hpp utilities.hpp alloc.hpp alloc_slab.hpp array.hpp array_string.hpp data_type.hpp \ +column_type.hpp column_fwd.hpp column.hpp column_tpl.hpp spec.hpp date.hpp binary_data.hpp \ +mixed.hpp table.hpp table_ref.hpp table_basic_fwd.hpp table_accessors.hpp table_basic.hpp \ +table_view.hpp table_view_basic.hpp $(TABLE_MACROS_HPP) group.hpp group_shared.hpp query.hpp \ query_conditions.hpp lang_bind_helper.hpp tightdb_nmmintrin.h replication.hpp lib_LIBRARIES = libtightdb.a diff --git a/src/tightdb/column_mixed.cpp b/src/tightdb/column_mixed.cpp index 815aaf180c0..344f54496e4 100644 --- a/src/tightdb/column_mixed.cpp +++ b/src/tightdb/column_mixed.cpp @@ -142,18 +142,18 @@ void ColumnMixed::Clear() { m_types->Clear(); m_refs->Clear(); - if (m_data) + if (m_data) m_data->Clear(); } -ColumnType ColumnMixed::GetType(size_t ndx) const TIGHTDB_NOEXCEPT +DataType ColumnMixed::get_type(size_t ndx) const TIGHTDB_NOEXCEPT { TIGHTDB_ASSERT(ndx < m_types->Size()); MixedColType coltype = static_cast(m_types->Get(ndx)); switch (coltype) { - case MIXED_COL_INT_NEG: return COLUMN_TYPE_INT; - case MIXED_COL_DOUBLE_NEG: return COLUMN_TYPE_DOUBLE; - default: return static_cast(coltype); // all others must be in sync with ColumnType + case MIXED_COL_INT_NEG: return type_Int; + case MIXED_COL_DOUBLE_NEG: return type_Double; + default: return static_cast(coltype); // all others must be in sync with ColumnType } } @@ -168,7 +168,7 @@ void ColumnMixed::fill(size_t count) m_types->Insert(i, MIXED_COL_INT); } for (size_t i = 0; i < count; ++i) { - m_refs->Insert(i, 1); // 1 is zero shifted one and low bit set; + m_refs->Insert(i, 1); // 1 is zero shifted one and low bit set; } #ifdef TIGHTDB_DEBUG @@ -247,50 +247,51 @@ void ColumnMixed::set_binary(size_t ndx, const char* value, size_t len) bool ColumnMixed::Compare(const ColumnMixed& c) const { const size_t n = Size(); - if (c.Size() != n) + if (c.Size() != n) return false; - + for (size_t i=0; iget_table_ref(); ConstTableRef t2 = c.get_subtable_ptr(i)->get_table_ref(); - if (*t1 != *t2) + if (*t1 != *t2) return false; } break; - default: + case type_Mixed: TIGHTDB_ASSERT(false); + break; } } return true; diff --git a/src/tightdb/column_mixed.hpp b/src/tightdb/column_mixed.hpp index b066793a015..c2efd956c3c 100644 --- a/src/tightdb/column_mixed.hpp +++ b/src/tightdb/column_mixed.hpp @@ -72,7 +72,7 @@ class ColumnMixed : public ColumnBase { void SetParent(ArrayParent* parent, size_t pndx); void UpdateFromParent(); - ColumnType GetType(size_t ndx) const TIGHTDB_NOEXCEPT; + DataType get_type(size_t ndx) const TIGHTDB_NOEXCEPT; size_t Size() const TIGHTDB_NOEXCEPT TIGHTDB_OVERRIDE { return m_types->Size(); } bool is_empty() const TIGHTDB_NOEXCEPT { return m_types->is_empty(); } @@ -119,7 +119,7 @@ class ColumnMixed : public ColumnBase { // Indexing bool HasIndex() const {return false;} - void BuildIndex(Index& index) {(void)index;} + void BuildIndex(Index& index) { static_cast(index); } void ClearIndex() {} size_t GetRef() const {return m_array->GetRef();} @@ -163,7 +163,7 @@ class ColumnMixed : public ColumnBase { }; void clear_value(size_t ndx, MixedColType newtype); - + // Get/set/insert 64-bit values in m_refs/m_types int64_t get_value(size_t ndx) const; void set_value(size_t ndx, int64_t value, MixedColType coltype); @@ -179,10 +179,10 @@ class ColumnMixed : public ColumnBase { // (By having a type for both positive numbers, and another type for negative numbers) Column* m_types; - // Bit 0 is used to indicate if it's a reference. + // Bit 0 is used to indicate if it's a reference. // If not, the data value is stored (shifted 1 bit left). And the sign bit is stored in m_types. - RefsColumn* m_refs; - + RefsColumn* m_refs; + // m_data holds any Binary/String data - if needed. ColumnBinary* m_data; }; diff --git a/src/tightdb/column_mixed_tpl.hpp b/src/tightdb/column_mixed_tpl.hpp index 63ee15800a1..1056e270842 100644 --- a/src/tightdb/column_mixed_tpl.hpp +++ b/src/tightdb/column_mixed_tpl.hpp @@ -44,7 +44,7 @@ inline size_t ColumnMixed::get_subtable_size(size_t row_idx) const TIGHTDB_NOEXC // size from it. Maybe it is faster in general to check for the // the presence of the cached object and use it when available. TIGHTDB_ASSERT(row_idx < m_types->Size()); - if (m_types->Get(row_idx) != COLUMN_TYPE_TABLE) return 0; + if (m_types->Get(row_idx) != type_Table) return 0; const size_t top_ref = m_refs->GetAsRef(row_idx); const size_t columns_ref = Array(top_ref, 0, 0, m_refs->GetAllocator()).GetAsRef(1); const Array columns(columns_ref, 0, 0, m_refs->GetAllocator()); @@ -56,7 +56,7 @@ inline size_t ColumnMixed::get_subtable_size(size_t row_idx) const TIGHTDB_NOEXC inline Table* ColumnMixed::get_subtable_ptr(size_t row_idx) const { TIGHTDB_ASSERT(row_idx < m_types->Size()); - if (m_types->Get(row_idx) != COLUMN_TYPE_TABLE) + if (m_types->Get(row_idx) != type_Table) return 0; return m_refs->get_subtable_ptr(row_idx); } diff --git a/src/tightdb/column_type.hpp b/src/tightdb/column_type.hpp index ace9d409c39..dde73aaeb5f 100644 --- a/src/tightdb/column_type.hpp +++ b/src/tightdb/column_type.hpp @@ -22,41 +22,27 @@ namespace tightdb { -// Note: tightdb_objc/Deliv/ColumnType.h must be kept in sync with his file. -// Note: tightdb_java2/src/main/java/ColumnType.java must be kept in sync with his file. - -// FIXME: The namespace of all-upper-case names must be considered -// reserved for macros. Consider renaming 'COLUMN_TYPE_INT' to -// 'type_Int', COLUMN_TYPE_STRING_ENUM to 'type_StringEnum', and so -// forth. That is, a qualifying prefix followed by the enumeration -// name in CamelCase. This is a reasonably common naming scheme for -// enumeration values. Note that I am also suggesting that we drop -// 'column' from the names, since these types a used much more -// generally than as just 'column types'. -// -// Note: must be kept in sync with his file. -// Note: must be kept in sync with his file. -// Note: "com/tightdb/ColumnType.java" must be kept in sync with his file. +// Note: Value assignments must be kept in sync with enum ColumnType { // Column types - COLUMN_TYPE_INT = 0, - COLUMN_TYPE_BOOL = 1, - COLUMN_TYPE_STRING = 2, - COLUMN_TYPE_STRING_ENUM = 3, // double refs - COLUMN_TYPE_BINARY = 4, - COLUMN_TYPE_TABLE = 5, - COLUMN_TYPE_MIXED = 6, - COLUMN_TYPE_DATE = 7, - COLUMN_TYPE_RESERVED1 = 8, // DateTime - COLUMN_TYPE_FLOAT = 9, // Float - COLUMN_TYPE_DOUBLE = 10, // Double - COLUMN_TYPE_RESERVED4 = 11, // Decimal + col_type_Int = 0, + col_type_Bool = 1, + col_type_String = 2, + col_type_StringEnum = 3, // double refs + col_type_Binary = 4, + col_type_Table = 5, + col_type_Mixed = 6, + col_type_Date = 7, + col_type_Reserved1 = 8, // DateTime + col_type_Float = 9, + col_type_Double = 10, + col_type_Reserved4 = 11, // Decimal // Attributes - COLUMN_ATTR_INDEXED = 100, - COLUMN_ATTR_UNIQUE = 101, - COLUMN_ATTR_SORTED = 102, - COLUMN_ATTR_NONE = 103 + col_attr_Indexed = 100, + col_attr_Unique = 101, + col_attr_Sorted = 102, + col_attr_None = 103 }; diff --git a/src/tightdb/data_type.hpp b/src/tightdb/data_type.hpp new file mode 100644 index 00000000000..fe2bd730873 --- /dev/null +++ b/src/tightdb/data_type.hpp @@ -0,0 +1,44 @@ +/************************************************************************* + * + * TIGHTDB CONFIDENTIAL + * __________________ + * + * [2011] - [2012] TightDB Inc + * All Rights Reserved. + * + * NOTICE: All information contained herein is, and remains + * the property of TightDB Incorporated and its suppliers, + * if any. The intellectual and technical concepts contained + * herein are proprietary to TightDB Incorporated + * and its suppliers and may be covered by U.S. and Foreign Patents, + * patents in process, and are protected by trade secret or copyright law. + * Dissemination of this information or reproduction of this material + * is strictly forbidden unless prior written permission is obtained + * from TightDB Incorporated. + * + **************************************************************************/ +#ifndef TIGHTDB_DATA_TYPE_HPP +#define TIGHTDB_DATA_TYPE_HPP + +namespace tightdb { + +// Note: Value assignments must be kept in sync with +// Note: Value assignments must be kept in sync with +// Note: Value assignments must be kept in sync with +// Note: Value assignments must be kept in sync with "com/tightdb/ColumnType.java" +enum DataType { + type_Int = 0, + type_Bool = 1, + type_Date = 7, + type_Float = 9, + type_Double = 10, + type_String = 2, + type_Binary = 4, + type_Table = 5, + type_Mixed = 6 +}; + + +} // namespace tightdb + +#endif // TIGHTDB_DATA_TYPE_HPP diff --git a/src/tightdb/mixed.hpp b/src/tightdb/mixed.hpp index 0edef683f75..f0459c37726 100644 --- a/src/tightdb/mixed.hpp +++ b/src/tightdb/mixed.hpp @@ -27,7 +27,7 @@ #include #include -#include +#include #include #include @@ -47,9 +47,9 @@ class Mixed { Mixed(Date) TIGHTDB_NOEXCEPT; struct subtable_tag {}; - Mixed(subtable_tag) TIGHTDB_NOEXCEPT: m_type(COLUMN_TYPE_TABLE) {} + Mixed(subtable_tag) TIGHTDB_NOEXCEPT: m_type(type_Table) {} - ColumnType get_type() const TIGHTDB_NOEXCEPT { return m_type; } + DataType get_type() const TIGHTDB_NOEXCEPT { return m_type; } bool get_bool() const TIGHTDB_NOEXCEPT; int64_t get_int() const TIGHTDB_NOEXCEPT; @@ -72,7 +72,7 @@ class Mixed { friend std::basic_ostream& operator<<(std::basic_ostream&, const Mixed&); private: - ColumnType m_type; + DataType m_type; union { int64_t m_int; bool m_bool; @@ -85,7 +85,7 @@ class Mixed { }; // Note: We cannot compare two mixed values, since when the type of -// both is COLUMN_TYPE_TABLE, we would have to compare the two tables, +// both is type_Table, we would have to compare the two tables, // but the mixed values do not provide access to those tables. // Note: The mixed values are specified as Wrap. If they were @@ -146,122 +146,122 @@ bool operator!=(Date, Wrap) TIGHTDB_NOEXCEPT; inline Mixed::Mixed() TIGHTDB_NOEXCEPT { - m_type = COLUMN_TYPE_INT; + m_type = type_Int; m_int = 0; } inline Mixed::Mixed(bool v) TIGHTDB_NOEXCEPT { - m_type = COLUMN_TYPE_BOOL; + m_type = type_Bool; m_bool = v; } inline Mixed::Mixed(int64_t v) TIGHTDB_NOEXCEPT { - m_type = COLUMN_TYPE_INT; + m_type = type_Int; m_int = v; } inline Mixed::Mixed(float v) TIGHTDB_NOEXCEPT { - m_type = COLUMN_TYPE_FLOAT; + m_type = type_Float; m_float = v; } inline Mixed::Mixed(double v) TIGHTDB_NOEXCEPT { - m_type = COLUMN_TYPE_DOUBLE; + m_type = type_Double; m_double = v; } inline Mixed::Mixed(const char* v) TIGHTDB_NOEXCEPT { - m_type = COLUMN_TYPE_STRING; + m_type = type_String; m_str = v; } inline Mixed::Mixed(BinaryData v) TIGHTDB_NOEXCEPT { - m_type = COLUMN_TYPE_BINARY; + m_type = type_Binary; m_str = v.pointer; m_len = v.len; } inline Mixed::Mixed(Date v) TIGHTDB_NOEXCEPT { - m_type = COLUMN_TYPE_DATE; + m_type = type_Date; m_date = v.get_date(); } inline bool Mixed::get_bool() const TIGHTDB_NOEXCEPT { - TIGHTDB_ASSERT(m_type == COLUMN_TYPE_BOOL); + TIGHTDB_ASSERT(m_type == type_Bool); return m_bool; } inline int64_t Mixed::get_int() const TIGHTDB_NOEXCEPT { - TIGHTDB_ASSERT(m_type == COLUMN_TYPE_INT); + TIGHTDB_ASSERT(m_type == type_Int); return m_int; } inline float Mixed::get_float() const TIGHTDB_NOEXCEPT { - TIGHTDB_ASSERT(m_type == COLUMN_TYPE_FLOAT); + TIGHTDB_ASSERT(m_type == type_Float); return m_float; } inline double Mixed::get_double() const TIGHTDB_NOEXCEPT { - TIGHTDB_ASSERT(m_type == COLUMN_TYPE_DOUBLE); + TIGHTDB_ASSERT(m_type == type_Double); return m_double; } inline const char* Mixed::get_string() const TIGHTDB_NOEXCEPT { - TIGHTDB_ASSERT(m_type == COLUMN_TYPE_STRING); + TIGHTDB_ASSERT(m_type == type_String); return m_str; } inline BinaryData Mixed::get_binary() const TIGHTDB_NOEXCEPT { - TIGHTDB_ASSERT(m_type == COLUMN_TYPE_BINARY); + TIGHTDB_ASSERT(m_type == type_Binary); return BinaryData(m_str, m_len); } inline std::time_t Mixed::get_date() const TIGHTDB_NOEXCEPT { - TIGHTDB_ASSERT(m_type == COLUMN_TYPE_DATE); + TIGHTDB_ASSERT(m_type == type_Date); return m_date; } inline void Mixed::set_bool(bool v) TIGHTDB_NOEXCEPT { - m_type = COLUMN_TYPE_BOOL; + m_type = type_Bool; m_bool = v; } inline void Mixed::set_int(int64_t v) TIGHTDB_NOEXCEPT { - m_type = COLUMN_TYPE_INT; + m_type = type_Int; m_int = v; } inline void Mixed::set_float(float v) TIGHTDB_NOEXCEPT { - m_type = COLUMN_TYPE_FLOAT; + m_type = type_Float; m_float = v; } inline void Mixed::set_double(double v) TIGHTDB_NOEXCEPT { - m_type = COLUMN_TYPE_DOUBLE; + m_type = type_Double; m_double = v; } inline void Mixed::set_string(const char* v) TIGHTDB_NOEXCEPT { - m_type = COLUMN_TYPE_STRING; + m_type = type_String; m_str = v; } @@ -272,14 +272,14 @@ inline void Mixed::set_binary(BinaryData v) TIGHTDB_NOEXCEPT inline void Mixed::set_binary(const char* data, std::size_t size) TIGHTDB_NOEXCEPT { - m_type = COLUMN_TYPE_BINARY; + m_type = type_Binary; m_str = data; m_len = size; } inline void Mixed::set_date(std::time_t v) TIGHTDB_NOEXCEPT { - m_type = COLUMN_TYPE_DATE; + m_type = type_Date; m_date = v; } @@ -289,41 +289,41 @@ inline std::basic_ostream& operator<<(std::basic_ostream& out, c { out << "Mixed("; switch (m.m_type) { - case COLUMN_TYPE_BOOL: out << m.m_bool; break; - case COLUMN_TYPE_INT: out << m.m_int; break; - case COLUMN_TYPE_STRING: out << m.m_str; break; - case COLUMN_TYPE_FLOAT: out << m.m_float; break; - case COLUMN_TYPE_DOUBLE: out << m.m_double; break; - case COLUMN_TYPE_BINARY: out << BinaryData(m.m_str, m.m_len); break; - case COLUMN_TYPE_DATE: out << Date(m.m_date); break; - case COLUMN_TYPE_TABLE: out << "subtable"; break; - default: TIGHTDB_ASSERT(false); break; + case type_Bool: out << m.m_bool; break; + case type_Int: out << m.m_int; break; + case type_String: out << m.m_str; break; + case type_Float: out << m.m_float; break; + case type_Double: out << m.m_double; break; + case type_Binary: out << BinaryData(m.m_str, m.m_len); break; + case type_Date: out << Date(m.m_date); break; + case type_Table: out << "subtable"; break; + default: TIGHTDB_ASSERT(false); break; // FIXME: Remove } out << ")"; return out; -} - +} + // Compare mixed with boolean inline bool operator==(Wrap a, bool b) TIGHTDB_NOEXCEPT { - return Mixed(a).get_type() == COLUMN_TYPE_BOOL && Mixed(a).get_bool() == b; + return Mixed(a).get_type() == type_Bool && Mixed(a).get_bool() == b; } inline bool operator!=(Wrap a, bool b) TIGHTDB_NOEXCEPT { - return Mixed(a).get_type() == COLUMN_TYPE_BOOL && Mixed(a).get_bool() != b; + return Mixed(a).get_type() == type_Bool && Mixed(a).get_bool() != b; } inline bool operator==(bool a, Wrap b) TIGHTDB_NOEXCEPT { - return Mixed(b).get_type() == COLUMN_TYPE_BOOL && a == Mixed(b).get_bool(); + return Mixed(b).get_type() == type_Bool && a == Mixed(b).get_bool(); } inline bool operator!=(bool a, Wrap b) TIGHTDB_NOEXCEPT { - return Mixed(b).get_type() == COLUMN_TYPE_BOOL && a != Mixed(b).get_bool(); + return Mixed(b).get_type() == type_Bool && a != Mixed(b).get_bool(); } @@ -331,22 +331,22 @@ inline bool operator!=(bool a, Wrap b) TIGHTDB_NOEXCEPT template inline bool operator==(Wrap a, const T& b) TIGHTDB_NOEXCEPT { - return Mixed(a).get_type() == COLUMN_TYPE_INT && Mixed(a).get_int() == b; + return Mixed(a).get_type() == type_Int && Mixed(a).get_int() == b; } template inline bool operator!=(Wrap a, const T& b) TIGHTDB_NOEXCEPT { - return Mixed(a).get_type() == COLUMN_TYPE_INT && Mixed(a).get_int() != b; + return Mixed(a).get_type() == type_Int && Mixed(a).get_int() != b; } template inline bool operator==(const T& a, Wrap b) TIGHTDB_NOEXCEPT { - return Mixed(b).get_type() == COLUMN_TYPE_INT && a == Mixed(b).get_int(); + return Mixed(b).get_type() == type_Int && a == Mixed(b).get_int(); } template inline bool operator!=(const T& a, Wrap b) TIGHTDB_NOEXCEPT { - return Mixed(b).get_type() == COLUMN_TYPE_INT && a != Mixed(b).get_int(); + return Mixed(b).get_type() == type_Int && a != Mixed(b).get_int(); } @@ -354,22 +354,22 @@ template inline bool operator!=(const T& a, Wrap b) TIGHTDB_NOEX inline bool operator==(Wrap a, float b) { - return Mixed(a).get_type() == COLUMN_TYPE_FLOAT && Mixed(a).get_float() == b; + return Mixed(a).get_type() == type_Float && Mixed(a).get_float() == b; } inline bool operator!=(Wrap a, float b) { - return Mixed(a).get_type() == COLUMN_TYPE_FLOAT && Mixed(a).get_float() != b; + return Mixed(a).get_type() == type_Float && Mixed(a).get_float() != b; } inline bool operator==(float a, Wrap b) { - return Mixed(b).get_type() == COLUMN_TYPE_FLOAT && a == Mixed(b).get_float(); + return Mixed(b).get_type() == type_Float && a == Mixed(b).get_float(); } inline bool operator!=(float a, Wrap b) { - return Mixed(b).get_type() == COLUMN_TYPE_FLOAT && a != Mixed(b).get_float(); + return Mixed(b).get_type() == type_Float && a != Mixed(b).get_float(); } @@ -377,22 +377,22 @@ inline bool operator!=(float a, Wrap b) inline bool operator==(Wrap a, double b) { - return Mixed(a).get_type() == COLUMN_TYPE_DOUBLE && Mixed(a).get_double() == b; + return Mixed(a).get_type() == type_Double && Mixed(a).get_double() == b; } inline bool operator!=(Wrap a, double b) { - return Mixed(a).get_type() == COLUMN_TYPE_DOUBLE && Mixed(a).get_double() != b; + return Mixed(a).get_type() == type_Double && Mixed(a).get_double() != b; } inline bool operator==(double a, Wrap b) { - return Mixed(b).get_type() == COLUMN_TYPE_DOUBLE && a == Mixed(b).get_double(); + return Mixed(b).get_type() == type_Double && a == Mixed(b).get_double(); } inline bool operator!=(double a, Wrap b) { - return Mixed(b).get_type() == COLUMN_TYPE_DOUBLE && a != Mixed(b).get_double(); + return Mixed(b).get_type() == type_Double && a != Mixed(b).get_double(); } @@ -400,42 +400,42 @@ inline bool operator!=(double a, Wrap b) inline bool operator==(Wrap a, const char* b) TIGHTDB_NOEXCEPT { - return Mixed(a).get_type() == COLUMN_TYPE_STRING && std::strcmp(Mixed(a).get_string(), b) == 0; + return Mixed(a).get_type() == type_String && std::strcmp(Mixed(a).get_string(), b) == 0; } inline bool operator!=(Wrap a, const char* b) TIGHTDB_NOEXCEPT { - return Mixed(a).get_type() == COLUMN_TYPE_STRING && std::strcmp(Mixed(a).get_string(), b) != 0; + return Mixed(a).get_type() == type_String && std::strcmp(Mixed(a).get_string(), b) != 0; } inline bool operator==(const char* a, Wrap b) TIGHTDB_NOEXCEPT { - return Mixed(b).get_type() == COLUMN_TYPE_STRING && std::strcmp(a, Mixed(b).get_string()) == 0; + return Mixed(b).get_type() == type_String && std::strcmp(a, Mixed(b).get_string()) == 0; } inline bool operator!=(const char* a, Wrap b) TIGHTDB_NOEXCEPT { - return Mixed(b).get_type() == COLUMN_TYPE_STRING && std::strcmp(a, Mixed(b).get_string()) != 0; + return Mixed(b).get_type() == type_String && std::strcmp(a, Mixed(b).get_string()) != 0; } inline bool operator==(Wrap a, char* b) TIGHTDB_NOEXCEPT { - return Mixed(a).get_type() == COLUMN_TYPE_STRING && std::strcmp(Mixed(a).get_string(), b) == 0; + return Mixed(a).get_type() == type_String && std::strcmp(Mixed(a).get_string(), b) == 0; } inline bool operator!=(Wrap a, char* b) TIGHTDB_NOEXCEPT { - return Mixed(a).get_type() == COLUMN_TYPE_STRING && std::strcmp(Mixed(a).get_string(), b) != 0; + return Mixed(a).get_type() == type_String && std::strcmp(Mixed(a).get_string(), b) != 0; } inline bool operator==(char* a, Wrap b) TIGHTDB_NOEXCEPT { - return Mixed(b).get_type() == COLUMN_TYPE_STRING && std::strcmp(a, Mixed(b).get_string()) == 0; + return Mixed(b).get_type() == type_String && std::strcmp(a, Mixed(b).get_string()) == 0; } inline bool operator!=(char* a, Wrap b) TIGHTDB_NOEXCEPT { - return Mixed(b).get_type() == COLUMN_TYPE_STRING && std::strcmp(a, Mixed(b).get_string()) != 0; + return Mixed(b).get_type() == type_String && std::strcmp(a, Mixed(b).get_string()) != 0; } @@ -443,22 +443,22 @@ inline bool operator!=(char* a, Wrap b) TIGHTDB_NOEXCEPT inline bool operator==(Wrap a, BinaryData b) TIGHTDB_NOEXCEPT { - return Mixed(a).get_type() == COLUMN_TYPE_BINARY && Mixed(a).get_binary().compare_payload(b); + return Mixed(a).get_type() == type_Binary && Mixed(a).get_binary().compare_payload(b); } inline bool operator!=(Wrap a, BinaryData b) TIGHTDB_NOEXCEPT { - return Mixed(a).get_type() == COLUMN_TYPE_BINARY && !Mixed(a).get_binary().compare_payload(b); + return Mixed(a).get_type() == type_Binary && !Mixed(a).get_binary().compare_payload(b); } inline bool operator==(BinaryData a, Wrap b) TIGHTDB_NOEXCEPT { - return Mixed(b).get_type() == COLUMN_TYPE_BINARY && a.compare_payload(Mixed(b).get_binary()); + return Mixed(b).get_type() == type_Binary && a.compare_payload(Mixed(b).get_binary()); } inline bool operator!=(BinaryData a, Wrap b) TIGHTDB_NOEXCEPT { - return Mixed(b).get_type() == COLUMN_TYPE_BINARY && !a.compare_payload(Mixed(b).get_binary()); + return Mixed(b).get_type() == type_Binary && !a.compare_payload(Mixed(b).get_binary()); } @@ -466,22 +466,22 @@ inline bool operator!=(BinaryData a, Wrap b) TIGHTDB_NOEXCEPT inline bool operator==(Wrap a, Date b) TIGHTDB_NOEXCEPT { - return Mixed(a).get_type() == COLUMN_TYPE_DATE && Date(Mixed(a).get_date()) == b; + return Mixed(a).get_type() == type_Date && Date(Mixed(a).get_date()) == b; } inline bool operator!=(Wrap a, Date b) TIGHTDB_NOEXCEPT { - return Mixed(a).get_type() == COLUMN_TYPE_DATE && Date(Mixed(a).get_date()) != b; + return Mixed(a).get_type() == type_Date && Date(Mixed(a).get_date()) != b; } inline bool operator==(Date a, Wrap b) TIGHTDB_NOEXCEPT { - return Mixed(b).get_type() == COLUMN_TYPE_DATE && a == Date(Mixed(b).get_date()); + return Mixed(b).get_type() == type_Date && a == Date(Mixed(b).get_date()); } inline bool operator!=(Date a, Wrap b) TIGHTDB_NOEXCEPT { - return Mixed(b).get_type() == COLUMN_TYPE_DATE && a != Date(Mixed(b).get_date()); + return Mixed(b).get_type() == type_Date && a != Date(Mixed(b).get_date()); } diff --git a/src/tightdb/query.cpp b/src/tightdb/query.cpp index d6bc1121820..9c484fec813 100644 --- a/src/tightdb/query.cpp +++ b/src/tightdb/query.cpp @@ -271,13 +271,14 @@ Query& Query::not_equal(size_t column_ndx, const char* value, bool caseSensitive // Aggregates ================================================================================= template -R Query::aggregate(R (ColType::*aggregateMethod)(size_t start, size_t end) const, +R Query::aggregate(R (ColType::*aggregateMethod)(size_t start, size_t end) const, size_t column_ndx, size_t* resultcount, size_t start, size_t end, size_t limit) const { if (end == size_t(-1)) end = m_table->size(); - const ColType& column = m_table->GetColumn::id>(column_ndx); + const ColType& column = + m_table->GetColumn::id)>(column_ndx); if (first.size() == 0 || first[0] == 0) { // User created query with no criteria; aggregate range diff --git a/src/tightdb/query_engine.hpp b/src/tightdb/query_engine.hpp index 5db9d20bb41..a96cbf3aba7 100644 --- a/src/tightdb/query_engine.hpp +++ b/src/tightdb/query_engine.hpp @@ -32,7 +32,7 @@ The construction of all this takes part in query.cpp. Each node has two importan aggregate_local(start, end) The aggregate() function executes the aggregate of a query. You can call the method on any of the nodes -(except children nodes of OrNode and SubtableNode) - it has the same behaviour. The function contains +(except children nodes of OrNode and SubtableNode) - it has the same behaviour. The function contains scheduling that calls aggregate_local(start, end) on different nodes with different start/end ranges, depending on what it finds is most optimal. @@ -52,8 +52,8 @@ aggregate(0, 10) node1->find_first_local(7, 8) node2->find_first_local(7, 8) -find_first_local(n, n + 1) is a function that can be used to test a single row of another condition. Note that -this is very simplified. There are other statistical arguments to the methods, and also, find_first_local() can be +find_first_local(n, n + 1) is a function that can be used to test a single row of another condition. Note that +this is very simplified. There are other statistical arguments to the methods, and also, find_first_local() can be called from a callback function called by an integer Array. @@ -66,10 +66,10 @@ TConditionValue: Type of values in condition column. That is, int64_t, float, TAction: What to do with each search result, from the enums TDB_RETURN_FIRST, TDB_COUNT, TDB_SUM, etc -TResult: Type of result of actions - float, double, int64_t, etc. Special notes: For TDB_COUNT it's +TResult: Type of result of actions - float, double, int64_t, etc. Special notes: For TDB_COUNT it's int64_t, for TDB_FIND_ALL it's int64_t which points at destination array. -TSourceColumn: Type of source column used in actions, or *ignored* if no source column is used (like for +TSourceColumn: Type of source column used in actions, or *ignored* if no source column is used (like for TDB_COUNT, TDB_RETURN_FIRST) @@ -78,7 +78,7 @@ There are two important classes used in queries: SequentialGetter Column iterator used to get successive values with leaf caching. Used both for condition columns and aggregate source column -AggregateState State of the aggregate - contains a state variable that stores intermediate sum, max, min, +AggregateState State of the aggregate - contains a state variable that stores intermediate sum, max, min, etc, etc. */ @@ -107,17 +107,17 @@ namespace tightdb { // Number of matches to find in best condition loop before breaking out to probe other conditions. Too low value gives too many // constant time overheads everywhere in the query engine. Too high value makes it adapt less rapidly to changes in match // frequencies. -const size_t findlocals = 64; +const size_t findlocals = 64; // Average match distance in linear searches where further increase in distance no longer increases query speed (because time // spent on handling each match becomes insignificant compared to time spent on the search). const size_t bestdist = 512; -// Minimum number of matches required in a certain condition before it can be used to compute statistics. Too high value can spent +// Minimum number of matches required in a certain condition before it can be used to compute statistics. Too high value can spent // too much time in a bad node (with high match frequency). Too low value gives inaccurate statistics. const size_t probe_matches = 4; -const size_t bitwidth_time_unit = 64; +const size_t bitwidth_time_unit = 64; typedef bool (*CallbackDummy)(int64_t); @@ -127,25 +127,25 @@ template<> struct ColumnTypeTraits { typedef Column column_type; typedef Array array_type; typedef int64_t sum_type; - static const ColumnType id = COLUMN_TYPE_INT; + static const DataType id = type_Int; }; template<> struct ColumnTypeTraits { typedef Column column_type; typedef Array array_type; typedef int64_t sum_type; - static const ColumnType id = COLUMN_TYPE_BOOL; + static const DataType id = type_Bool; }; template<> struct ColumnTypeTraits { typedef ColumnFloat column_type; typedef ArrayFloat array_type; typedef double sum_type; - static const ColumnType id = COLUMN_TYPE_FLOAT; + static const DataType id = type_Float; }; template<> struct ColumnTypeTraits { typedef ColumnDouble column_type; typedef ArrayDouble array_type; typedef double sum_type; - static const ColumnType id = COLUMN_TYPE_DOUBLE; + static const DataType id = type_Double; }; // Only purpose is to return 'double' if and only if source column (T) is float and you're doing a sum (A) @@ -168,14 +168,14 @@ templateclass SequentialGetter : public SequentialGetterBase { typedef typename ColumnTypeTraits::column_type ColType; typedef typename ColumnTypeTraits::array_type ArrayType; - // We must destroy m_array immediately after its instantiation to avoid leak of what it preallocates. We cannot + // We must destroy m_array immediately after its instantiation to avoid leak of what it preallocates. We cannot // wait until a SequentialGetter destructor because GetBlock() maps it to data that we don't have ownership of. - SequentialGetter() - { - m_array.Destroy(); + SequentialGetter() + { + m_array.Destroy(); } - SequentialGetter(const Table& table, size_t column_ndx) + SequentialGetter(const Table& table, size_t column_ndx) { m_array.Destroy(); if (column_ndx != not_found) @@ -183,7 +183,7 @@ templateclass SequentialGetter : public SequentialGetterBase { m_leaf_end = 0; } - SequentialGetter(ColType* column) + SequentialGetter(ColType* column) { m_array.Destroy(); m_column = column; @@ -228,7 +228,8 @@ class ParentNode { ParentNode() : m_is_integer_node(false), m_table(NULL) {} // Note: Changed to avoid a lot of copying of the vector. Lasse, plese review. - void gather_children(std::vector& v) { + void gather_children(std::vector& v) + { m_children.clear(); ParentNode* p = this; size_t i = v.size(); @@ -242,11 +243,10 @@ class ParentNode { m_children.erase(m_children.begin() + i); m_children.insert(m_children.begin(), this); - m_conds = m_children.size(); + m_conds = m_children.size(); } - struct score_compare - { + struct score_compare { bool operator ()(ParentNode const* a, ParentNode const* b) const { return (a->cost() < b->cost()); } }; @@ -282,25 +282,25 @@ class ParentNode { virtual ~ParentNode() {} - - virtual void Init(const Table& table) + + virtual void Init(const Table& table) { - m_table = &table; - if (m_child) + m_table = &table; + if (m_child) m_child->Init(table); } - + virtual size_t find_first_local(size_t start, size_t end) = 0; - + virtual ParentNode* child_criteria(void) { return m_child; } // Only purpose is to make all IntegerNode classes have this function (overloaded only in IntegerNode) - virtual size_t aggregate_call_specialized(ACTION /*TAction*/, ColumnType /*TResult*/, - QueryStateBase* /*st*/, - size_t /*start*/, size_t /*end*/, size_t /*local_limit*/, + virtual size_t aggregate_call_specialized(ACTION /*TAction*/, DataType /*TResult*/, + QueryStateBase* /*st*/, + size_t /*start*/, size_t /*end*/, size_t /*local_limit*/, SequentialGetterBase* /*source_column*/, size_t* /*matchcount*/) { TIGHTDB_ASSERT(false); @@ -308,11 +308,11 @@ class ParentNode { } template - size_t aggregate_local_selector(ParentNode* node, QueryState* st, size_t start, size_t end, size_t local_limit, + size_t aggregate_local_selector(ParentNode* node, QueryState* st, size_t start, size_t end, size_t local_limit, SequentialGetter* source_column, size_t* matchcount) { size_t r; - + if (node->m_is_integer_node) // call method in IntegerNode r = node->aggregate_call_specialized(TAction, ColumnTypeTraits::id,(QueryStateBase*)st, @@ -325,13 +325,13 @@ class ParentNode { template - TResult aggregate(QueryState* st, size_t start, size_t end, size_t agg_col, size_t* matchcount) + TResult aggregate(QueryState* st, size_t start, size_t end, size_t agg_col, size_t* matchcount) { - if (end == size_t(-1)) + if (end == size_t(-1)) end = m_table->size(); SequentialGetter* source_column = NULL; - + if (agg_col != not_found) source_column = new SequentialGetter(*m_table, agg_col); @@ -371,30 +371,30 @@ class ParentNode { } template - size_t aggregate_local(QueryStateBase* st, size_t start, size_t end, size_t local_limit, - SequentialGetterBase* source_column, size_t* matchcount) + size_t aggregate_local(QueryStateBase* st, size_t start, size_t end, size_t local_limit, + SequentialGetterBase* source_column, size_t* matchcount) { // aggregate called on non-integer column type. Speed of this function is not as critical as speed of the // integer version, because find_first_local() is relatively slower here (because it's non-integers). // // Todo: Two speedups are possible. Simple: Initially test if there are no sub criterias and run find_first_local() - // in a tight loop if so (instead of testing if there are sub criterias after each match). Harder: Specialize + // in a tight loop if so (instead of testing if there are sub criterias after each match). Harder: Specialize // data type array to make array call match() directly on each match, like for integers. - + (void)matchcount; size_t local_matches = 0; size_t r = start - 1; for (;;) { - if (local_matches == local_limit) { - m_dD = double(r - start) / local_matches; + if (local_matches == local_limit) { + m_dD = double(r - start) / local_matches; return r + 1; } // Find first match in this condition node r = find_first_local(r + 1, end); - if (r == end) { - m_dD = double(r - start) / local_matches; + if (r == end) { + m_dD = double(r - start) / local_matches; return end; } @@ -417,7 +417,7 @@ class ParentNode { if (source_column != NULL) av = static_cast*>(source_column)->GetNext(r); // todo, avoid GetNext if value not needed (if !uses_val) ((QueryState*)st)->template match(r, 0, TResult(av), CallbackDummy()); - } + } } } @@ -500,17 +500,17 @@ class SubtableNode: public ParentNode { m_matches = 0; m_table = &table; - + if (m_child) { m_child->Init(table); std::vector v; m_child->gather_children(v); } - if (m_child2) + if (m_child2) m_child2->Init(table); } - + size_t find_first_local(size_t start, size_t end) { TIGHTDB_ASSERT(m_table); @@ -524,12 +524,13 @@ class SubtableNode: public ParentNode { const size_t sub = m_child->find_first(0, subsize); if (sub != subsize) - return s; + return s; } return end; } - ParentNode* child_criteria(void) { + ParentNode* child_criteria(void) + { return m_child2; } @@ -544,7 +545,8 @@ template class IntegerNode: pu // NOTE: Be careful to call Array(no_prealloc_tag) constructors on m_array in the initializer list, otherwise // their default constructors are called which are slow - IntegerNode(TConditionValue v, size_t column) : m_value(v), m_array(Array::no_prealloc_tag()) { + IntegerNode(TConditionValue v, size_t column) : m_value(v), m_array(Array::no_prealloc_tag()) + { m_is_integer_node = true; m_condition_column_idx = column; m_child = 0; @@ -557,8 +559,9 @@ template class IntegerNode: pu // Only purpose of this function is to let you quickly create a IntegerNode object and call aggregate_local() on it to aggregate // on a single stand-alone column, with 1 or 0 search criterias, without involving any tables, etc. Todo, could // be merged with Init somehow to simplify - void QuickInit(Column *column, int64_t value) { - m_condition_column = column; + void QuickInit(Column *column, int64_t value) + { + m_condition_column = column; m_leaf_end = 0; m_value = value; m_conds = 0; @@ -576,7 +579,8 @@ template class IntegerNode: pu // This function is called from Array::find() for each search result if TAction == TDB_CALLBACK_IDX // in the IntegerNode::aggregate_local() call. Used if aggregate source column is different from search criteria column - template bool match_callback(int64_t v) { + template bool match_callback(int64_t v) + { size_t i = to_size_t(v); m_last_local_match = i; m_local_matches++; @@ -594,12 +598,12 @@ template class IntegerNode: pu } bool b; - if (state->template uses_val()) { // Compiler cannot see that Column::Get has no side effect and result is discarded + if (state->template uses_val()) { // Compiler cannot see that Column::Get has no side effect and result is discarded TSourceColumn av = source_column->GetNext(i); - b = state->template match(i, 0, av, CallbackDummy()); + b = state->template match(i, 0, av, CallbackDummy()); } else { - b = state->template match(i, 0, TSourceColumn(0), CallbackDummy()); + b = state->template match(i, 0, TSourceColumn(0), CallbackDummy()); } if (m_local_matches == m_local_limit) @@ -608,38 +612,38 @@ template class IntegerNode: pu return b; } - size_t aggregate_call_specialized(ACTION TAction, ColumnType col_id, QueryStateBase* st, - size_t start, size_t end, size_t local_limit, - SequentialGetterBase* source_column, size_t* matchcount) + size_t aggregate_call_specialized(ACTION TAction, DataType col_id, QueryStateBase* st, + size_t start, size_t end, size_t local_limit, + SequentialGetterBase* source_column, size_t* matchcount) { size_t ret; if (TAction == TDB_RETURN_FIRST) - ret = aggregate_local(st, start, end, local_limit, source_column, matchcount); + ret = aggregate_local(st, start, end, local_limit, source_column, matchcount); else if (TAction == TDB_COUNT) ret = aggregate_local(st, start, end, local_limit, source_column, matchcount); - else if (TAction == TDB_SUM && col_id == COLUMN_TYPE_INT) + else if (TAction == TDB_SUM && col_id == type_Int) ret = aggregate_local(st, start, end, local_limit, source_column, matchcount); - else if (TAction == TDB_SUM && col_id == COLUMN_TYPE_FLOAT) - // todo, fixme, see if we must let sum return a double even when summing a float coltype + else if (TAction == TDB_SUM && col_id == type_Float) + // todo, fixme, see if we must let sum return a double even when summing a float coltype ret = aggregate_local(st, start, end, local_limit, source_column, matchcount); - else if (TAction == TDB_SUM && col_id == COLUMN_TYPE_DOUBLE) + else if (TAction == TDB_SUM && col_id == type_Double) ret = aggregate_local(st, start, end, local_limit, source_column, matchcount); - else if (TAction == TDB_MAX && col_id == COLUMN_TYPE_INT) + else if (TAction == TDB_MAX && col_id == type_Int) ret = aggregate_local(st, start, end, local_limit, source_column, matchcount); - else if (TAction == TDB_MAX && col_id == COLUMN_TYPE_FLOAT) + else if (TAction == TDB_MAX && col_id == type_Float) ret = aggregate_local(st, start, end, local_limit, source_column, matchcount); - else if (TAction == TDB_MAX && col_id == COLUMN_TYPE_DOUBLE) + else if (TAction == TDB_MAX && col_id == type_Double) ret = aggregate_local(st, start, end, local_limit, source_column, matchcount); - else if (TAction == TDB_MIN && col_id == COLUMN_TYPE_INT) + else if (TAction == TDB_MIN && col_id == type_Int) ret = aggregate_local(st, start, end, local_limit, source_column, matchcount); - else if (TAction == TDB_MIN && col_id == COLUMN_TYPE_FLOAT) + else if (TAction == TDB_MIN && col_id == type_Float) ret = aggregate_local(st, start, end, local_limit, source_column, matchcount); - else if (TAction == TDB_MIN && col_id == COLUMN_TYPE_DOUBLE) + else if (TAction == TDB_MIN && col_id == type_Double) ret = aggregate_local(st, start, end, local_limit, source_column, matchcount); else if (TAction == TDB_FINDALL) @@ -648,7 +652,7 @@ template class IntegerNode: pu else if (TAction == TDB_CALLBACK_IDX) ret = aggregate_local(st, start, end, local_limit, source_column, matchcount); - else { + else { TIGHTDB_ASSERT(false); return 0; } @@ -657,8 +661,8 @@ template class IntegerNode: pu // source_column: column number in m_table which must act as source for aggreate TAction - template - size_t aggregate_local(QueryStateBase* st, size_t start, size_t end, size_t local_limit, + template + size_t aggregate_local(QueryStateBase* st, size_t start, size_t end, size_t local_limit, SequentialGetterBase* source_column, size_t* matchcount) { typedef typename ColumnTypeTraitsSum::sum_type QueryStateType; @@ -672,10 +676,10 @@ template class IntegerNode: pu m_last_local_match = start - 1; m_state = st; - for (size_t s = start; s < end; ) { + for (size_t s = start; s < end; ) { // Cache internal leafs - if (s >= m_leaf_end) { - m_condition_column->GetBlock(s, m_array, m_leaf_start); + if (s >= m_leaf_end) { + m_condition_column->GetBlock(s, m_array, m_leaf_start); m_leaf_end = m_leaf_start + m_array.Size(); size_t w = m_array.GetBitWidth(); m_dT = (w == 0 ? 1.0 / MAX_LIST_SIZE : w / float(bitwidth_time_unit)); @@ -687,18 +691,18 @@ template class IntegerNode: pu else end2 = end - m_leaf_start; - if (m_conds <= 1 && (source_column == NULL || - (SameType::value - && static_cast*>(source_column)->m_column == m_condition_column))) { + if (m_conds <= 1 && (source_column == NULL || + (SameType::value + && static_cast*>(source_column)->m_column == m_condition_column))) { m_array.find(c, TAction, m_value, s - m_leaf_start, end2, m_leaf_start, (QueryState*)st); } else { QueryState jumpstate; // todo optimize by moving outside for loop - m_source_column = source_column; - m_array.find(m_value, s - m_leaf_start, end2, m_leaf_start, &jumpstate, + m_source_column = source_column; + m_array.find(m_value, s - m_leaf_start, end2, m_leaf_start, &jumpstate, std::bind1st(std::mem_fun(&IntegerNode::match_callback), this)); } - + if (m_local_matches == m_local_limit) break; @@ -732,7 +736,7 @@ template class IntegerNode: pu m_condition_column->GetBlock(start, m_array, m_leaf_start); m_leaf_end = m_leaf_start + m_array.Size(); } - + // Do search directly on cached leaf array if (start + 1 == end) { if (condition(m_array.Get(start - m_leaf_start), m_value)) @@ -755,7 +759,7 @@ template class IntegerNode: pu } else return s + m_leaf_start; - } + } return end; } @@ -767,14 +771,14 @@ template class IntegerNode: pu size_t m_last_local_match; ColType* m_condition_column; // Column on which search criteria is applied // const Array* m_criteria_arr; - Array m_array; + Array m_array; size_t m_leaf_start; size_t m_leaf_end; size_t m_local_end; size_t m_local_matches; size_t m_local_limit; - + QueryStateBase* m_state; SequentialGetterBase* m_source_column; // Column of values used in aggregate (TDB_FINDALL, TDB_RETURN_FIRST, TDB_SUM, etc) }; @@ -806,7 +810,9 @@ template class StringNode: public ParentNode { if (!b1 || !b2) error_code = "Malformed UTF-8: " + std::string(m_value); } - ~StringNode() { + + ~StringNode() + { delete[] m_value; delete[] m_ucase; delete[] m_lcase; } @@ -818,7 +824,7 @@ template class StringNode: public ParentNode { m_table = &table; m_condition_column = &table.GetColumnBase(m_condition_column_idx); - m_column_type = table.GetRealColumnType(m_condition_column_idx); + m_column_type = table.get_real_column_type(m_condition_column_idx); if (m_child) m_child->Init(table); } @@ -831,11 +837,11 @@ template class StringNode: public ParentNode { const char* t; // todo, can be optimized by placing outside loop - if (m_column_type == COLUMN_TYPE_STRING) - t = ((const AdaptiveStringColumn*)m_condition_column)->Get(s); + if (m_column_type == col_type_String) + t = static_cast(m_condition_column)->Get(s); else { //TODO: First check if string is in key list - t = ((const ColumnStringEnum*)m_condition_column)->Get(s); + t = static_cast(m_condition_column)->Get(s); } if (cond(m_value, m_ucase, m_lcase, t)) @@ -857,7 +863,7 @@ template class StringNode: public ParentNode { template class BASICNODE: public ParentNode { public: typedef typename ColumnTypeTraits::column_type ColType; - + BASICNODE(TConditionValue v, size_t column_ndx) : m_value(v) { m_condition_column_idx = column_ndx; @@ -868,7 +874,8 @@ template class BASICNODE: publ // Only purpose of this function is to let you quickly create a IntegerNode object and call aggregate_local() on it to aggregate // on a single stand-alone column, with 1 or 0 search criterias, without involving any tables, etc. Todo, could // be merged with Init somehow to simplify - void QuickInit(BasicColumn *column, TConditionValue value) { + void QuickInit(BasicColumn *column, TConditionValue value) + { m_condition_column.m_column = (ColType*)column; m_condition_column.m_leaf_end = 0; m_value = value; @@ -882,14 +889,15 @@ template class BASICNODE: publ m_condition_column.m_column = (ColType*)(&table.GetColumnBase(m_condition_column_idx)); m_condition_column.m_leaf_end = 0; - if (m_child) + if (m_child) m_child->Init(table); } - - size_t find_first_local(size_t start, size_t end) { + + size_t find_first_local(size_t start, size_t end) + { TConditionFunction cond; - for (size_t s = start; s < end; ++s) { + for (size_t s = start; s < end; ++s) { TConditionValue v = m_condition_column.GetNext(s); if (cond(v, m_value)) return s; @@ -916,7 +924,9 @@ template class BinaryNode: public ParentNode { m_value = (char *)malloc(len); memcpy(m_value, v, len); } - ~BinaryNode() { + + ~BinaryNode() + { free((void*)m_value); } @@ -925,16 +935,17 @@ template class BinaryNode: public ParentNode { m_dD = 100.0; m_table = &table; m_condition_column = (const ColumnBinary*)&table.GetColumnBase(m_condition_column_idx); - m_column_type = table.GetRealColumnType(m_condition_column_idx); + m_column_type = table.get_real_column_type(m_condition_column_idx); - if (m_child) + if (m_child) m_child->Init(table); } - size_t find_first_local(size_t start, size_t end) { + size_t find_first_local(size_t start, size_t end) + { TConditionFunction condition; - for (size_t s = start; s < end; ++s) { + for (size_t s = start; s < end; ++s) { const char* value = m_condition_column->Get(s).pointer; size_t len = m_condition_column->Get(s).len; @@ -954,10 +965,10 @@ template class BinaryNode: public ParentNode { template <> class StringNode: public ParentNode { public: - template - int64_t find_all(Array*, size_t, size_t, size_t, size_t) + template + int64_t find_all(Array*, size_t, size_t, size_t, size_t) { - TIGHTDB_ASSERT(false); + TIGHTDB_ASSERT(false); return 0; } @@ -975,12 +986,12 @@ template <> class StringNode: public ParentNode { void Init(const Table& table) { m_dD = 10.0; - + m_table = &table; m_condition_column = &table.GetColumnBase(m_condition_column_idx); - m_column_type = table.GetRealColumnType(m_condition_column_idx); + m_column_type = table.get_real_column_type(m_condition_column_idx); - if (m_column_type == COLUMN_TYPE_STRING_ENUM) { + if (m_column_type == col_type_StringEnum) { m_dT = 1.0; m_key_ndx = ((const ColumnStringEnum*)m_condition_column)->GetKeyNdx(m_value); } @@ -989,7 +1000,7 @@ template <> class StringNode: public ParentNode { } if (m_condition_column->HasIndex()) { - if (m_column_type == COLUMN_TYPE_STRING_ENUM) + if (m_column_type == col_type_StringEnum) ((ColumnStringEnum*)m_condition_column)->find_all(m_index, m_value); else { ((AdaptiveStringColumn*)m_condition_column)->find_all(m_index, m_value); @@ -997,7 +1008,7 @@ template <> class StringNode: public ParentNode { last_indexed = 0; } - if (m_child) + if (m_child) m_child->Init(table); } @@ -1016,10 +1027,10 @@ template <> class StringNode: public ParentNode { } else { // todo, can be optimized by placing outside loop - if (m_column_type == COLUMN_TYPE_STRING) + if (m_column_type == col_type_String) s = ((const AdaptiveStringColumn*)m_condition_column)->find_first(m_value, s, end); else { - if (m_key_ndx == size_t(-1)) + if (m_key_ndx == size_t(-1)) s = end; // not in key set else { const ColumnStringEnum* const cse = (const ColumnStringEnum*)m_condition_column; diff --git a/src/tightdb/replication.cpp b/src/tightdb/replication.cpp index 4c7058b10fb..779031106b1 100644 --- a/src/tightdb/replication.cpp +++ b/src/tightdb/replication.cpp @@ -779,13 +779,13 @@ struct Replication::TransactLogApplier { bool is_valid_column_type(int type) { switch (type) { - case COLUMN_TYPE_INT: - case COLUMN_TYPE_BOOL: - case COLUMN_TYPE_DATE: - case COLUMN_TYPE_STRING: - case COLUMN_TYPE_BINARY: - case COLUMN_TYPE_TABLE: - case COLUMN_TYPE_MIXED: return true; + case type_Int: + case type_Bool: + case type_Date: + case type_String: + case type_Binary: + case type_Table: + case type_Mixed: return true; default: break; } return false; @@ -872,7 +872,7 @@ template void Replication::TransactLogApplier::set_or_insert(int column_ndx, size_t ndx) { switch (m_table->get_column_type(column_ndx)) { - case COLUMN_TYPE_INT: + case type_Int: { int64_t value = read_int(); // Throws if (insert) m_table->insert_int(column_ndx, ndx, value); // FIXME: Memory allocation failure!!! @@ -885,7 +885,7 @@ void Replication::TransactLogApplier::set_or_insert(int column_ndx, size_t ndx) #endif } break; - case COLUMN_TYPE_BOOL: + case type_Bool: { bool value = read_int(); // Throws if (insert) m_table->insert_bool(column_ndx, ndx, value); // FIXME: Memory allocation failure!!! @@ -898,7 +898,7 @@ void Replication::TransactLogApplier::set_or_insert(int column_ndx, size_t ndx) #endif } break; - case COLUMN_TYPE_DATE: + case type_Date: { time_t value = read_int(); // Throws if (insert) m_table->insert_date(column_ndx, ndx, value); // FIXME: Memory allocation failure!!! @@ -911,7 +911,7 @@ void Replication::TransactLogApplier::set_or_insert(int column_ndx, size_t ndx) #endif } break; - case COLUMN_TYPE_STRING: + case type_String: { read_string(m_string_buffer); // Throws const char* const value = m_string_buffer.c_str(); @@ -925,7 +925,7 @@ void Replication::TransactLogApplier::set_or_insert(int column_ndx, size_t ndx) #endif } break; - case COLUMN_TYPE_BINARY: + case type_Binary: { read_string(m_string_buffer); // Throws if (insert) m_table->insert_binary(column_ndx, ndx, m_string_buffer.data(), @@ -940,7 +940,7 @@ void Replication::TransactLogApplier::set_or_insert(int column_ndx, size_t ndx) #endif } break; - case COLUMN_TYPE_TABLE: + case type_Table: if (insert) m_table->insert_subtable(column_ndx, ndx); // FIXME: Memory allocation failure!!! else m_table->clear_subtable(column_ndx, ndx); // FIXME: Memory allocation failure!!! #ifdef TIGHTDB_DEBUG @@ -950,11 +950,11 @@ void Replication::TransactLogApplier::set_or_insert(int column_ndx, size_t ndx) } #endif break; - case COLUMN_TYPE_MIXED: + case type_Mixed: { int type = read_int(); // Throws switch (type) { - case COLUMN_TYPE_INT: + case type_Int: { int64_t value = read_int(); // Throws if (insert) m_table->insert_mixed(column_ndx, ndx, value); // FIXME: Memory allocation failure!!! @@ -967,7 +967,7 @@ void Replication::TransactLogApplier::set_or_insert(int column_ndx, size_t ndx) #endif } break; - case COLUMN_TYPE_BOOL: + case type_Bool: { bool value = read_int(); // Throws if (insert) m_table->insert_mixed(column_ndx, ndx, value); // FIXME: Memory allocation failure!!! @@ -980,7 +980,7 @@ void Replication::TransactLogApplier::set_or_insert(int column_ndx, size_t ndx) #endif } break; - case COLUMN_TYPE_DATE: + case type_Date: { time_t value = read_int(); // Throws if (insert) m_table->insert_mixed(column_ndx, ndx, Date(value)); // FIXME: Memory allocation failure!!! @@ -993,7 +993,7 @@ void Replication::TransactLogApplier::set_or_insert(int column_ndx, size_t ndx) #endif } break; - case COLUMN_TYPE_STRING: + case type_String: { read_string(m_string_buffer); // Throws const char* const value = m_string_buffer.c_str(); @@ -1007,7 +1007,7 @@ void Replication::TransactLogApplier::set_or_insert(int column_ndx, size_t ndx) #endif } break; - case COLUMN_TYPE_BINARY: + case type_Binary: { read_string(m_string_buffer); // Throws const BinaryData value(m_string_buffer.data(), m_string_buffer.size()); @@ -1021,7 +1021,7 @@ void Replication::TransactLogApplier::set_or_insert(int column_ndx, size_t ndx) #endif } break; - case COLUMN_TYPE_TABLE: + case type_Table: if (insert) m_table->insert_mixed(column_ndx, ndx, Mixed::subtable_tag()); // FIXME: Memory allocation failure!!! else m_table->set_mixed(column_ndx, ndx, Mixed::subtable_tag()); // FIXME: Memory allocation failure!!! #ifdef TIGHTDB_DEBUG @@ -1144,10 +1144,10 @@ void Replication::TransactLogApplier::apply() goto bad_transact_log; if (m_table->size() <= ndx) goto bad_transact_log; switch (m_table->get_column_type(column_ndx)) { - case COLUMN_TYPE_TABLE: + case type_Table: m_table = m_table->get_subtable(column_ndx, ndx); break; - case COLUMN_TYPE_MIXED: + case type_Mixed: m_table = m_table->get_subtable(column_ndx, ndx); if (!m_table) goto bad_transact_log; break; diff --git a/src/tightdb/replication.hpp b/src/tightdb/replication.hpp index 6657c5603e0..904498bdd9b 100644 --- a/src/tightdb/replication.hpp +++ b/src/tightdb/replication.hpp @@ -472,29 +472,29 @@ inline void Replication::mixed_cmd(char cmd, std::size_t column_ndx, buf = encode_int(buf, ndx); buf = encode_int(buf, int(value.get_type())); switch (value.get_type()) { - case COLUMN_TYPE_INT: + case type_Int: buf = encode_int(buf, value.get_int()); transact_log_advance(buf); break; - case COLUMN_TYPE_BOOL: + case type_Bool: buf = encode_int(buf, int(value.get_bool())); transact_log_advance(buf); break; - case COLUMN_TYPE_FLOAT: + case type_Float: TIGHTDB_ASSERT(false); // FIXME: IMPLEMENT //buf = encode_float(buf, value.get_float())); transact_log_advance(buf); break; - case COLUMN_TYPE_DOUBLE: + case type_Double: TIGHTDB_ASSERT(false); // FIXME: IMPLEMENT //buf = encode_double(buf, value.get_double())); transact_log_advance(buf); break; - case COLUMN_TYPE_DATE: + case type_Date: buf = encode_int(buf, value.get_date()); transact_log_advance(buf); break; - case COLUMN_TYPE_STRING: + case type_String: { const char* data = value.get_string(); std::size_t size = std::strlen(data); @@ -503,7 +503,7 @@ inline void Replication::mixed_cmd(char cmd, std::size_t column_ndx, transact_log_append(data, size); // Throws } break; - case COLUMN_TYPE_BINARY: + case type_Binary: { BinaryData data = value.get_binary(); buf = encode_int(buf, data.len); @@ -511,7 +511,7 @@ inline void Replication::mixed_cmd(char cmd, std::size_t column_ndx, transact_log_append(data.pointer, data.len); // Throws } break; - case COLUMN_TYPE_TABLE: + case type_Table: transact_log_advance(buf); break; default: diff --git a/src/tightdb/spec.cpp b/src/tightdb/spec.cpp index aa6a96c32d4..17c94d68843 100644 --- a/src/tightdb/spec.cpp +++ b/src/tightdb/spec.cpp @@ -67,7 +67,7 @@ bool Spec::update_from_parent() else return false; } -size_t Spec::add_column(ColumnType type, const char* name, ColumnType attr) +size_t Spec::add_column(DataType type, const char* name, ColumnType attr) { TIGHTDB_ASSERT(name); @@ -76,12 +76,12 @@ size_t Spec::add_column(ColumnType type, const char* name, ColumnType attr) // We can set column attribute on creation // TODO: add to replication log - if (attr != COLUMN_ATTR_NONE) { + if (attr != col_attr_None) { const size_t column_ndx = m_names.Size()-1; set_column_attr(column_ndx, attr); } - if (type == COLUMN_TYPE_TABLE) { + if (type == type_Table) { // SubSpecs array is only there when there are subtables if (m_specSet.Size() == 2) { m_subSpecs.SetType(COLUMN_HASREFS); @@ -113,13 +113,13 @@ size_t Spec::add_column(ColumnType type, const char* name, ColumnType attr) return (m_names.Size()-1); // column_ndx } -size_t Spec::add_subcolumn(const vector& column_path, ColumnType type, const char* name) +size_t Spec::add_subcolumn(const vector& column_path, DataType type, const char* name) { TIGHTDB_ASSERT(!column_path.empty()); return do_add_subcolumn(column_path, 0, type, name); } -size_t Spec::do_add_subcolumn(const vector& column_ids, size_t pos, ColumnType type, const char* name) +size_t Spec::do_add_subcolumn(const vector& column_ids, size_t pos, DataType type, const char* name) { const size_t column_ndx = column_ids[pos]; Spec subspec = get_subtable_spec(column_ndx); @@ -135,7 +135,7 @@ size_t Spec::do_add_subcolumn(const vector& column_ids, size_t pos, Colu Spec Spec::add_subtable_column(const char* name) { const size_t column_ndx = m_names.Size(); - add_column(COLUMN_TYPE_TABLE, name); + add_column(type_Table, name); return get_subtable_spec(column_ndx); } @@ -174,8 +174,8 @@ void Spec::remove_column(size_t column_ndx) // If the column is a subtable column, we have to delete // the subspec(s) as well - const ColumnType type = (ColumnType)m_spec.Get(type_ndx); - if (type == COLUMN_TYPE_TABLE) { + const ColumnType type = ColumnType(m_spec.Get(type_ndx)); + if (type == col_type_Table) { const size_t subspec_ndx = get_subspec_ndx(column_ndx); const size_t subspec_ref = m_subSpecs.GetAsRef(subspec_ndx); @@ -190,8 +190,8 @@ void Spec::remove_column(size_t column_ndx) // If there are an attribute, we have to delete that as well if (type_ndx > 0) { - const ColumnType type_prefix = (ColumnType)m_spec.Get(type_ndx-1); - if (type_prefix >= COLUMN_ATTR_INDEXED) + const ColumnType type_prefix = ColumnType(m_spec.Get(type_ndx-1)); + if (type_prefix >= col_attr_Indexed) m_spec.Delete(type_ndx-1); } } @@ -216,7 +216,7 @@ void Spec::do_remove_column(const vector& column_ids, size_t pos) Spec Spec::get_subtable_spec(size_t column_ndx) { TIGHTDB_ASSERT(column_ndx < get_column_count()); - TIGHTDB_ASSERT(get_column_type(column_ndx) == COLUMN_TYPE_TABLE); + TIGHTDB_ASSERT(get_column_type(column_ndx) == type_Table); const size_t subspec_ndx = get_subspec_ndx(column_ndx); @@ -229,7 +229,7 @@ Spec Spec::get_subtable_spec(size_t column_ndx) const Spec Spec::get_subtable_spec(size_t column_ndx) const { TIGHTDB_ASSERT(column_ndx < get_column_count()); - TIGHTDB_ASSERT(get_column_type(column_ndx) == COLUMN_TYPE_TABLE); + TIGHTDB_ASSERT(get_column_type(column_ndx) == type_Table); const size_t subspec_ndx = get_subspec_ndx(column_ndx); @@ -247,7 +247,7 @@ size_t Spec::get_subspec_ndx(size_t column_ndx) const // so we need to count up to it's position size_t pos = 0; for (size_t i = 0; i < type_ndx; ++i) { - if ((ColumnType)m_spec.Get(i) == COLUMN_TYPE_TABLE) ++pos; + if (ColumnType(m_spec.Get(i)) == col_type_Table) ++pos; } return pos; } @@ -287,7 +287,7 @@ size_t Spec::get_column_type_pos(size_t column_ndx) const TIGHTDB_NOEXCEPT size_t type_ndx = 0; for (; type_ndx < column_ndx; ++i) { const ColumnType type = ColumnType(m_spec.Get(i)); - if (type >= COLUMN_ATTR_INDEXED) continue; // ignore attributes + if (type >= col_attr_Indexed) continue; // ignore attributes ++type_ndx; } return i; @@ -301,22 +301,23 @@ ColumnType Spec::get_real_column_type(size_t ndx) const TIGHTDB_NOEXCEPT size_t column_ndx = 0; for (size_t i = 0; column_ndx <= ndx; ++i) { type = ColumnType(m_spec.Get(i)); - if (type >= COLUMN_ATTR_INDEXED) continue; // ignore attributes + if (type >= col_attr_Indexed) continue; // ignore attributes ++column_ndx; } return type; } -ColumnType Spec::get_column_type(size_t ndx) const TIGHTDB_NOEXCEPT +DataType Spec::get_column_type(size_t ndx) const TIGHTDB_NOEXCEPT { TIGHTDB_ASSERT(ndx < get_column_count()); const ColumnType type = get_real_column_type(ndx); // Hide internal types - if (type == COLUMN_TYPE_STRING_ENUM) return COLUMN_TYPE_STRING; - else return type; + if (type == col_type_StringEnum) return type_String; + + return DataType(type); } void Spec::set_column_type(std::size_t column_ndx, ColumnType type) @@ -328,15 +329,15 @@ void Spec::set_column_type(std::size_t column_ndx, ColumnType type) const size_t count = m_spec.Size(); for (;type_ndx < count; ++type_ndx) { - const size_t t = (ColumnType)m_spec.Get(type_ndx); - if (t >= COLUMN_ATTR_INDEXED) continue; // ignore attributes + const ColumnType t = ColumnType(m_spec.Get(type_ndx)); + if (t >= col_attr_Indexed) continue; // ignore attributes if (column_count == column_ndx) break; ++column_count; } // At this point we only support upgrading to string enum - TIGHTDB_ASSERT((ColumnType)m_spec.Get(type_ndx) == COLUMN_TYPE_STRING); - TIGHTDB_ASSERT(type == COLUMN_TYPE_STRING_ENUM); + TIGHTDB_ASSERT(ColumnType(m_spec.Get(type_ndx)) == col_type_String); + TIGHTDB_ASSERT(type == col_type_StringEnum); m_spec.Set(type_ndx, type); } @@ -350,28 +351,28 @@ ColumnType Spec::get_column_attr(size_t ndx) const // The attribute is an optional prefix for the type for (size_t i = 0; column_ndx <= ndx; ++i) { const ColumnType type = (ColumnType)m_spec.Get(i); - if (type >= COLUMN_ATTR_INDEXED) { + if (type >= col_attr_Indexed) { if (column_ndx == ndx) return type; } else ++column_ndx; } - return COLUMN_ATTR_NONE; + return col_attr_None; } void Spec::set_column_attr(size_t ndx, ColumnType attr) { TIGHTDB_ASSERT(ndx < get_column_count()); - TIGHTDB_ASSERT(attr >= COLUMN_ATTR_INDEXED); + TIGHTDB_ASSERT(attr >= col_attr_Indexed); size_t column_ndx = 0; for (size_t i = 0; column_ndx <= ndx; ++i) { const ColumnType type = (ColumnType)m_spec.Get(i); - if (type >= COLUMN_ATTR_INDEXED) { + if (type >= col_attr_Indexed) { if (column_ndx == ndx) { // if column already has an attr, we replace it - if (attr == COLUMN_ATTR_NONE) m_spec.Delete(i); + if (attr == col_attr_None) m_spec.Delete(i); else m_spec.Set(i, attr); return; } diff --git a/src/tightdb/spec.hpp b/src/tightdb/spec.hpp index a447e212914..bc9d9d8d8d1 100644 --- a/src/tightdb/spec.hpp +++ b/src/tightdb/spec.hpp @@ -22,6 +22,7 @@ #include #include +#include #include namespace tightdb { @@ -36,8 +37,8 @@ class Spec { Spec(const Spec& s); ~Spec(); - size_t add_column(ColumnType type, const char* name, ColumnType attr=COLUMN_ATTR_NONE); - size_t add_subcolumn(const vector& column_path, ColumnType type, const char* name); + size_t add_column(DataType type, const char* name, ColumnType attr=col_attr_None); + size_t add_subcolumn(const vector& column_path, DataType type, const char* name); Spec add_subtable_column(const char* name); void rename_column(size_t column_ndx, const char* newname); @@ -60,7 +61,7 @@ class Spec { // Column info size_t get_column_count() const TIGHTDB_NOEXCEPT; - ColumnType get_column_type(size_t column_ndx) const TIGHTDB_NOEXCEPT; + DataType get_column_type(size_t column_ndx) const TIGHTDB_NOEXCEPT; ColumnType get_real_column_type(size_t column_ndx) const TIGHTDB_NOEXCEPT; const char* get_column_name(size_t column_ndx) const TIGHTDB_NOEXCEPT; @@ -97,12 +98,6 @@ class Spec { bool update_from_parent(); void set_parent(ArrayParent* parent, size_t pndx); - // FIXME: This one was made private because it is called - // internally from Table::optimize(), and it is not called from - // any test case. If it must be public, it must also be made to - // emit a transaction log instruction, but the internal call must - // then call a different version that does not emit such an - // instruction. void set_column_type(size_t column_ndx, ColumnType type); void set_column_attr(size_t column_ndx, ColumnType attr); @@ -119,7 +114,7 @@ class Spec { /// underlying memory. static size_t create_empty_spec(Allocator&); - size_t do_add_subcolumn(const vector& column_ids, size_t pos, ColumnType type, const char* name); + size_t do_add_subcolumn(const vector& column_ids, size_t pos, DataType type, const char* name); void do_remove_column(const vector& column_ids, size_t pos); void do_rename_column(const vector& column_ids, size_t pos, const char* name); diff --git a/src/tightdb/table.cpp b/src/tightdb/table.cpp index 6e0706f0234..d07710c8c96 100644 --- a/src/tightdb/table.cpp +++ b/src/tightdb/table.cpp @@ -70,7 +70,7 @@ void Table::CreateColumns() } size_t subtable_count = 0; - ColumnType attr = COLUMN_ATTR_NONE; + ColumnType attr = col_attr_None; Allocator& alloc = m_columns.GetAllocator(); const size_t count = m_spec_set.get_type_attr_count(); @@ -81,9 +81,9 @@ void Table::CreateColumns() ColumnBase* new_col = 0; switch (type) { - case COLUMN_TYPE_INT: - case COLUMN_TYPE_BOOL: - case COLUMN_TYPE_DATE: + case type_Int: + case type_Bool: + case type_Date: { Column* c = new Column(COLUMN_NORMAL, alloc); m_columns.add(c->GetRef()); @@ -91,7 +91,7 @@ void Table::CreateColumns() new_col = c; } break; - case COLUMN_TYPE_FLOAT: + case type_Float: { ColumnFloat* c = new ColumnFloat(alloc); m_columns.add(c->GetRef()); @@ -99,7 +99,7 @@ void Table::CreateColumns() new_col = c; } break; - case COLUMN_TYPE_DOUBLE: + case type_Double: { ColumnDouble* c = new ColumnDouble(alloc); m_columns.add(c->GetRef()); @@ -107,7 +107,7 @@ void Table::CreateColumns() new_col = c; } break; - case COLUMN_TYPE_STRING: + case type_String: { AdaptiveStringColumn* c = new AdaptiveStringColumn(alloc); m_columns.add(c->GetRef()); @@ -115,7 +115,7 @@ void Table::CreateColumns() new_col = c; } break; - case COLUMN_TYPE_BINARY: + case type_Binary: { ColumnBinary* c = new ColumnBinary(alloc); m_columns.add(c->GetRef()); @@ -123,7 +123,7 @@ void Table::CreateColumns() new_col = c; } break; - case COLUMN_TYPE_TABLE: + case type_Table: { const size_t column_ndx = m_cols.Size(); const size_t subspec_ref = m_spec_set.get_subspec_ref(subtable_count); @@ -134,7 +134,7 @@ void Table::CreateColumns() ++subtable_count; } break; - case COLUMN_TYPE_MIXED: + case type_Mixed: { const size_t column_ndx = m_cols.Size(); ColumnMixed* c = new ColumnMixed(alloc, this, column_ndx); @@ -145,8 +145,8 @@ void Table::CreateColumns() break; // Attributes - case COLUMN_ATTR_INDEXED: - case COLUMN_ATTR_UNIQUE: + case col_attr_Indexed: + case col_attr_Unique: attr = type; continue; // attr prefix column types) @@ -158,11 +158,11 @@ void Table::CreateColumns() m_cols.add(reinterpret_cast(new_col)); // FIXME: intptr_t is not guaranteed to exists, not even in C++11 // Atributes on columns may define that they come with an index - if (attr != COLUMN_ATTR_NONE) { + if (attr != col_attr_None) { const size_t column_ndx = m_cols.Size()-1; set_index(column_ndx, false); - attr = COLUMN_ATTR_NONE; + attr = col_attr_None; } } } @@ -200,7 +200,7 @@ void Table::invalidate() void Table::InstantiateBeforeChange() { // Empty (zero-ref'ed) tables need to be instantiated before first modification - if (!m_columns.IsValid()) + if (!m_columns.IsValid()) CreateColumns(); } @@ -209,7 +209,7 @@ void Table::CacheColumns() TIGHTDB_ASSERT(m_cols.is_empty()); // only done on creation Allocator& alloc = m_columns.GetAllocator(); - ColumnType attr = COLUMN_ATTR_NONE; + ColumnType attr = col_attr_None; size_t size = size_t(-1); size_t ndx_in_parent = 0; const size_t count = m_spec_set.get_type_attr_count(); @@ -223,30 +223,30 @@ void Table::CacheColumns() ColumnBase* new_col = 0; size_t colsize = size_t(-1); switch (type) { - case COLUMN_TYPE_INT: - case COLUMN_TYPE_BOOL: - case COLUMN_TYPE_DATE: + case type_Int: + case type_Bool: + case type_Date: { Column* c = new Column(ref, &m_columns, ndx_in_parent, alloc); colsize = c->Size(); new_col = c; } break; - case COLUMN_TYPE_FLOAT: + case type_Float: { ColumnFloat* c = new ColumnFloat(ref, &m_columns, ndx_in_parent, alloc); colsize = c->Size(); new_col = c; } break; - case COLUMN_TYPE_DOUBLE: + case type_Double: { ColumnDouble* c = new ColumnDouble(ref, &m_columns, ndx_in_parent, alloc); colsize = c->Size(); new_col = c; } break; - case COLUMN_TYPE_STRING: + case type_String: { AdaptiveStringColumn* c = new AdaptiveStringColumn(ref, &m_columns, ndx_in_parent, alloc); @@ -254,14 +254,14 @@ void Table::CacheColumns() new_col = c; } break; - case COLUMN_TYPE_BINARY: + case type_Binary: { ColumnBinary* c = new ColumnBinary(ref, &m_columns, ndx_in_parent, alloc); colsize = c->Size(); new_col = c; } break; - case COLUMN_TYPE_STRING_ENUM: + case col_type_StringEnum: { const size_t values_ref = m_columns.GetAsRef(ndx_in_parent+1); ColumnStringEnum* c = @@ -271,7 +271,7 @@ void Table::CacheColumns() ++ndx_in_parent; // advance one matchcount pos to account for keys/values pair } break; - case COLUMN_TYPE_TABLE: + case type_Table: { const size_t column_ndx = m_cols.Size(); const size_t spec_ref = m_spec_set.get_subspec_ref(subtable_count); @@ -282,7 +282,7 @@ void Table::CacheColumns() ++subtable_count; } break; - case COLUMN_TYPE_MIXED: + case type_Mixed: { const size_t column_ndx = m_cols.Size(); ColumnMixed* c = @@ -293,8 +293,8 @@ void Table::CacheColumns() break; // Attributes (prefixing column types) - case COLUMN_ATTR_INDEXED: - case COLUMN_ATTR_UNIQUE: + case col_attr_Indexed: + case col_attr_Unique: attr = type; continue; @@ -305,17 +305,17 @@ void Table::CacheColumns() m_cols.add(reinterpret_cast(new_col)); // FIXME: intptr_t is not guaranteed to exists, even in C++11 // Atributes on columns may define that they come with an index - if (attr != COLUMN_ATTR_NONE) { - TIGHTDB_ASSERT(attr == COLUMN_ATTR_INDEXED); // only attribute supported for now - TIGHTDB_ASSERT(type == COLUMN_TYPE_STRING || - type == COLUMN_TYPE_STRING_ENUM); // index only for strings + if (attr != col_attr_None) { + TIGHTDB_ASSERT(attr == col_attr_Indexed); // only attribute supported for now + TIGHTDB_ASSERT(type == col_type_String || + type == col_type_StringEnum); // index only for strings const size_t pndx = ndx_in_parent+1; const size_t index_ref = m_columns.GetAsRef(pndx); new_col->SetIndexRef(index_ref, &m_columns, pndx); ++ndx_in_parent; // advance one matchcount pos to account for index - attr = COLUMN_ATTR_NONE; + attr = col_attr_None; } // Set table size @@ -391,36 +391,6 @@ Table::~Table() m_top.Destroy(); } -size_t Table::get_column_count() const TIGHTDB_NOEXCEPT -{ - return m_spec_set.get_column_count(); -} - -const char* Table::get_column_name(size_t ndx) const TIGHTDB_NOEXCEPT -{ - TIGHTDB_ASSERT(ndx < get_column_count()); - return m_spec_set.get_column_name(ndx); -} - -size_t Table::get_column_index(const char* name) const -{ - return m_spec_set.get_column_index(name); -} - -ColumnType Table::GetRealColumnType(size_t ndx) const TIGHTDB_NOEXCEPT -{ - TIGHTDB_ASSERT(ndx < get_column_count()); - return m_spec_set.get_real_column_type(ndx); -} - -ColumnType Table::get_column_type(size_t ndx) const TIGHTDB_NOEXCEPT -{ - TIGHTDB_ASSERT(ndx < get_column_count()); - - // Hides internal types like COLUM_STRING_ENUM - return m_spec_set.get_column_type(ndx); -} - size_t Table::GetColumnRefPos(size_t column_ndx) const { size_t pos = 0; @@ -433,9 +403,9 @@ size_t Table::GetColumnRefPos(size_t column_ndx) const ++pos; const ColumnType type = (ColumnType)m_spec_set.get_type_attr(i); - if (type >= COLUMN_ATTR_INDEXED) + if (type >= col_attr_Indexed) continue; // ignore attributes - if (type == COLUMN_TYPE_STRING_ENUM) + if (type == col_type_StringEnum) ++pos; // string enums take up two places in m_columns ++current_column; @@ -445,7 +415,7 @@ size_t Table::GetColumnRefPos(size_t column_ndx) const return (size_t)-1; } -size_t Table::add_subcolumn(const vector& column_path, ColumnType type, const char* name) +size_t Table::add_subcolumn(const vector& column_path, DataType type, const char* name) { TIGHTDB_ASSERT(!column_path.empty()); @@ -465,14 +435,14 @@ size_t Table::add_subcolumn(const vector& column_path, ColumnType type, return column_ndx; } -void Table::do_add_subcolumn(const vector& column_path, size_t pos, ColumnType type) +void Table::do_add_subcolumn(const vector& column_path, size_t pos, DataType type) { const size_t column_ndx = column_path[pos]; const bool is_last = (pos == column_path.size()-1); #ifdef TIGHTDB_DEBUG - const ColumnType stype = GetRealColumnType(column_ndx); - TIGHTDB_ASSERT(stype == COLUMN_TYPE_TABLE); + const ColumnType stype = get_real_column_type(column_ndx); + TIGHTDB_ASSERT(stype == col_type_Table); #endif // TIGHTDB_DEBUG const size_t row_count = size(); @@ -489,7 +459,7 @@ void Table::do_add_subcolumn(const vector& column_path, size_t pos, Colu } } -size_t Table::add_column(ColumnType type, const char* name) +size_t Table::add_column(DataType type, const char* name) { // Create column and add cached instance const size_t column_ndx = do_add_column(type); @@ -498,7 +468,7 @@ size_t Table::add_column(ColumnType type, const char* name) m_spec_set.add_column(type, name); // Since subspec was not set at creation time we have to set it now - if (type == COLUMN_TYPE_TABLE) { + if (type == type_Table) { const size_t subspec_ref = m_spec_set.get_subspec_ref(m_spec_set.get_num_subspecs()-1); ColumnTable& c = GetColumnTable(column_ndx); c.set_specref(subspec_ref); @@ -511,7 +481,7 @@ size_t Table::add_column(ColumnType type, const char* name) return column_ndx; } -size_t Table::do_add_column(ColumnType type) +size_t Table::do_add_column(DataType type) { const size_t count = size(); const size_t column_ndx = m_cols.Size(); @@ -520,9 +490,9 @@ size_t Table::do_add_column(ColumnType type) Allocator& alloc = m_columns.GetAllocator(); switch (type) { - case COLUMN_TYPE_INT: - case COLUMN_TYPE_BOOL: - case COLUMN_TYPE_DATE: + case type_Int: + case type_Bool: + case type_Date: { Column* c = new Column(COLUMN_NORMAL, alloc); m_columns.add(c->GetRef()); @@ -531,7 +501,7 @@ size_t Table::do_add_column(ColumnType type) c->fill(count); } break; - case COLUMN_TYPE_FLOAT: + case type_Float: { ColumnFloat* c = new ColumnFloat(alloc); m_columns.add(c->GetRef()); @@ -540,7 +510,7 @@ size_t Table::do_add_column(ColumnType type) c->fill(count); } break; - case COLUMN_TYPE_DOUBLE: + case type_Double: { ColumnDouble* c = new ColumnDouble(alloc); m_columns.add(c->GetRef()); @@ -549,7 +519,7 @@ size_t Table::do_add_column(ColumnType type) c->fill(count); } break; - case COLUMN_TYPE_STRING: + case type_String: { AdaptiveStringColumn* c = new AdaptiveStringColumn(alloc); m_columns.add(c->GetRef()); @@ -558,7 +528,7 @@ size_t Table::do_add_column(ColumnType type) c->fill(count); } break; - case COLUMN_TYPE_BINARY: + case type_Binary: { ColumnBinary* c = new ColumnBinary(alloc); m_columns.add(c->GetRef()); @@ -568,7 +538,7 @@ size_t Table::do_add_column(ColumnType type) } break; - case COLUMN_TYPE_TABLE: + case type_Table: { ColumnTable* c = new ColumnTable(alloc, this, column_ndx, -1); // subspec ref will be filled in later m_columns.add(c->GetRef()); @@ -578,7 +548,7 @@ size_t Table::do_add_column(ColumnType type) } break; - case COLUMN_TYPE_MIXED: + case type_Mixed: { ColumnMixed* c = new ColumnMixed(alloc, this, column_ndx); m_columns.add(c->GetRef()); @@ -587,8 +557,6 @@ size_t Table::do_add_column(ColumnType type) c->fill(count); } break; - default: - TIGHTDB_ASSERT(false); } m_cols.add(reinterpret_cast(new_col)); // FIXME: intptr_t is not guaranteed to exists, even in C++11 @@ -655,8 +623,8 @@ void Table::do_remove_column(const vector& column_path, size_t pos) } else { #ifdef TIGHTDB_DEBUG - const ColumnType type = GetRealColumnType(column_ndx); - TIGHTDB_ASSERT(type == COLUMN_TYPE_TABLE); + const ColumnType type = get_real_column_type(column_ndx); + TIGHTDB_ASSERT(type == col_type_Table); #endif // TIGHTDB_DEBUG const size_t row_count = size(); @@ -693,11 +661,11 @@ void Table::set_index(size_t column_ndx, bool update_spec) TIGHTDB_ASSERT(column_ndx < get_column_count()); if (has_index(column_ndx)) return; - const ColumnType ct = GetRealColumnType(column_ndx); + const ColumnType ct = get_real_column_type(column_ndx); const size_t column_pos = GetColumnRefPos(column_ndx); size_t ndx_ref = -1; - if (ct == COLUMN_TYPE_STRING) { + if (ct == col_type_String) { AdaptiveStringColumn& col = GetColumnString(column_ndx); // Create the index @@ -705,7 +673,7 @@ void Table::set_index(size_t column_ndx, bool update_spec) ndx.SetParent(&m_columns, column_pos+1); ndx_ref = ndx.GetRef(); } - else if (ct == COLUMN_TYPE_STRING_ENUM) { + else if (ct == col_type_StringEnum) { ColumnStringEnum& col = GetColumnStringEnum(column_ndx); // Create the index @@ -724,7 +692,7 @@ void Table::set_index(size_t column_ndx, bool update_spec) // Update spec if (update_spec) - m_spec_set.set_column_attr(column_ndx, COLUMN_ATTR_INDEXED); + m_spec_set.set_column_attr(column_ndx, col_attr_Indexed); #ifdef TIGHTDB_ENABLE_REPLICATION transact_log().add_index_to_column(column_ndx); // Throws @@ -751,41 +719,42 @@ const ColumnBase& Table::GetColumnBase(size_t ndx) const TIGHTDB_NOEXCEPT void Table::validate_column_type(const ColumnBase& column, ColumnType coltype, size_t ndx) const { - if (coltype == COLUMN_TYPE_INT || coltype == COLUMN_TYPE_DATE || coltype == COLUMN_TYPE_BOOL) { + if (coltype == col_type_Int || coltype == col_type_Date || coltype == col_type_Bool) { TIGHTDB_ASSERT(column.IsIntColumn()); - } else { - TIGHTDB_ASSERT(coltype == GetRealColumnType(ndx)); } - (void)column; - (void)ndx; + else { + TIGHTDB_ASSERT(coltype == get_real_column_type(ndx)); + } + static_cast(column); + static_cast(ndx); } // TODO: get rid of the Column* template parameter -Column& Table::GetColumn(size_t ndx) { return GetColumn(ndx); } -const Column& Table::GetColumn(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); } +Column& Table::GetColumn(size_t ndx) { return GetColumn(ndx); } +const Column& Table::GetColumn(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); } -AdaptiveStringColumn& Table::GetColumnString(size_t ndx) { return GetColumn(ndx); } -const AdaptiveStringColumn& Table::GetColumnString(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); } +AdaptiveStringColumn& Table::GetColumnString(size_t ndx) { return GetColumn(ndx); } +const AdaptiveStringColumn& Table::GetColumnString(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); } -ColumnStringEnum& Table::GetColumnStringEnum(size_t ndx) { return GetColumn(ndx); } -const ColumnStringEnum& Table::GetColumnStringEnum(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); } +ColumnStringEnum& Table::GetColumnStringEnum(size_t ndx) { return GetColumn(ndx); } +const ColumnStringEnum& Table::GetColumnStringEnum(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); } -ColumnFloat& Table::GetColumnFloat(size_t ndx) { return GetColumn(ndx); } -const ColumnFloat& Table::GetColumnFloat(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); } +ColumnFloat& Table::GetColumnFloat(size_t ndx) { return GetColumn(ndx); } +const ColumnFloat& Table::GetColumnFloat(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); } -ColumnDouble& Table::GetColumnDouble(size_t ndx) { return GetColumn(ndx); } -const ColumnDouble& Table::GetColumnDouble(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); } +ColumnDouble& Table::GetColumnDouble(size_t ndx) { return GetColumn(ndx); } +const ColumnDouble& Table::GetColumnDouble(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); } -ColumnBinary& Table::GetColumnBinary(size_t ndx) { return GetColumn(ndx); } -const ColumnBinary& Table::GetColumnBinary(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); } +ColumnBinary& Table::GetColumnBinary(size_t ndx) { return GetColumn(ndx); } +const ColumnBinary& Table::GetColumnBinary(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); } -ColumnTable &Table::GetColumnTable(size_t ndx) { return GetColumn(ndx); } -const ColumnTable &Table::GetColumnTable(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); } +ColumnTable &Table::GetColumnTable(size_t ndx) { return GetColumn(ndx); } +const ColumnTable &Table::GetColumnTable(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); } -ColumnMixed& Table::GetColumnMixed(size_t ndx) { return GetColumn(ndx); } -const ColumnMixed& Table::GetColumnMixed(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); } +ColumnMixed& Table::GetColumnMixed(size_t ndx) { return GetColumn(ndx); } +const ColumnMixed& Table::GetColumnMixed(size_t ndx) const TIGHTDB_NOEXCEPT { return GetColumn(ndx); } @@ -863,7 +832,7 @@ void Table::remove(size_t ndx) void Table::insert_subtable(size_t column_ndx, size_t ndx) { TIGHTDB_ASSERT(column_ndx < get_column_count()); - TIGHTDB_ASSERT(GetRealColumnType(column_ndx) == COLUMN_TYPE_TABLE); + TIGHTDB_ASSERT(get_real_column_type(column_ndx) == col_type_Table); TIGHTDB_ASSERT(ndx <= m_size); ColumnTable& subtables = GetColumnTable(column_ndx); @@ -880,12 +849,12 @@ Table* Table::get_subtable_ptr(size_t col_idx, size_t row_idx) TIGHTDB_ASSERT(col_idx < get_column_count()); TIGHTDB_ASSERT(row_idx < m_size); - const ColumnType type = GetRealColumnType(col_idx); - if (type == COLUMN_TYPE_TABLE) { + const ColumnType type = get_real_column_type(col_idx); + if (type == col_type_Table) { ColumnTable& subtables = GetColumnTable(col_idx); return subtables.get_subtable_ptr(row_idx); } - if (type == COLUMN_TYPE_MIXED) { + if (type == col_type_Mixed) { ColumnMixed& subtables = GetColumnMixed(col_idx); return subtables.get_subtable_ptr(row_idx); } @@ -898,12 +867,12 @@ const Table* Table::get_subtable_ptr(size_t col_idx, size_t row_idx) const TIGHTDB_ASSERT(col_idx < get_column_count()); TIGHTDB_ASSERT(row_idx < m_size); - const ColumnType type = GetRealColumnType(col_idx); - if (type == COLUMN_TYPE_TABLE) { + const ColumnType type = get_real_column_type(col_idx); + if (type == col_type_Table) { const ColumnTable& subtables = GetColumnTable(col_idx); return subtables.get_subtable_ptr(row_idx); } - if (type == COLUMN_TYPE_MIXED) { + if (type == col_type_Mixed) { const ColumnMixed& subtables = GetColumnMixed(col_idx); return subtables.get_subtable_ptr(row_idx); } @@ -916,12 +885,12 @@ size_t Table::get_subtable_size(size_t col_idx, size_t row_idx) const TIGHTDB_NO TIGHTDB_ASSERT(col_idx < get_column_count()); TIGHTDB_ASSERT(row_idx < m_size); - const ColumnType type = GetRealColumnType(col_idx); - if (type == COLUMN_TYPE_TABLE) { + const ColumnType type = get_real_column_type(col_idx); + if (type == col_type_Table) { const ColumnTable& subtables = GetColumnTable(col_idx); return subtables.get_subtable_size(row_idx); } - if (type == COLUMN_TYPE_MIXED) { + if (type == col_type_Mixed) { const ColumnMixed& subtables = GetColumnMixed(col_idx); return subtables.get_subtable_size(row_idx); } @@ -934,8 +903,8 @@ void Table::clear_subtable(size_t col_idx, size_t row_idx) TIGHTDB_ASSERT(col_idx < get_column_count()); TIGHTDB_ASSERT(row_idx <= m_size); - const ColumnType type = GetRealColumnType(col_idx); - if (type == COLUMN_TYPE_TABLE) { + const ColumnType type = get_real_column_type(col_idx); + if (type == col_type_Table) { ColumnTable& subtables = GetColumnTable(col_idx); subtables.ClearTable(row_idx); subtables.invalidate_subtables(); @@ -944,7 +913,7 @@ void Table::clear_subtable(size_t col_idx, size_t row_idx) transact_log().set_value(col_idx, row_idx, Replication::subtable_tag()); // Throws #endif } - else if (type == COLUMN_TYPE_MIXED) { + else if (type == col_type_Mixed) { ColumnMixed& subtables = GetColumnMixed(col_idx); subtables.set_subtable(row_idx); subtables.invalidate_subtables(); @@ -984,7 +953,7 @@ void Table::set_int(size_t column_ndx, size_t ndx, int64_t value) void Table::add_int(size_t column_ndx, int64_t value) { TIGHTDB_ASSERT(column_ndx < get_column_count()); - TIGHTDB_ASSERT(GetRealColumnType(column_ndx) == COLUMN_TYPE_INT); + TIGHTDB_ASSERT(get_real_column_type(column_ndx) == col_type_Int); GetColumn(column_ndx).Increment64(value); #ifdef TIGHTDB_ENABLE_REPLICATION @@ -996,7 +965,7 @@ void Table::add_int(size_t column_ndx, int64_t value) bool Table::get_bool(size_t column_ndx, size_t ndx) const TIGHTDB_NOEXCEPT { TIGHTDB_ASSERT(column_ndx < get_column_count()); - TIGHTDB_ASSERT(GetRealColumnType(column_ndx) == COLUMN_TYPE_BOOL); + TIGHTDB_ASSERT(get_real_column_type(column_ndx) == col_type_Bool); TIGHTDB_ASSERT(ndx < m_size); const Column& column = GetColumn(column_ndx); @@ -1006,7 +975,7 @@ bool Table::get_bool(size_t column_ndx, size_t ndx) const TIGHTDB_NOEXCEPT void Table::set_bool(size_t column_ndx, size_t ndx, bool value) { TIGHTDB_ASSERT(column_ndx < get_column_count()); - TIGHTDB_ASSERT(GetRealColumnType(column_ndx) == COLUMN_TYPE_BOOL); + TIGHTDB_ASSERT(get_real_column_type(column_ndx) == col_type_Bool); TIGHTDB_ASSERT(ndx < m_size); Column& column = GetColumn(column_ndx); @@ -1020,21 +989,21 @@ void Table::set_bool(size_t column_ndx, size_t ndx, bool value) time_t Table::get_date(size_t column_ndx, size_t ndx) const TIGHTDB_NOEXCEPT { TIGHTDB_ASSERT(column_ndx < get_column_count()); - TIGHTDB_ASSERT(GetRealColumnType(column_ndx) == COLUMN_TYPE_DATE); + TIGHTDB_ASSERT(get_real_column_type(column_ndx) == col_type_Date); TIGHTDB_ASSERT(ndx < m_size); const Column& column = GetColumn(column_ndx); - return (time_t)column.Get(ndx); + return time_t(column.Get(ndx)); } void Table::set_date(size_t column_ndx, size_t ndx, time_t value) { TIGHTDB_ASSERT(column_ndx < get_column_count()); - TIGHTDB_ASSERT(GetRealColumnType(column_ndx) == COLUMN_TYPE_DATE); + TIGHTDB_ASSERT(get_real_column_type(column_ndx) == col_type_Date); TIGHTDB_ASSERT(ndx < m_size); Column& column = GetColumn(column_ndx); - column.Set(ndx, (int64_t)value); + column.Set(ndx, int64_t(value)); #ifdef TIGHTDB_ENABLE_REPLICATION transact_log().set_value(column_ndx, ndx, value); // Throws @@ -1136,14 +1105,14 @@ const char* Table::get_string(size_t column_ndx, size_t ndx) const TIGHTDB_NOEXC TIGHTDB_ASSERT(column_ndx < m_columns.Size()); TIGHTDB_ASSERT(ndx < m_size); - const ColumnType type = GetRealColumnType(column_ndx); + const ColumnType type = get_real_column_type(column_ndx); - if (type == COLUMN_TYPE_STRING) { + if (type == col_type_String) { const AdaptiveStringColumn& column = GetColumnString(column_ndx); return column.Get(ndx); } else { - TIGHTDB_ASSERT(type == COLUMN_TYPE_STRING_ENUM); + TIGHTDB_ASSERT(type == col_type_StringEnum); const ColumnStringEnum& column = GetColumnStringEnum(column_ndx); return column.Get(ndx); } @@ -1160,14 +1129,14 @@ void Table::set_string(size_t column_ndx, size_t ndx, const char* value) TIGHTDB_ASSERT(column_ndx < get_column_count()); TIGHTDB_ASSERT(ndx < m_size); - const ColumnType type = GetRealColumnType(column_ndx); + const ColumnType type = get_real_column_type(column_ndx); - if (type == COLUMN_TYPE_STRING) { + if (type == col_type_String) { AdaptiveStringColumn& column = GetColumnString(column_ndx); column.Set(ndx, value); } else { - TIGHTDB_ASSERT(type == COLUMN_TYPE_STRING_ENUM); + TIGHTDB_ASSERT(type == col_type_StringEnum); ColumnStringEnum& column = GetColumnStringEnum(column_ndx); column.Set(ndx, value); } @@ -1182,14 +1151,14 @@ void Table::insert_string(size_t column_ndx, size_t ndx, const char* value) TIGHTDB_ASSERT(column_ndx < get_column_count()); TIGHTDB_ASSERT(ndx <= m_size); - const ColumnType type = GetRealColumnType(column_ndx); + const ColumnType type = get_real_column_type(column_ndx); - if (type == COLUMN_TYPE_STRING) { + if (type == col_type_String) { AdaptiveStringColumn& column = GetColumnString(column_ndx); column.Insert(ndx, value); } else { - TIGHTDB_ASSERT(type == COLUMN_TYPE_STRING_ENUM); + TIGHTDB_ASSERT(type == col_type_StringEnum); ColumnStringEnum& column = GetColumnStringEnum(column_ndx); column.Insert(ndx, value); } @@ -1242,38 +1211,39 @@ Mixed Table::get_mixed(size_t column_ndx, size_t ndx) const TIGHTDB_ASSERT(ndx < m_size); const ColumnMixed& column = GetColumnMixed(column_ndx); - const ColumnType type = column.GetType(ndx); + const DataType type = column.get_type(ndx); switch (type) { - case COLUMN_TYPE_INT: + case type_Int: return Mixed(column.get_int(ndx)); - case COLUMN_TYPE_BOOL: + case type_Bool: return Mixed(column.get_bool(ndx)); - case COLUMN_TYPE_DATE: + case type_Date: return Mixed(Date(column.get_date(ndx))); - case COLUMN_TYPE_FLOAT: + case type_Float: return Mixed(column.get_float(ndx)); - case COLUMN_TYPE_DOUBLE: + case type_Double: return Mixed(column.get_double(ndx)); - case COLUMN_TYPE_STRING: + case type_String: return Mixed(column.get_string(ndx)); // Throws - case COLUMN_TYPE_BINARY: + case type_Binary: return Mixed(column.get_binary(ndx)); // Throws - case COLUMN_TYPE_TABLE: + case type_Table: return Mixed::subtable_tag(); - default: - TIGHTDB_ASSERT(false); - return Mixed((int64_t)0); + case type_Mixed: + break; } + TIGHTDB_ASSERT(false); + return Mixed((int64_t)0); } -ColumnType Table::get_mixed_type(size_t column_ndx, size_t ndx) const TIGHTDB_NOEXCEPT +DataType Table::get_mixed_type(size_t column_ndx, size_t ndx) const TIGHTDB_NOEXCEPT { TIGHTDB_ASSERT(column_ndx < m_columns.Size()); TIGHTDB_ASSERT(ndx < m_size); const ColumnMixed& column = GetColumnMixed(column_ndx); - return column.GetType(ndx); + return column.get_type(ndx); } void Table::set_mixed(size_t column_ndx, size_t ndx, Mixed value) @@ -1282,38 +1252,38 @@ void Table::set_mixed(size_t column_ndx, size_t ndx, Mixed value) TIGHTDB_ASSERT(ndx < m_size); ColumnMixed& column = GetColumnMixed(column_ndx); - const ColumnType type = value.get_type(); + const DataType type = value.get_type(); switch (type) { - case COLUMN_TYPE_INT: + case type_Int: column.set_int(ndx, value.get_int()); break; - case COLUMN_TYPE_BOOL: + case type_Bool: column.set_bool(ndx, value.get_bool()); break; - case COLUMN_TYPE_DATE: + case type_Date: column.set_date(ndx, value.get_date()); break; - case COLUMN_TYPE_FLOAT: + case type_Float: column.set_float(ndx, value.get_float()); break; - case COLUMN_TYPE_DOUBLE: + case type_Double: column.set_double(ndx, value.get_double()); break; - case COLUMN_TYPE_STRING: + case type_String: column.set_string(ndx, value.get_string()); break; - case COLUMN_TYPE_BINARY: - { + case type_Binary: { const BinaryData b = value.get_binary(); - column.set_binary(ndx, (const char*)b.pointer, b.len); + column.set_binary(ndx, b.pointer, b.len); break; } - case COLUMN_TYPE_TABLE: + case type_Table: column.set_subtable(ndx); break; - default: + case type_Mixed: TIGHTDB_ASSERT(false); + break; } column.invalidate_subtables(); @@ -1328,38 +1298,38 @@ void Table::insert_mixed(size_t column_ndx, size_t ndx, Mixed value) { TIGHTDB_ASSERT(ndx <= m_size); ColumnMixed& column = GetColumnMixed(column_ndx); - const ColumnType type = value.get_type(); + const DataType type = value.get_type(); switch (type) { - case COLUMN_TYPE_INT: + case type_Int: column.insert_int(ndx, value.get_int()); break; - case COLUMN_TYPE_BOOL: + case type_Bool: column.insert_bool(ndx, value.get_bool()); break; - case COLUMN_TYPE_DATE: + case type_Date: column.insert_date(ndx, value.get_date()); break; - case COLUMN_TYPE_FLOAT: + case type_Float: column.insert_float(ndx, value.get_float()); break; - case COLUMN_TYPE_DOUBLE: + case type_Double: column.insert_double(ndx, value.get_double()); break; - case COLUMN_TYPE_STRING: + case type_String: column.insert_string(ndx, value.get_string()); break; - case COLUMN_TYPE_BINARY: - { + case type_Binary: { const BinaryData b = value.get_binary(); - column.insert_binary(ndx, (const char*)b.pointer, b.len); + column.insert_binary(ndx, b.pointer, b.len); break; } - case COLUMN_TYPE_TABLE: + case type_Table: column.insert_subtable(ndx); break; - default: + case type_Mixed: TIGHTDB_ASSERT(false); + break; } column.invalidate_subtables(); @@ -1387,17 +1357,17 @@ void Table::insert_done() size_t Table::count_int(size_t column_ndx, int64_t target) const { - const Column& column = GetColumn(column_ndx); + const Column& column = GetColumn(column_ndx); return column.count(target); } size_t Table::count_float(size_t column_ndx, float target) const { - const ColumnFloat& column = GetColumn(column_ndx); + const ColumnFloat& column = GetColumn(column_ndx); return column.count(target); } size_t Table::count_double(size_t column_ndx, double target) const { - const ColumnDouble& column = GetColumn(column_ndx); + const ColumnDouble& column = GetColumn(column_ndx); return column.count(target); } size_t Table::count_string(size_t column_ndx, const char* value) const @@ -1405,14 +1375,14 @@ size_t Table::count_string(size_t column_ndx, const char* value) const TIGHTDB_ASSERT(column_ndx < get_column_count()); TIGHTDB_ASSERT(value); - const ColumnType type = GetRealColumnType(column_ndx); + const ColumnType type = get_real_column_type(column_ndx); - if (type == COLUMN_TYPE_STRING) { + if (type == col_type_String) { const AdaptiveStringColumn& column = GetColumnString(column_ndx); return column.count(value); } else { - TIGHTDB_ASSERT(type == COLUMN_TYPE_STRING_ENUM); + TIGHTDB_ASSERT(type == col_type_StringEnum); const ColumnStringEnum& column = GetColumnStringEnum(column_ndx); return column.count(value); } @@ -1422,17 +1392,17 @@ size_t Table::count_string(size_t column_ndx, const char* value) const int64_t Table::sum(size_t column_ndx) const { - const Column& column = GetColumn(column_ndx); + const Column& column = GetColumn(column_ndx); return column.sum(); } double Table::sum_float(size_t column_ndx) const { - const ColumnFloat& column = GetColumn(column_ndx); + const ColumnFloat& column = GetColumn(column_ndx); return column.sum(); } double Table::sum_double(size_t column_ndx) const { - const ColumnDouble& column = GetColumn(column_ndx); + const ColumnDouble& column = GetColumn(column_ndx); return column.sum(); } @@ -1440,17 +1410,17 @@ double Table::sum_double(size_t column_ndx) const double Table::average(size_t column_ndx) const { - const Column& column = GetColumn(column_ndx); + const Column& column = GetColumn(column_ndx); return column.average(); } double Table::average_float(size_t column_ndx) const { - const ColumnFloat& column = GetColumn(column_ndx); + const ColumnFloat& column = GetColumn(column_ndx); return column.average(); } double Table::average_double(size_t column_ndx) const { - const ColumnDouble& column = GetColumn(column_ndx); + const ColumnDouble& column = GetColumn(column_ndx); return column.average(); } @@ -1461,10 +1431,10 @@ double Table::average_double(size_t column_ndx) const int64_t Table::minimum(size_t column_ndx) const { #if USE_COLUMN_AGGREGATE - const Column& column = GetColumn(column_ndx); + const Column& column = GetColumn(column_ndx); return column.minimum(); #else - if (is_empty()) + if (is_empty()) return 0; int64_t mv = get_int(column_ndx, 0); @@ -1480,12 +1450,12 @@ int64_t Table::minimum(size_t column_ndx) const float Table::minimum_float(size_t column_ndx) const { - const ColumnFloat& column = GetColumn(column_ndx); + const ColumnFloat& column = GetColumn(column_ndx); return column.minimum(); } double Table::minimum_double(size_t column_ndx) const { - const ColumnDouble& column = GetColumn(column_ndx); + const ColumnDouble& column = GetColumn(column_ndx); return column.minimum(); } @@ -1494,7 +1464,7 @@ double Table::minimum_double(size_t column_ndx) const int64_t Table::maximum(size_t column_ndx) const { #if USE_COLUMN_AGGREGATE - const Column& column = GetColumn(column_ndx); + const Column& column = GetColumn(column_ndx); return column.maximum(); #else if (is_empty()) @@ -1512,12 +1482,12 @@ int64_t Table::maximum(size_t column_ndx) const } float Table::maximum_float(size_t column_ndx) const { - const ColumnFloat& column = GetColumn(column_ndx); + const ColumnFloat& column = GetColumn(column_ndx); return column.maximum(); } double Table::maximum_double(size_t column_ndx) const { - const ColumnDouble& column = GetColumn(column_ndx); + const ColumnDouble& column = GetColumn(column_ndx); return column.maximum(); } @@ -1530,9 +1500,9 @@ size_t Table::lookup(const char* value) const if (get_column_count() < 1) return not_found; // no column to lookup in - const ColumnType type = GetRealColumnType(0); + const ColumnType type = get_real_column_type(0); - if (type == COLUMN_TYPE_STRING) { + if (type == col_type_String) { const AdaptiveStringColumn& column = GetColumnString(0); if (!column.HasIndex()) return column.find_first(value); @@ -1540,7 +1510,7 @@ size_t Table::lookup(const char* value) const m_lookup_index = &column.GetIndex(); } } - else if (type == COLUMN_TYPE_STRING_ENUM) { + else if (type == col_type_StringEnum) { const ColumnStringEnum& column = GetColumnStringEnum(0); if (!column.HasIndex()) return column.find_first(value); @@ -1558,7 +1528,7 @@ size_t Table::lookup(const char* value) const size_t Table::find_first_int(size_t column_ndx, int64_t value) const { TIGHTDB_ASSERT(column_ndx < m_columns.Size()); - TIGHTDB_ASSERT(GetRealColumnType(column_ndx) == COLUMN_TYPE_INT); + TIGHTDB_ASSERT(get_real_column_type(column_ndx) == col_type_Int); const Column& column = GetColumn(column_ndx); return column.find_first(value); @@ -1567,7 +1537,7 @@ size_t Table::find_first_int(size_t column_ndx, int64_t value) const size_t Table::find_first_bool(size_t column_ndx, bool value) const { TIGHTDB_ASSERT(column_ndx < m_columns.Size()); - TIGHTDB_ASSERT(GetRealColumnType(column_ndx) == COLUMN_TYPE_BOOL); + TIGHTDB_ASSERT(get_real_column_type(column_ndx) == col_type_Bool); const Column& column = GetColumn(column_ndx); return column.find_first(value ? 1 : 0); @@ -1576,7 +1546,7 @@ size_t Table::find_first_bool(size_t column_ndx, bool value) const size_t Table::find_first_date(size_t column_ndx, time_t value) const { TIGHTDB_ASSERT(column_ndx < m_columns.Size()); - TIGHTDB_ASSERT(GetRealColumnType(column_ndx) == COLUMN_TYPE_DATE); + TIGHTDB_ASSERT(get_real_column_type(column_ndx) == col_type_Date); const Column& column = GetColumn(column_ndx); return column.find_first((int64_t)value); @@ -1585,7 +1555,7 @@ size_t Table::find_first_date(size_t column_ndx, time_t value) const size_t Table::find_first_float(size_t column_ndx, float value) const { TIGHTDB_ASSERT(column_ndx < m_columns.Size()); - TIGHTDB_ASSERT(GetRealColumnType(column_ndx) == COLUMN_TYPE_FLOAT); + TIGHTDB_ASSERT(get_real_column_type(column_ndx) == col_type_Float); const ColumnFloat& column = GetColumnFloat(column_ndx); return column.find_first(value); @@ -1594,7 +1564,7 @@ size_t Table::find_first_float(size_t column_ndx, float value) const size_t Table::find_first_double(size_t column_ndx, double value) const { TIGHTDB_ASSERT(column_ndx < m_columns.Size()); - TIGHTDB_ASSERT(GetRealColumnType(column_ndx) == COLUMN_TYPE_DOUBLE); + TIGHTDB_ASSERT(get_real_column_type(column_ndx) == col_type_Double); const ColumnDouble& column = GetColumnDouble(column_ndx); return column.find_first(value); @@ -1604,14 +1574,14 @@ size_t Table::find_first_string(size_t column_ndx, const char* value) const { TIGHTDB_ASSERT(column_ndx < m_columns.Size()); - const ColumnType type = GetRealColumnType(column_ndx); + const ColumnType type = get_real_column_type(column_ndx); - if (type == COLUMN_TYPE_STRING) { + if (type == col_type_String) { const AdaptiveStringColumn& column = GetColumnString(column_ndx); return column.find_first(value); } else { - TIGHTDB_ASSERT(type == COLUMN_TYPE_STRING_ENUM); + TIGHTDB_ASSERT(type == col_type_StringEnum); const ColumnStringEnum& column = GetColumnStringEnum(column_ndx); return column.find_first(value); } @@ -1746,15 +1716,15 @@ TableView Table::find_all_string(size_t column_ndx, const char *value) { TIGHTDB_ASSERT(column_ndx < m_columns.Size()); - const ColumnType type = GetRealColumnType(column_ndx); + const ColumnType type = get_real_column_type(column_ndx); TableView tv(*this); - if (type == COLUMN_TYPE_STRING) { + if (type == col_type_String) { const AdaptiveStringColumn& column = GetColumnString(column_ndx); column.find_all(tv.get_ref_column(), value); } else { - TIGHTDB_ASSERT(type == COLUMN_TYPE_STRING_ENUM); + TIGHTDB_ASSERT(type == col_type_StringEnum); const ColumnStringEnum& column = GetColumnStringEnum(column_ndx); column.find_all(tv.get_ref_column(), value); } @@ -1765,15 +1735,15 @@ ConstTableView Table::find_all_string(size_t column_ndx, const char *value) cons { TIGHTDB_ASSERT(column_ndx < m_columns.Size()); - const ColumnType type = GetRealColumnType(column_ndx); + const ColumnType type = get_real_column_type(column_ndx); ConstTableView tv(*this); - if (type == COLUMN_TYPE_STRING) { + if (type == col_type_String) { const AdaptiveStringColumn& column = GetColumnString(column_ndx); column.find_all(tv.get_ref_column(), value); } else { - TIGHTDB_ASSERT(type == COLUMN_TYPE_STRING_ENUM); + TIGHTDB_ASSERT(type == col_type_StringEnum); const ColumnStringEnum& column = GetColumnStringEnum(column_ndx); column.find_all(tv.get_ref_column(), value); } @@ -1830,14 +1800,14 @@ TableView Table::distinct(size_t column_ndx) TableView tv(*this); Array& refs = tv.get_ref_column(); - const ColumnType type = GetRealColumnType(column_ndx); - if (type == COLUMN_TYPE_STRING) { + const ColumnType type = get_real_column_type(column_ndx); + if (type == col_type_String) { const AdaptiveStringColumn& column = GetColumnString(column_ndx); const StringIndex& ndx = column.GetIndex(); ndx.distinct(refs); } else { - TIGHTDB_ASSERT(type == COLUMN_TYPE_STRING_ENUM); + TIGHTDB_ASSERT(type == col_type_StringEnum); const ColumnStringEnum& column = GetColumnStringEnum(column_ndx); const StringIndex& ndx = column.GetIndex(); ndx.distinct(refs); @@ -1853,14 +1823,14 @@ ConstTableView Table::distinct(size_t column_ndx) const ConstTableView tv(*this); Array& refs = tv.get_ref_column(); - const ColumnType type = GetRealColumnType(column_ndx); - if (type == COLUMN_TYPE_STRING) { + const ColumnType type = get_real_column_type(column_ndx); + if (type == col_type_String) { const AdaptiveStringColumn& column = GetColumnString(column_ndx); const StringIndex& ndx = column.GetIndex(); ndx.distinct(refs); } else { - TIGHTDB_ASSERT(type == COLUMN_TYPE_STRING_ENUM); + TIGHTDB_ASSERT(type == col_type_StringEnum); const ColumnStringEnum& column = GetColumnStringEnum(column_ndx); const StringIndex& ndx = column.GetIndex(); ndx.distinct(refs); @@ -1912,9 +1882,9 @@ void Table::optimize() Allocator& alloc = m_columns.GetAllocator(); for (size_t i = 0; i < column_count; ++i) { - const ColumnType type = GetRealColumnType(i); + const ColumnType type = get_real_column_type(i); - if (type == COLUMN_TYPE_STRING) { + if (type == col_type_String) { AdaptiveStringColumn* column = &GetColumnString(i); size_t ref_keys; @@ -1923,7 +1893,7 @@ void Table::optimize() if (!res) continue; // Add to spec and column refs - m_spec_set.set_column_type(i, COLUMN_TYPE_STRING_ENUM); + m_spec_set.set_column_type(i, col_type_StringEnum); const size_t column_ndx = GetColumnRefPos(i); m_columns.Set(column_ndx, ref_keys); m_columns.Insert(column_ndx+1, ref_values); @@ -1998,7 +1968,7 @@ void Table::update_from_spec() -static inline void out_date(std::ostream& out, const time_t rawtime) +static inline void out_date(std::ostream& out, const time_t rawtime) { struct tm* const t = gmtime(&rawtime); if (t) { @@ -2011,7 +1981,7 @@ static inline void out_date(std::ostream& out, const time_t rawtime) } } -static inline void out_binary(std::ostream& out, const BinaryData bin) +static inline void out_binary(std::ostream& out, const BinaryData bin) { const char* const p = (char*)bin.pointer; for (size_t i = 0; i < bin.len; ++i) @@ -2025,7 +1995,7 @@ void Table::to_json(std::ostream& out) const size_t row_count = size(); for (size_t r = 0; r < row_count; ++r) { - if (r > 0) + if (r > 0) out << ","; to_json_row(r, out); } @@ -2038,64 +2008,64 @@ void Table::to_json_row(size_t row_ndx, std::ostream& out) out << "{"; const size_t column_count = get_column_count(); for (size_t i = 0; i < column_count; ++i) { - if (i > 0) + if (i > 0) out << ","; const char* const name = get_column_name(i); out << "\"" << name << "\":"; - const ColumnType type = get_column_type(i); + const DataType type = get_column_type(i); switch (type) { - case COLUMN_TYPE_INT: + case type_Int: out << get_int(i, row_ndx); break; - case COLUMN_TYPE_BOOL: + case type_Bool: out << (get_bool(i, row_ndx) ? "true" : "false"); break; - case COLUMN_TYPE_STRING: + case type_String: out << "\"" << get_string(i, row_ndx) << "\""; break; - case COLUMN_TYPE_DATE: + case type_Date: out << "\""; out_date(out, get_date(i, row_ndx)); out << "\""; break; - case COLUMN_TYPE_BINARY: - out << "\""; out_binary(out, get_binary(i, row_ndx)); out << "\""; + case type_Binary: + out << "\""; out_binary(out, get_binary(i, row_ndx)); out << "\""; break; - case COLUMN_TYPE_TABLE: + case type_Table: get_subtable(i, row_ndx)->to_json(out); break; - case COLUMN_TYPE_MIXED: + case type_Mixed: { - const ColumnType mtype = get_mixed_type(i, row_ndx); - if (mtype == COLUMN_TYPE_TABLE) { + const DataType mtype = get_mixed_type(i, row_ndx); + if (mtype == type_Table) { get_subtable(i, row_ndx)->to_json(out); } else { const Mixed m = get_mixed(i, row_ndx); switch (mtype) { - case COLUMN_TYPE_INT: + case type_Int: out << m.get_int(); break; - case COLUMN_TYPE_BOOL: + case type_Bool: out << (m.get_bool() ? "true" : "false"); break; - case COLUMN_TYPE_STRING: + case type_String: out << "\"" << m.get_string() << "\""; break; - case COLUMN_TYPE_DATE: + case type_Date: out << "\""; out_date(out, m.get_date()); out << "\""; break; - case COLUMN_TYPE_BINARY: - out << "\""; out_binary(out, m.get_binary()); out << "\""; + case type_Binary: + out << "\""; out_binary(out, m.get_binary()); out << "\""; break; - default: + case type_Table: + case type_Mixed: TIGHTDB_ASSERT(false); + break; } } break; } - default: - TIGHTDB_ASSERT(false); } } out << "}"; @@ -2158,40 +2128,40 @@ void Table::to_string_header(std::ostream& out, std::vector& widths) con // Write header for (size_t col = 0; col < column_count; ++col) { const char* const name = get_column_name(col); - const ColumnType type = get_column_type(col); + const DataType type = get_column_type(col); size_t width = 0; switch (type) { - case COLUMN_TYPE_BOOL: + case type_Bool: width = 5; break; - case COLUMN_TYPE_DATE: + case type_Date: width = 19; break; - case COLUMN_TYPE_INT: + case type_Int: width = chars_in_int(maximum(col)); break; - case COLUMN_TYPE_FLOAT: + case type_Float: width = 12; // FIXME break; - case COLUMN_TYPE_DOUBLE: + case type_Double: width = 12; // FIXME break; - case COLUMN_TYPE_TABLE: + case type_Table: for (size_t row = 0; row < row_count; ++row) { size_t len = chars_in_int( get_subtable_size(col, row) ); width = max(width, len+2); } width += 2; // space for "[]" break; - case COLUMN_TYPE_BINARY: + case type_Binary: for (size_t row = 0; row < row_count; ++row) { size_t len = chars_in_int( get_binary(col, row).len ) + 2; width = max(width, len); } width += 6; // space for " bytes" break; - case COLUMN_TYPE_STRING: - { // Find max length of the strings + case type_String: { + // Find max length of the strings for (size_t row = 0; row < row_count; ++row) { size_t len = get_string_length(col, row); width = max(width, len); @@ -2199,57 +2169,55 @@ void Table::to_string_header(std::ostream& out, std::vector& widths) con if (width > 20) width = 23; // cut strings longer than 20 chars break; } - case COLUMN_TYPE_MIXED: + case type_Mixed: // Find max length of the mixed values width = 0; for (size_t row = 0; row < row_count; ++row) { - const ColumnType mtype = get_mixed_type(col, row); - if (mtype == COLUMN_TYPE_TABLE) { + const DataType mtype = get_mixed_type(col, row); + if (mtype == type_Table) { size_t len = chars_in_int( get_subtable_size(col, row) ) + 2; width = max(width, len); + continue; } - else { - const Mixed m = get_mixed(col, row); - switch (mtype) { - case COLUMN_TYPE_BOOL: - width = max(width, (size_t)5); - break; - case COLUMN_TYPE_DATE: - width = max(width, (size_t)19); - break; - case COLUMN_TYPE_INT: - width = max(width, chars_in_int(m.get_int())); - break; - case COLUMN_TYPE_FLOAT: - width = max(width, (size_t)12); // FIXME - break; - case COLUMN_TYPE_DOUBLE: - width = max(width, (size_t)12); // FIXME - break; - case COLUMN_TYPE_BINARY: - width = max(width, chars_in_int(m.get_binary().len) + 6); - break; - case COLUMN_TYPE_STRING: - { - size_t len = strlen(m.get_string()); - if (len > 20) len = 23; - width = max(width, len); - break; - } - default: - TIGHTDB_ASSERT(false); + const Mixed m = get_mixed(col, row); + switch (mtype) { + case type_Bool: + width = max(width, size_t(5)); + break; + case type_Date: + width = max(width, size_t(19)); + break; + case type_Int: + width = max(width, chars_in_int(m.get_int())); + break; + case type_Float: + width = max(width, size_t(12)); // FIXME: Implement this + break; + case type_Double: + width = max(width, size_t(12)); // FIXME: Implement this + break; + case type_Binary: + width = max(width, chars_in_int(m.get_binary().len) + 6); + break; + case type_String: { + size_t len = strlen(m.get_string()); + if (len > 20) len = 23; + width = max(width, len); + break; } + case type_Table: + case type_Mixed: + TIGHTDB_ASSERT(false); + break; } } break; - default: - TIGHTDB_ASSERT(false); } // Set width to max of column name and the longest value const size_t name_len = strlen(name); if (name_len > width) width = name_len; - + widths.push_back(width); out << " "; // spacing @@ -2265,7 +2233,7 @@ inline void out_string(std::ostream& out, const std::string text, const size_t m { out.setf(std::ostream::left, std::ostream::adjustfield); if (text.size() > max_len) - out << text.substr(0, max_len) + "..."; + out << text.substr(0, max_len) + "..."; else out << text; out.unsetf(std::ostream::adjustfield); @@ -2292,72 +2260,72 @@ void Table::to_string_row(size_t row_ndx, std::ostream& out, const std::vector& column_path, ColumnType type, const char* name); + size_t add_column(DataType type, const char* name); // Add a column dynamically + size_t add_subcolumn(const vector& column_path, DataType type, const char* name); void remove_column(size_t column_ndx); void remove_column(const vector& column_path); void rename_column(size_t column_ndx, const char* name); @@ -136,7 +136,7 @@ class Table { size_t get_column_count() const TIGHTDB_NOEXCEPT; const char* get_column_name(size_t column_ndx) const TIGHTDB_NOEXCEPT; size_t get_column_index(const char* name) const; - ColumnType get_column_type(size_t column_ndx) const TIGHTDB_NOEXCEPT; + DataType get_column_type(size_t column_ndx) const TIGHTDB_NOEXCEPT; // Row handling size_t add_empty_row(size_t num_rows = 1); @@ -168,7 +168,7 @@ class Table { size_t get_string_length(size_t column_ndx, size_t row_ndx) const TIGHTDB_NOEXCEPT; BinaryData get_binary(size_t column_ndx, size_t row_ndx) const; // FIXME: Should be modified so it never throws Mixed get_mixed(size_t column_ndx, size_t row_ndx) const; // FIXME: Should be modified so it never throws - ColumnType get_mixed_type(size_t column_ndx, size_t row_ndx) const TIGHTDB_NOEXCEPT; + DataType get_mixed_type(size_t column_ndx, size_t row_ndx) const TIGHTDB_NOEXCEPT; // Set cell values void set_int(size_t column_ndx, size_t row_ndx, int64_t value); @@ -200,12 +200,12 @@ class Table { size_t count_string(size_t column_ndx, const char* target) const; size_t count_float(size_t column_ndx, float target) const; size_t count_double(size_t column_ndx, double target) const; - + int64_t sum(size_t column_ndx) const; double sum_float(size_t column_ndx) const; double sum_double(size_t column_ndx) const; // FIXME: What to return for below when table empty? 0? - int64_t maximum(size_t column_ndx) const; + int64_t maximum(size_t column_ndx) const; float maximum_float(size_t column_ndx) const; double maximum_double(size_t column_ndx) const; int64_t minimum(size_t column_ndx) const; @@ -281,9 +281,8 @@ class Table { MemStats stats() const; #endif // TIGHTDB_DEBUG - // todo, note, these three functions have been protected const ColumnBase& GetColumnBase(size_t column_ndx) const TIGHTDB_NOEXCEPT; // FIXME: Move this to private section next to the non-const version - ColumnType GetRealColumnType(size_t column_ndx) const TIGHTDB_NOEXCEPT; + ColumnType get_real_column_type(size_t column_ndx) const TIGHTDB_NOEXCEPT; // FIXME: Used by various node types in class Parent; @@ -345,8 +344,8 @@ class Table { void UpdateFromParent(); void do_remove_column(const vector& column_ids, size_t pos); void do_remove_column(size_t column_ndx); - size_t do_add_column(ColumnType type); - void do_add_subcolumn(const vector& column_path, size_t pos, ColumnType type); + size_t do_add_column(DataType type); + void do_add_subcolumn(const vector& column_path, size_t pos, DataType type); void set_index(size_t column_ndx, bool update_spec); @@ -478,6 +477,34 @@ class Table::Parent: public ArrayParent { // Implementation: +inline std::size_t Table::get_column_count() const TIGHTDB_NOEXCEPT +{ + return m_spec_set.get_column_count(); +} + +inline const char* Table::get_column_name(std::size_t ndx) const TIGHTDB_NOEXCEPT +{ + TIGHTDB_ASSERT(ndx < get_column_count()); + return m_spec_set.get_column_name(ndx); +} + +inline std::size_t Table::get_column_index(const char* name) const +{ + return m_spec_set.get_column_index(name); +} + +inline ColumnType Table::get_real_column_type(std::size_t ndx) const TIGHTDB_NOEXCEPT +{ + TIGHTDB_ASSERT(ndx < get_column_count()); + return m_spec_set.get_real_column_type(ndx); +} + +inline DataType Table::get_column_type(std::size_t ndx) const TIGHTDB_NOEXCEPT +{ + TIGHTDB_ASSERT(ndx < get_column_count()); + return m_spec_set.get_column_type(ndx); +} + template C& Table::GetColumn(size_t ndx) { @@ -634,7 +661,7 @@ struct Table::LocalTransactLog { if (m_repl) m_repl->optimize_table(m_table); // Throws } - void add_column(ColumnType type, const char* name) + void add_column(DataType type, const char* name) { if (m_repl) m_repl->add_column(m_table, &m_table->m_spec_set, type, name); // Throws } diff --git a/src/tightdb/table_accessors.hpp b/src/tightdb/table_accessors.hpp index 0ae5ed62c5c..bd69ea6a02b 100644 --- a/src/tightdb/table_accessors.hpp +++ b/src/tightdb/table_accessors.hpp @@ -624,7 +624,7 @@ class MixedFieldAccessorBase: public FieldAccessorBase { return static_cast(*this); } - ColumnType get_type() const TIGHTDB_NOEXCEPT + DataType get_type() const TIGHTDB_NOEXCEPT { return Base::m_table->get_impl()->get_mixed_type(col_idx, Base::m_row_idx); } @@ -643,7 +643,7 @@ class MixedFieldAccessorBase: public FieldAccessorBase { BinaryData get_binary() const { return get().get_binary(); } // FIXME: Should be modified so it never throws - bool is_subtable() const TIGHTDB_NOEXCEPT { return get_type() == COLUMN_TYPE_TABLE; } + bool is_subtable() const TIGHTDB_NOEXCEPT { return get_type() == type_Table; } /// Checks whether this value is a subtable of the specified type. /// diff --git a/src/tightdb/table_basic.hpp b/src/tightdb/table_basic.hpp index c35773c83bb..3dcfb9cf103 100644 --- a/src/tightdb/table_basic.hpp +++ b/src/tightdb/table_basic.hpp @@ -216,7 +216,7 @@ template class BasicTable: private Table, public Spec::ConvenienceMe /// must have the same columns, and in the same order. Two columns /// are considered equal if, and only if they have the same name /// and the same type. The type is understood as the value encoded - /// by the ColumnType enumeration. This check proceeds recursively + /// by the DataType enumeration. This check proceeds recursively /// for subtable columns. /// /// \tparam T The static table type. It makes no difference @@ -394,31 +394,31 @@ namespace _impl template struct GetColumnTypeId; template<> struct GetColumnTypeId { - static const ColumnType id = COLUMN_TYPE_INT; + static const DataType id = type_Int; }; template<> struct GetColumnTypeId { - static const ColumnType id = COLUMN_TYPE_BOOL; + static const DataType id = type_Bool; }; template<> struct GetColumnTypeId { - static const ColumnType id = COLUMN_TYPE_FLOAT; + static const DataType id = type_Float; }; template<> struct GetColumnTypeId { - static const ColumnType id = COLUMN_TYPE_DOUBLE; + static const DataType id = type_Double; }; template<> struct GetColumnTypeId { - static const ColumnType id = COLUMN_TYPE_STRING; + static const DataType id = type_String; }; template struct GetColumnTypeId > { - static const ColumnType id = COLUMN_TYPE_INT; + static const DataType id = type_Int; }; template<> struct GetColumnTypeId { - static const ColumnType id = COLUMN_TYPE_DATE; + static const DataType id = type_Date; }; template<> struct GetColumnTypeId { - static const ColumnType id = COLUMN_TYPE_BINARY; + static const DataType id = type_Binary; }; template<> struct GetColumnTypeId { - static const ColumnType id = COLUMN_TYPE_MIXED; + static const DataType id = type_Mixed; }; @@ -456,7 +456,7 @@ namespace _impl template struct DiffColType, col_idx> { static bool exec(const Spec* spec, const char* const* col_names) { - if (spec->get_column_type(col_idx) != COLUMN_TYPE_TABLE || + if (spec->get_column_type(col_idx) != type_Table || std::strcmp(col_names[col_idx], spec->get_column_name(col_idx)) != 0) return true; Spec subspec = spec->get_subtable_spec(col_idx); return !Subtab::matches_dynamic_spec(&subspec); diff --git a/src/tightdb/table_view.cpp b/src/tightdb/table_view.cpp index 557694eec74..bf602b7628b 100644 --- a/src/tightdb/table_view.cpp +++ b/src/tightdb/table_view.cpp @@ -18,7 +18,7 @@ size_t TableViewBase::find_first_integer(size_t column_ndx, int64_t value) const size_t TableViewBase::find_first_string(size_t column_ndx, const char* value) const { - TIGHTDB_ASSERT_COLUMN_AND_TYPE(column_ndx, COLUMN_TYPE_STRING); + TIGHTDB_ASSERT_COLUMN_AND_TYPE(column_ndx, type_String); for (size_t i = 0; i < m_refs.Size(); i++) if (strcmp(get_string(column_ndx, i), value) == 0) @@ -143,9 +143,9 @@ double TableViewBase::minimum_double(size_t column_ndx) const void TableViewBase::sort(size_t column, bool Ascending) { TIGHTDB_ASSERT(m_table); - TIGHTDB_ASSERT(m_table->get_column_type(column) == COLUMN_TYPE_INT || - m_table->get_column_type(column) == COLUMN_TYPE_DATE || - m_table->get_column_type(column) == COLUMN_TYPE_BOOL); + TIGHTDB_ASSERT(m_table->get_column_type(column) == type_Int || + m_table->get_column_type(column) == type_Date || + m_table->get_column_type(column) == type_Bool); if (m_refs.Size() == 0) return; @@ -160,20 +160,20 @@ void TableViewBase::sort(size_t column, bool Ascending) // Extract all values from the Column and put them in an Array because Array is much faster to operate on // with rand access (we have ~log(n) accesses to each element, so using 1 additional read to speed up the rest is faster) - if (m_table->get_column_type(column) == COLUMN_TYPE_INT) { + if (m_table->get_column_type(column) == type_Int) { for (size_t t = 0; t < m_refs.Size(); t++) { const int64_t v = m_table->get_int(column, size_t(m_refs.Get(t))); vals.add(v); } } - else if (m_table->get_column_type(column) == COLUMN_TYPE_DATE) { + else if (m_table->get_column_type(column) == type_Date) { for (size_t t = 0; t < m_refs.Size(); t++) { const size_t idx = size_t(m_refs.Get(t)); const int64_t v = int64_t(m_table->get_date(column, idx)); vals.add(v); } } - else if (m_table->get_column_type(column) == COLUMN_TYPE_BOOL) { + else if (m_table->get_column_type(column) == type_Bool) { for (size_t t = 0; t < m_refs.Size(); t++) { const size_t idx = size_t(m_refs.Get(t)); const int64_t v = int64_t(m_table->get_bool(column, idx)); diff --git a/src/tightdb/table_view.hpp b/src/tightdb/table_view.hpp index 6a35fc6fd87..0c5c2152fd7 100644 --- a/src/tightdb/table_view.hpp +++ b/src/tightdb/table_view.hpp @@ -43,7 +43,7 @@ class TableViewBase { size_t get_column_count() const TIGHTDB_NOEXCEPT; const char* get_column_name(size_t column_ndx) const TIGHTDB_NOEXCEPT; size_t get_column_index(const char* name) const; - ColumnType get_column_type(size_t column_ndx) const TIGHTDB_NOEXCEPT; + DataType get_column_type(size_t column_ndx) const TIGHTDB_NOEXCEPT; // Getting values int64_t get_int(size_t column_ndx, size_t row_ndx) const TIGHTDB_NOEXCEPT; @@ -54,7 +54,7 @@ class TableViewBase { const char* get_string(size_t column_ndx, size_t row_ndx) const TIGHTDB_NOEXCEPT; BinaryData get_binary(size_t column_ndx, size_t row_ndx) const; // FIXME: Should be modified so it never throws Mixed get_mixed(size_t column_ndx, size_t row_ndx) const; // FIXME: Should be modified so it never throws - ColumnType get_mixed_type(size_t column_ndx, size_t row_ndx) const TIGHTDB_NOEXCEPT; + DataType get_mixed_type(size_t column_ndx, size_t row_ndx) const TIGHTDB_NOEXCEPT; // Subtables size_t get_subtable_size(size_t column_ndx, size_t row_ndx) const TIGHTDB_NOEXCEPT; @@ -348,7 +348,7 @@ inline size_t TableViewBase::get_column_index(const char* name) const return m_table->get_column_index(name); } -inline ColumnType TableViewBase::get_column_type(size_t column_ndx) const TIGHTDB_NOEXCEPT +inline DataType TableViewBase::get_column_type(size_t column_ndx) const TIGHTDB_NOEXCEPT { TIGHTDB_ASSERT(m_table); return m_table->get_column_type(column_ndx); @@ -368,7 +368,7 @@ inline int64_t TableViewBase::get_int(size_t column_ndx, size_t row_ndx) const T inline bool TableViewBase::get_bool(size_t column_ndx, size_t row_ndx) const TIGHTDB_NOEXCEPT { - TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, COLUMN_TYPE_BOOL); + TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, type_Bool); const size_t real_ndx = size_t(m_refs.Get(row_ndx)); return m_table->get_bool(column_ndx, real_ndx); @@ -376,7 +376,7 @@ inline bool TableViewBase::get_bool(size_t column_ndx, size_t row_ndx) const TIG inline time_t TableViewBase::get_date(size_t column_ndx, size_t row_ndx) const TIGHTDB_NOEXCEPT { - TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, COLUMN_TYPE_DATE); + TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, type_Date); const size_t real_ndx = size_t(m_refs.Get(row_ndx)); return m_table->get_date(column_ndx, real_ndx); @@ -384,7 +384,7 @@ inline time_t TableViewBase::get_date(size_t column_ndx, size_t row_ndx) const T inline float TableViewBase::get_float(size_t column_ndx, size_t row_ndx) const { - TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, COLUMN_TYPE_FLOAT); + TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, type_Float); const size_t real_ndx = size_t(m_refs.Get(row_ndx)); return m_table->get_float(column_ndx, real_ndx); @@ -392,15 +392,16 @@ inline float TableViewBase::get_float(size_t column_ndx, size_t row_ndx) const inline double TableViewBase::get_double(size_t column_ndx, size_t row_ndx) const { - TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, COLUMN_TYPE_DOUBLE); + TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, type_Double); const size_t real_ndx = size_t(m_refs.Get(row_ndx)); return m_table->get_double(column_ndx, real_ndx); } -inline const char* TableViewBase::get_string(size_t column_ndx, size_t row_ndx) const TIGHTDB_NOEXCEPT +inline const char* TableViewBase::get_string(size_t column_ndx, size_t row_ndx) const + TIGHTDB_NOEXCEPT { - TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, COLUMN_TYPE_STRING); + TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, type_String); const size_t real_ndx = size_t(m_refs.Get(row_ndx)); return m_table->get_string(column_ndx, real_ndx); @@ -408,7 +409,7 @@ inline const char* TableViewBase::get_string(size_t column_ndx, size_t row_ndx) inline BinaryData TableViewBase::get_binary(size_t column_ndx, size_t row_ndx) const { - TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, COLUMN_TYPE_BINARY); + TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, type_Binary); const size_t real_ndx = size_t(m_refs.Get(row_ndx)); return m_table->get_binary(column_ndx, real_ndx); // Throws @@ -416,23 +417,25 @@ inline BinaryData TableViewBase::get_binary(size_t column_ndx, size_t row_ndx) c inline Mixed TableViewBase::get_mixed(size_t column_ndx, size_t row_ndx) const { - TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, COLUMN_TYPE_MIXED); + TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, type_Mixed); const size_t real_ndx = size_t(m_refs.Get(row_ndx)); return m_table->get_mixed(column_ndx, real_ndx); // Throws } -inline ColumnType TableViewBase::get_mixed_type(size_t column_ndx, size_t row_ndx) const TIGHTDB_NOEXCEPT +inline DataType TableViewBase::get_mixed_type(size_t column_ndx, size_t row_ndx) const + TIGHTDB_NOEXCEPT { - TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, COLUMN_TYPE_MIXED); + TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, type_Mixed); const size_t real_ndx = size_t(m_refs.Get(row_ndx)); return m_table->get_mixed_type(column_ndx, real_ndx); } -inline size_t TableViewBase::get_subtable_size(size_t column_ndx, size_t row_ndx) const TIGHTDB_NOEXCEPT +inline size_t TableViewBase::get_subtable_size(size_t column_ndx, size_t row_ndx) const + TIGHTDB_NOEXCEPT { - TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, COLUMN_TYPE_TABLE); + TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, type_Table); const size_t real_ndx = size_t(m_refs.Get(row_ndx)); return m_table->get_subtable_size(column_ndx, real_ndx); @@ -444,19 +447,19 @@ inline size_t TableViewBase::get_subtable_size(size_t column_ndx, size_t row_ndx inline size_t TableViewBase::find_first_int(size_t column_ndx, int64_t value) const { - TIGHTDB_ASSERT_COLUMN_AND_TYPE(column_ndx, COLUMN_TYPE_INT); + TIGHTDB_ASSERT_COLUMN_AND_TYPE(column_ndx, type_Int); return find_first_integer(column_ndx, value); } inline size_t TableViewBase::find_first_bool(size_t column_ndx, bool value) const { - TIGHTDB_ASSERT_COLUMN_AND_TYPE(column_ndx, COLUMN_TYPE_BOOL); + TIGHTDB_ASSERT_COLUMN_AND_TYPE(column_ndx, type_Bool); return find_first_integer(column_ndx, value ? 1 : 0); } inline size_t TableViewBase::find_first_date(size_t column_ndx, time_t value) const { - TIGHTDB_ASSERT_COLUMN_AND_TYPE(column_ndx, COLUMN_TYPE_DATE); + TIGHTDB_ASSERT_COLUMN_AND_TYPE(column_ndx, type_Date); return find_first_integer(column_ndx, (int64_t)value); } @@ -496,7 +499,7 @@ R TableViewBase::find_all_string(V* view, size_t column_ndx, const char* value) { TIGHTDB_ASSERT(view->m_table); TIGHTDB_ASSERT(column_ndx < view->m_table->get_column_count()); - TIGHTDB_ASSERT(view->m_table->get_column_type(column_ndx) == COLUMN_TYPE_STRING); + TIGHTDB_ASSERT(view->m_table->get_column_type(column_ndx) == type_String); R tv(*view->m_table); for (size_t i = 0; i < view->m_refs.Size(); i++) @@ -579,57 +582,57 @@ inline ConstTableView ConstTableView::find_all_integer(size_t column_ndx, int64_ inline TableView TableView::find_all_int(size_t column_ndx, int64_t value) { - TIGHTDB_ASSERT_COLUMN_AND_TYPE(column_ndx, COLUMN_TYPE_INT); + TIGHTDB_ASSERT_COLUMN_AND_TYPE(column_ndx, type_Int); return find_all_integer(column_ndx, value); } inline TableView TableView::find_all_bool(size_t column_ndx, bool value) { - TIGHTDB_ASSERT_COLUMN_AND_TYPE(column_ndx, COLUMN_TYPE_BOOL); + TIGHTDB_ASSERT_COLUMN_AND_TYPE(column_ndx, type_Bool); return find_all_integer(column_ndx, value ? 1 : 0); } inline TableView TableView::find_all_date(size_t column_ndx, time_t value) { - TIGHTDB_ASSERT_COLUMN_AND_TYPE(column_ndx, COLUMN_TYPE_DATE); + TIGHTDB_ASSERT_COLUMN_AND_TYPE(column_ndx, type_Date); return find_all_integer(column_ndx, (int64_t)value); } inline ConstTableView TableView::find_all_int(size_t column_ndx, int64_t value) const { - TIGHTDB_ASSERT_COLUMN_AND_TYPE(column_ndx, COLUMN_TYPE_INT); + TIGHTDB_ASSERT_COLUMN_AND_TYPE(column_ndx, type_Int); return find_all_integer(column_ndx, value); } inline ConstTableView TableView::find_all_bool(size_t column_ndx, bool value) const { - TIGHTDB_ASSERT_COLUMN_AND_TYPE(column_ndx, COLUMN_TYPE_BOOL); + TIGHTDB_ASSERT_COLUMN_AND_TYPE(column_ndx, type_Bool); return find_all_integer(column_ndx, value ? 1 : 0); } inline ConstTableView TableView::find_all_date(size_t column_ndx, time_t value) const { - TIGHTDB_ASSERT_COLUMN_AND_TYPE(column_ndx, COLUMN_TYPE_DATE); + TIGHTDB_ASSERT_COLUMN_AND_TYPE(column_ndx, type_Date); return find_all_integer(column_ndx, (int64_t)value); } inline ConstTableView ConstTableView::find_all_int(size_t column_ndx, int64_t value) const { - TIGHTDB_ASSERT_COLUMN_AND_TYPE(column_ndx, COLUMN_TYPE_INT); + TIGHTDB_ASSERT_COLUMN_AND_TYPE(column_ndx, type_Int); return find_all_integer(column_ndx, value); } inline ConstTableView ConstTableView::find_all_bool(size_t column_ndx, bool value) const { - TIGHTDB_ASSERT_COLUMN_AND_TYPE(column_ndx, COLUMN_TYPE_BOOL); + TIGHTDB_ASSERT_COLUMN_AND_TYPE(column_ndx, type_Bool); return find_all_integer(column_ndx, value ? 1 : 0); } inline ConstTableView ConstTableView::find_all_date(size_t column_ndx, time_t value) const { - TIGHTDB_ASSERT_COLUMN_AND_TYPE(column_ndx, COLUMN_TYPE_DATE); + TIGHTDB_ASSERT_COLUMN_AND_TYPE(column_ndx, type_Date); return find_all_integer(column_ndx, (int64_t)value); } @@ -639,7 +642,7 @@ inline ConstTableView ConstTableView::find_all_date(size_t column_ndx, time_t va inline TableRef TableView::get_subtable(size_t column_ndx, size_t row_ndx) { - TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, COLUMN_TYPE_TABLE); + TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, type_Table); const size_t real_ndx = size_t(m_refs.Get(row_ndx)); return m_table->get_subtable(column_ndx, real_ndx); @@ -647,7 +650,7 @@ inline TableRef TableView::get_subtable(size_t column_ndx, size_t row_ndx) inline ConstTableRef TableView::get_subtable(size_t column_ndx, size_t row_ndx) const { - TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, COLUMN_TYPE_TABLE); + TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, type_Table); const size_t real_ndx = size_t(m_refs.Get(row_ndx)); return m_table->get_subtable(column_ndx, real_ndx); @@ -655,7 +658,7 @@ inline ConstTableRef TableView::get_subtable(size_t column_ndx, size_t row_ndx) inline ConstTableRef ConstTableView::get_subtable(size_t column_ndx, size_t row_ndx) const { - TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, COLUMN_TYPE_TABLE); + TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, type_Table); const size_t real_ndx = size_t(m_refs.Get(row_ndx)); return m_table->get_subtable(column_ndx, real_ndx); @@ -663,7 +666,7 @@ inline ConstTableRef ConstTableView::get_subtable(size_t column_ndx, size_t row_ inline void TableView::clear_subtable(size_t column_ndx, size_t row_ndx) { - TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, COLUMN_TYPE_TABLE); + TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, type_Table); const size_t real_ndx = size_t(m_refs.Get(row_ndx)); return m_table->clear_subtable(column_ndx, real_ndx); @@ -675,7 +678,7 @@ inline void TableView::clear_subtable(size_t column_ndx, size_t row_ndx) inline void TableView::set_int(size_t column_ndx, size_t row_ndx, int64_t value) { - TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, COLUMN_TYPE_INT); + TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, type_Int); const size_t real_ndx = size_t(m_refs.Get(row_ndx)); m_table->set_int(column_ndx, real_ndx, value); @@ -683,7 +686,7 @@ inline void TableView::set_int(size_t column_ndx, size_t row_ndx, int64_t value) inline void TableView::set_bool(size_t column_ndx, size_t row_ndx, bool value) { - TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, COLUMN_TYPE_BOOL); + TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, type_Bool); const size_t real_ndx = size_t(m_refs.Get(row_ndx)); m_table->set_bool(column_ndx, real_ndx, value); @@ -691,7 +694,7 @@ inline void TableView::set_bool(size_t column_ndx, size_t row_ndx, bool value) inline void TableView::set_date(size_t column_ndx, size_t row_ndx, time_t value) { - TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, COLUMN_TYPE_DATE); + TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, type_Date); const size_t real_ndx = size_t(m_refs.Get(row_ndx)); m_table->set_date(column_ndx, real_ndx, value); @@ -699,7 +702,7 @@ inline void TableView::set_date(size_t column_ndx, size_t row_ndx, time_t value) inline void TableView::set_float(size_t column_ndx, size_t row_ndx, float value) { - TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, COLUMN_TYPE_FLOAT); + TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, type_Float); const size_t real_ndx = size_t(m_refs.Get(row_ndx)); m_table->set_float(column_ndx, real_ndx, value); @@ -707,7 +710,7 @@ inline void TableView::set_float(size_t column_ndx, size_t row_ndx, float value) inline void TableView::set_double(size_t column_ndx, size_t row_ndx, double value) { - TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, COLUMN_TYPE_DOUBLE); + TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, type_Double); const size_t real_ndx = size_t(m_refs.Get(row_ndx)); m_table->set_double(column_ndx, real_ndx, value); @@ -721,7 +724,7 @@ template inline void TableView::set_enum(size_t column_ndx, size_t row_ inline void TableView::set_string(size_t column_ndx, size_t row_ndx, const char* value) { - TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, COLUMN_TYPE_STRING); + TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, type_String); const size_t real_ndx = size_t(m_refs.Get(row_ndx)); m_table->set_string(column_ndx, real_ndx, value); @@ -729,7 +732,7 @@ inline void TableView::set_string(size_t column_ndx, size_t row_ndx, const char* inline void TableView::set_binary(size_t column_ndx, size_t row_ndx, const char* value, size_t len) { - TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, COLUMN_TYPE_BINARY); + TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, type_Binary); const size_t real_ndx = size_t(m_refs.Get(row_ndx)); m_table->set_binary(column_ndx, real_ndx, value, len); @@ -737,7 +740,7 @@ inline void TableView::set_binary(size_t column_ndx, size_t row_ndx, const char* inline void TableView::set_mixed(size_t column_ndx, size_t row_ndx, Mixed value) { - TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, COLUMN_TYPE_MIXED); + TIGHTDB_ASSERT_INDEX_AND_TYPE(column_ndx, row_ndx, type_Mixed); const size_t real_ndx = size_t(m_refs.Get(row_ndx)); m_table->set_mixed(column_ndx, real_ndx, value); diff --git a/test/TestQuery.cpp b/test/TestQuery.cpp index e2797f846cd..f7ceedce967 100644 --- a/test/TestQuery.cpp +++ b/test/TestQuery.cpp @@ -617,11 +617,11 @@ TEST(TestQuerySubtable) // Create specification with sub-table Spec& s = table->get_spec(); - s.add_column(COLUMN_TYPE_INT, "first"); - s.add_column(COLUMN_TYPE_STRING, "second"); + s.add_column(type_Int, "first"); + s.add_column(type_String, "second"); Spec sub = s.add_subtable_column("third"); - sub.add_column(COLUMN_TYPE_INT, "sub_first"); - sub.add_column(COLUMN_TYPE_STRING, "sub_second"); + sub.add_column(type_Int, "sub_first"); + sub.add_column(type_String, "sub_second"); table->update_from_spec(); CHECK_EQUAL(3, table->get_column_count()); @@ -826,7 +826,7 @@ TEST(TestQuerySort_Descending) TEST(TestQuerySort_Dates) { Table table; - table.add_column(COLUMN_TYPE_DATE, "first"); + table.add_column(type_Date, "first"); table.insert_date(0, 0, 1000); table.insert_done(); @@ -853,7 +853,7 @@ TEST(TestQuerySort_Dates) TEST(TestQuerySort_Bools) { Table table; - table.add_column(COLUMN_TYPE_BOOL, "first"); + table.add_column(type_Bool, "first"); table.insert_bool(0, 0, true); table.insert_done(); diff --git a/test/experiments/float.cpp b/test/experiments/float.cpp index 2ff30620904..5bff0413525 100644 --- a/test/experiments/float.cpp +++ b/test/experiments/float.cpp @@ -33,4 +33,4 @@ void exploreFloat() num.f, num.i, num.parts.sign, num.parts.exponent, num.parts.mantissa); } -} \ No newline at end of file +} diff --git a/test/pthread_test.hpp b/test/pthread_test.hpp index 8bcb6e20fa7..ca89e7f7feb 100644 --- a/test/pthread_test.hpp +++ b/test/pthread_test.hpp @@ -85,4 +85,4 @@ int ptf_pthread_barrier_wait(pthread_barrier_t *barrier) #define pthread_mutex_trylock ptf_pthread_mutex_trylock #define pthread_barrier_wait ptf_pthread_barrier_wait -#endif \ No newline at end of file +#endif diff --git a/test/testcolumnmixed.cpp b/test/testcolumnmixed.cpp index 877eb762149..762927aa70b 100644 --- a/test/testcolumnmixed.cpp +++ b/test/testcolumnmixed.cpp @@ -19,7 +19,7 @@ TEST(ColumnMixed_Int) CHECK_EQUAL(4, c.Size()); for (size_t i = 0; i < c.Size(); ++i) { - CHECK_EQUAL(COLUMN_TYPE_INT, c.GetType(i)); + CHECK_EQUAL(type_Int, c.get_type(i)); } CHECK_EQUAL( 2, c.get_int(0)); @@ -33,7 +33,7 @@ TEST(ColumnMixed_Int) c.set_int(3, 1); for (size_t i = 0; i < c.Size(); ++i) { - CHECK_EQUAL(COLUMN_TYPE_INT, c.GetType(i)); + CHECK_EQUAL(type_Int, c.get_type(i)); } CHECK_EQUAL( 400, c.get_int(0)); @@ -54,14 +54,14 @@ TEST(ColumnMixed_Float) const float f = static_cast(v); float fval1[] = {0.0f, 100.123f, -111.222f, f}; float fval2[] = {-0.0f, -100.123f, std::numeric_limits::max(), std::numeric_limits::min()}; - + // Test insert for (size_t i=0; i<4; ++i) c.insert_float(i, fval1[i]); CHECK_EQUAL(4, c.Size()); for (size_t i = 0; i < c.Size(); ++i) { - CHECK_EQUAL(COLUMN_TYPE_FLOAT, c.GetType(i)); + CHECK_EQUAL(type_Float, c.get_type(i)); CHECK_EQUAL( fval1[i], c.get_float(i)); } @@ -70,7 +70,7 @@ TEST(ColumnMixed_Float) c.set_float(i, fval2[i]); for (size_t i = 0; i < c.Size(); ++i) { - CHECK_EQUAL(COLUMN_TYPE_FLOAT, c.GetType(i)); + CHECK_EQUAL(type_Float, c.get_type(i)); CHECK_EQUAL( fval2[i], c.get_float(i)); } CHECK_EQUAL(4, c.Size()); @@ -87,7 +87,7 @@ TEST(ColumnMixed_Double) const double d = static_cast(v); double fval1[] = {1.0, 200.123, -111.222, d}; double fval2[] = {-1.0, -100.123, std::numeric_limits::max(), std::numeric_limits::min()}; - + // Test insert for (size_t i=0; i<4; ++i) { c.insert_double(i, fval1[i]); @@ -95,7 +95,7 @@ TEST(ColumnMixed_Double) CHECK_EQUAL(4, c.Size()); for (size_t i = 0; i < c.Size(); ++i) { - CHECK_EQUAL(COLUMN_TYPE_DOUBLE, c.GetType(i)); + CHECK_EQUAL(type_Double, c.get_type(i)); double v = c.get_double(i); CHECK_EQUAL( fval1[i], v); } @@ -106,7 +106,7 @@ TEST(ColumnMixed_Double) CHECK_EQUAL(4, c.Size()); for (size_t i = 0; i < c.Size(); ++i) { - CHECK_EQUAL(COLUMN_TYPE_DOUBLE, c.GetType(i)); + CHECK_EQUAL(type_Double, c.get_type(i)); CHECK_EQUAL( fval2[i], c.get_double(i)); } @@ -123,7 +123,7 @@ TEST(ColumnMixed_Bool) CHECK_EQUAL(3, c.Size()); for (size_t i = 0; i < c.Size(); ++i) { - CHECK_EQUAL(COLUMN_TYPE_BOOL, c.GetType(i)); + CHECK_EQUAL(type_Bool, c.get_type(i)); } CHECK_EQUAL(true, c.get_bool(0)); @@ -136,7 +136,7 @@ TEST(ColumnMixed_Bool) CHECK_EQUAL(3, c.Size()); for (size_t i = 0; i < c.Size(); ++i) { - CHECK_EQUAL(COLUMN_TYPE_BOOL, c.GetType(i)); + CHECK_EQUAL(type_Bool, c.get_type(i)); } CHECK_EQUAL(false, c.get_bool(0)); @@ -156,7 +156,7 @@ TEST(ColumnMixed_Date) CHECK_EQUAL(3, c.Size()); for (size_t i = 0; i < c.Size(); ++i) { - CHECK_EQUAL(COLUMN_TYPE_DATE, c.GetType(i)); + CHECK_EQUAL(type_Date, c.get_type(i)); } CHECK_EQUAL( 2, c.get_date(0)); @@ -168,7 +168,7 @@ TEST(ColumnMixed_Date) c.set_date(2, 99999); for (size_t i = 0; i < c.Size(); ++i) { - CHECK_EQUAL(COLUMN_TYPE_DATE, c.GetType(i)); + CHECK_EQUAL(type_Date, c.get_type(i)); } CHECK_EQUAL( 400, c.get_date(0)); @@ -189,7 +189,7 @@ TEST(ColumnMixed_String) CHECK_EQUAL(3, c.Size()); for (size_t i = 0; i < c.Size(); ++i) { - CHECK_EQUAL(COLUMN_TYPE_STRING, c.GetType(i)); + CHECK_EQUAL(type_String, c.get_type(i)); } CHECK_EQUAL("aaa", c.get_string(0)); @@ -202,7 +202,7 @@ TEST(ColumnMixed_String) CHECK_EQUAL(3, c.Size()); for (size_t i = 0; i < c.Size(); ++i) { - CHECK_EQUAL(COLUMN_TYPE_STRING, c.GetType(i)); + CHECK_EQUAL(type_String, c.get_type(i)); } CHECK_EQUAL("dd", c.get_string(0)); @@ -222,7 +222,7 @@ TEST(ColumnMixed_Binary) CHECK_EQUAL(3, c.Size()); for (size_t i = 0; i < c.Size(); ++i) { - CHECK_EQUAL(COLUMN_TYPE_BINARY, c.GetType(i)); + CHECK_EQUAL(type_Binary, c.get_type(i)); } CHECK_EQUAL("aaa", (const char*)c.get_binary(0).pointer); @@ -235,7 +235,7 @@ TEST(ColumnMixed_Binary) CHECK_EQUAL(3, c.Size()); for (size_t i = 0; i < c.Size(); ++i) { - CHECK_EQUAL(COLUMN_TYPE_BINARY, c.GetType(i)); + CHECK_EQUAL(type_Binary, c.get_type(i)); } CHECK_EQUAL("dd", (const char*)c.get_binary(0).pointer); @@ -254,7 +254,7 @@ TEST(ColumnMixed_Table) CHECK_EQUAL(2, c.Size()); for (size_t i = 0; i < c.Size(); ++i) { - CHECK_EQUAL(COLUMN_TYPE_TABLE, c.GetType(i)); + CHECK_EQUAL(type_Table, c.get_type(i)); } Table* const t1 = c.get_subtable_ptr(0); @@ -282,14 +282,14 @@ TEST(ColumnMixed_Mixed) c.insert_double(0, 1234.124); CHECK_EQUAL(8, c.Size()); - CHECK_EQUAL(COLUMN_TYPE_DOUBLE, c.GetType(0)); - CHECK_EQUAL(COLUMN_TYPE_FLOAT, c.GetType(1)); - CHECK_EQUAL(COLUMN_TYPE_TABLE, c.GetType(2)); - CHECK_EQUAL(COLUMN_TYPE_BINARY, c.GetType(3)); - CHECK_EQUAL(COLUMN_TYPE_STRING, c.GetType(4)); - CHECK_EQUAL(COLUMN_TYPE_DATE, c.GetType(5)); - CHECK_EQUAL(COLUMN_TYPE_BOOL, c.GetType(6)); - CHECK_EQUAL(COLUMN_TYPE_INT, c.GetType(7)); + CHECK_EQUAL(type_Double, c.get_type(0)); + CHECK_EQUAL(type_Float, c.get_type(1)); + CHECK_EQUAL(type_Table, c.get_type(2)); + CHECK_EQUAL(type_Binary, c.get_type(3)); + CHECK_EQUAL(type_String, c.get_type(4)); + CHECK_EQUAL(type_Date, c.get_type(5)); + CHECK_EQUAL(type_Bool, c.get_type(6)); + CHECK_EQUAL(type_Int, c.get_type(7)); // Change all entries to new types c.set_int(0, 23); @@ -302,14 +302,14 @@ TEST(ColumnMixed_Mixed) c.set_double(7, 1234.124); CHECK_EQUAL(8, c.Size()); - CHECK_EQUAL(COLUMN_TYPE_DOUBLE, c.GetType(7)); - CHECK_EQUAL(COLUMN_TYPE_FLOAT, c.GetType(6)); - CHECK_EQUAL(COLUMN_TYPE_TABLE, c.GetType(5)); - CHECK_EQUAL(COLUMN_TYPE_BINARY, c.GetType(4)); - CHECK_EQUAL(COLUMN_TYPE_STRING, c.GetType(3)); - CHECK_EQUAL(COLUMN_TYPE_DATE, c.GetType(2)); - CHECK_EQUAL(COLUMN_TYPE_BOOL, c.GetType(1)); - CHECK_EQUAL(COLUMN_TYPE_INT, c.GetType(0)); + CHECK_EQUAL(type_Double, c.get_type(7)); + CHECK_EQUAL(type_Float, c.get_type(6)); + CHECK_EQUAL(type_Table, c.get_type(5)); + CHECK_EQUAL(type_Binary, c.get_type(4)); + CHECK_EQUAL(type_String, c.get_type(3)); + CHECK_EQUAL(type_Date, c.get_type(2)); + CHECK_EQUAL(type_Bool, c.get_type(1)); + CHECK_EQUAL(type_Int, c.get_type(0)); c.Destroy(); } diff --git a/test/testgroup.cpp b/test/testgroup.cpp index 824653c5c59..5ac9135397f 100644 --- a/test/testgroup.cpp +++ b/test/testgroup.cpp @@ -321,12 +321,12 @@ TEST(Group_Serialize_All) Group toMem; TableRef table = toMem.get_table("test"); - table->add_column(COLUMN_TYPE_INT, "int"); - table->add_column(COLUMN_TYPE_BOOL, "bool"); - table->add_column(COLUMN_TYPE_DATE, "date"); - table->add_column(COLUMN_TYPE_STRING, "string"); - table->add_column(COLUMN_TYPE_BINARY, "binary"); - table->add_column(COLUMN_TYPE_MIXED, "mixed"); + table->add_column(type_Int, "int"); + table->add_column(type_Bool, "bool"); + table->add_column(type_Date, "date"); + table->add_column(type_String, "string"); + table->add_column(type_Binary, "binary"); + table->add_column(type_Mixed, "mixed"); table->insert_int(0, 0, 12); table->insert_bool(1, 0, true); @@ -351,7 +351,7 @@ TEST(Group_Serialize_All) CHECK_EQUAL("test", t->get_string(3, 0)); CHECK_EQUAL(7, t->get_binary(4, 0).len); CHECK_EQUAL("binary", (const char*)t->get_binary(4, 0).pointer); - CHECK_EQUAL(COLUMN_TYPE_BOOL, t->get_mixed(5, 0).get_type()); + CHECK_EQUAL(type_Bool, t->get_mixed(5, 0).get_type()); CHECK_EQUAL(false, t->get_mixed(5, 0).get_bool()); } @@ -365,12 +365,12 @@ TEST(Group_Persist) // Insert some data TableRef table = db.get_table("test"); - table->add_column(COLUMN_TYPE_INT, "int"); - table->add_column(COLUMN_TYPE_BOOL, "bool"); - table->add_column(COLUMN_TYPE_DATE, "date"); - table->add_column(COLUMN_TYPE_STRING, "string"); - table->add_column(COLUMN_TYPE_BINARY, "binary"); - table->add_column(COLUMN_TYPE_MIXED, "mixed"); + table->add_column(type_Int, "int"); + table->add_column(type_Bool, "bool"); + table->add_column(type_Date, "date"); + table->add_column(type_String, "string"); + table->add_column(type_Binary, "binary"); + table->add_column(type_Mixed, "mixed"); table->insert_int(0, 0, 12); table->insert_bool(1, 0, true); table->insert_date(2, 0, 12345); @@ -394,7 +394,7 @@ TEST(Group_Persist) CHECK_EQUAL("test", table->get_string(3, 0)); CHECK_EQUAL(7, table->get_binary(4, 0).len); CHECK_EQUAL("binary", (const char*)table->get_binary(4, 0).pointer); - CHECK_EQUAL(COLUMN_TYPE_BOOL, table->get_mixed(5, 0).get_type()); + CHECK_EQUAL(type_Bool, table->get_mixed(5, 0).get_type()); CHECK_EQUAL(false, table->get_mixed(5, 0).get_bool()); // Change a bit @@ -415,7 +415,7 @@ TEST(Group_Persist) CHECK_EQUAL("Changed!", table->get_string(3, 0)); CHECK_EQUAL(7, table->get_binary(4, 0).len); CHECK_EQUAL("binary", (const char*)table->get_binary(4, 0).pointer); - CHECK_EQUAL(COLUMN_TYPE_BOOL, table->get_mixed(5, 0).get_type()); + CHECK_EQUAL(type_Bool, table->get_mixed(5, 0).get_type()); CHECK_EQUAL(false, table->get_mixed(5, 0).get_bool()); } @@ -426,10 +426,10 @@ TEST(Group_Subtable) Group g; TableRef table = g.get_table("test"); Spec& s = table->get_spec(); - s.add_column(COLUMN_TYPE_INT, "foo"); + s.add_column(type_Int, "foo"); Spec sub = s.add_subtable_column("sub"); - sub.add_column(COLUMN_TYPE_INT, "bar"); - s.add_column(COLUMN_TYPE_MIXED, "baz"); + sub.add_column(type_Int, "bar"); + s.add_column(type_Mixed, "baz"); table->update_from_spec(); for (int i=0; iset_mixed(2, i, Mixed::subtable_tag()); TableRef st = table->get_subtable(2, i); - st->add_column(COLUMN_TYPE_INT, "banach"); + st->add_column(type_Int, "banach"); st->add_empty_row(); st->set_int(0, 0, 700+i); } @@ -462,7 +462,7 @@ TEST(Group_Subtable) st->set_int(0, st->size()-1, 300+i); } } - CHECK_EQUAL(table->get_mixed_type(2,i), i%3 == 1 ? COLUMN_TYPE_TABLE : COLUMN_TYPE_INT); + CHECK_EQUAL(table->get_mixed_type(2,i), i%3 == 1 ? type_Table : type_Int); if (i%3 == 1) { TableRef st = table->get_subtable(2, i); CHECK_EQUAL(st->size(), 1); @@ -471,7 +471,7 @@ TEST(Group_Subtable) if (i%8 == 3) { if (i%3 != 1) table->set_mixed(2, i, Mixed::subtable_tag()); TableRef st = table->get_subtable(2, i); - if (i%3 != 1) st->add_column(COLUMN_TYPE_INT, "banach"); + if (i%3 != 1) st->add_column(type_Int, "banach"); st->add_empty_row(); st->set_int(0, st->size()-1, 800+i); } @@ -493,7 +493,7 @@ TEST(Group_Subtable) ++idx; } } - CHECK_EQUAL(table->get_mixed_type(2,i), i%3 == 1 || i%8 == 3 ? COLUMN_TYPE_TABLE : COLUMN_TYPE_INT); + CHECK_EQUAL(table->get_mixed_type(2,i), i%3 == 1 || i%8 == 3 ? type_Table : type_Int); if (i%3 == 1 || i%8 == 3) { TableRef st = table->get_subtable(2, i); size_t expected_size = (i%3 == 1 ? 1 : 0) + (i%8 == 3 ? 1 : 0); @@ -536,7 +536,7 @@ TEST(Group_Subtable) st->set_int(0, st->size()-1, 400+i); } } - CHECK_EQUAL(table2->get_mixed_type(2,i), i%3 == 1 || i%8 == 3 ? COLUMN_TYPE_TABLE : COLUMN_TYPE_INT); + CHECK_EQUAL(table2->get_mixed_type(2,i), i%3 == 1 || i%8 == 3 ? type_Table : type_Int); if (i%3 == 1 || i%8 == 3) { TableRef st = table2->get_subtable(2, i); size_t expected_size = (i%3 == 1 ? 1 : 0) + (i%8 == 3 ? 1 : 0); @@ -554,7 +554,7 @@ TEST(Group_Subtable) if (i%7 == 4) { if (i%3 != 1 && i%8 != 3) table2->set_mixed(2, i, Mixed::subtable_tag()); TableRef st = table2->get_subtable(2, i); - if (i%3 != 1 && i%8 != 3) st->add_column(COLUMN_TYPE_INT, "banach"); + if (i%3 != 1 && i%8 != 3) st->add_column(type_Int, "banach"); st->add_empty_row(); st->set_int(0, st->size()-1, 900+i); } @@ -580,7 +580,7 @@ TEST(Group_Subtable) ++idx; } } - CHECK_EQUAL(table2->get_mixed_type(2,i), i%3 == 1 || i%8 == 3 || i%7 == 4 ? COLUMN_TYPE_TABLE : COLUMN_TYPE_INT); + CHECK_EQUAL(table2->get_mixed_type(2,i), i%3 == 1 || i%8 == 3 || i%7 == 4 ? type_Table : type_Int); if (i%3 == 1 || i%8 == 3 || i%7 == 4) { TableRef st = table2->get_subtable(2, i); size_t expected_size = (i%3 == 1 ? 1 : 0) + (i%8 == 3 ? 1 : 0) + (i%7 == 4 ? 1 : 0); @@ -627,7 +627,7 @@ TEST(Group_Subtable) ++idx; } } - CHECK_EQUAL(table3->get_mixed_type(2,i), i%3 == 1 || i%8 == 3 || i%7 == 4 ? COLUMN_TYPE_TABLE : COLUMN_TYPE_INT); + CHECK_EQUAL(table3->get_mixed_type(2,i), i%3 == 1 || i%8 == 3 || i%7 == 4 ? type_Table : type_Int); if (i%3 == 1 || i%8 == 3 || i%7 == 4) { TableRef st = table3->get_subtable(2, i); size_t expected_size = (i%3 == 1 ? 1 : 0) + (i%8 == 3 ? 1 : 0) + (i%7 == 4 ? 1 : 0); @@ -656,16 +656,16 @@ TEST(Group_MultiLevelSubtables) TableRef table = g.get_table("test"); { Spec& s = table->get_spec(); - s.add_column(COLUMN_TYPE_INT, "int"); + s.add_column(type_Int, "int"); { Spec sub = s.add_subtable_column("tab"); - sub.add_column(COLUMN_TYPE_INT, "int"); + sub.add_column(type_Int, "int"); { Spec subsub = sub.add_subtable_column("tab"); - subsub.add_column(COLUMN_TYPE_INT, "int"); + subsub.add_column(type_Int, "int"); } } - s.add_column(COLUMN_TYPE_MIXED, "mix"); + s.add_column(type_Mixed, "mix"); table->update_from_spec(); } table->add_empty_row(); @@ -680,8 +680,8 @@ TEST(Group_MultiLevelSubtables) TableRef a = table->get_subtable(2, 0); { Spec& s = a->get_spec(); - s.add_column(COLUMN_TYPE_INT, "int"); - s.add_column(COLUMN_TYPE_MIXED, "mix"); + s.add_column(type_Int, "int"); + s.add_column(type_Mixed, "mix"); a->update_from_spec(); } a->add_empty_row(); @@ -689,7 +689,7 @@ TEST(Group_MultiLevelSubtables) TableRef b = a->get_subtable(1, 0); { Spec& s = b->get_spec(); - s.add_column(COLUMN_TYPE_INT, "int"); + s.add_column(type_Int, "int"); b->update_from_spec(); } b->add_empty_row(); @@ -901,17 +901,17 @@ TEST(Group_ToDot) // Create table with all column types TableRef table = mygroup.get_table("test"); Spec s = table->get_spec(); - s.add_column(COLUMN_TYPE_INT, "int"); - s.add_column(COLUMN_TYPE_BOOL, "bool"); - s.add_column(COLUMN_TYPE_DATE, "date"); - s.add_column(COLUMN_TYPE_STRING, "string"); - s.add_column(COLUMN_TYPE_STRING, "string_long"); - s.add_column(COLUMN_TYPE_STRING, "string_enum"); // becomes ColumnStringEnum - s.add_column(COLUMN_TYPE_BINARY, "binary"); - s.add_column(COLUMN_TYPE_MIXED, "mixed"); + s.add_column(type_Int, "int"); + s.add_column(type_Bool, "bool"); + s.add_column(type_Date, "date"); + s.add_column(type_String, "string"); + s.add_column(type_String, "string_long"); + s.add_column(type_String, "string_enum"); // becomes ColumnStringEnum + s.add_column(type_Binary, "binary"); + s.add_column(type_Mixed, "mixed"); Spec sub = s.add_subtable_column("tables"); - sub.add_column(COLUMN_TYPE_INT, "sub_first"); - sub.add_column(COLUMN_TYPE_STRING, "sub_second"); + sub.add_column(type_Int, "sub_first"); + sub.add_column(type_String, "sub_second"); table->UpdateFromSpec(s.GetRef()); // Add some rows @@ -959,12 +959,12 @@ TEST(Group_ToDot) // Add sub-tables if (i == 2) { // To mixed column - table->set_mixed(7, i, Mixed(COLUMN_TYPE_TABLE)); + table->set_mixed(7, i, Mixed(type_Table)); Table subtable = table->GetMixedTable(7, i); Spec s = subtable->get_spec(); - s.add_column(COLUMN_TYPE_INT, "first"); - s.add_column(COLUMN_TYPE_STRING, "second"); + s.add_column(type_Int, "first"); + s.add_column(type_String, "second"); subtable->UpdateFromSpec(s.GetRef()); subtable->insert_int(0, 0, 42); diff --git a/test/testshared.cpp b/test/testshared.cpp index 68faa9f700c..5c34249be22 100644 --- a/test/testshared.cpp +++ b/test/testshared.cpp @@ -508,21 +508,21 @@ TEST(Shared_FormerErrorCase1) TableRef table = wt.get_table("my_table"); { Spec& spec = table->get_spec(); - spec.add_column(COLUMN_TYPE_INT, "alpha"); - spec.add_column(COLUMN_TYPE_BOOL, "beta"); - spec.add_column(COLUMN_TYPE_INT, "gamma"); - spec.add_column(COLUMN_TYPE_DATE, "delta"); - spec.add_column(COLUMN_TYPE_STRING, "epsilon"); - spec.add_column(COLUMN_TYPE_BINARY, "zeta"); + spec.add_column(type_Int, "alpha"); + spec.add_column(type_Bool, "beta"); + spec.add_column(type_Int, "gamma"); + spec.add_column(type_Date, "delta"); + spec.add_column(type_String, "epsilon"); + spec.add_column(type_Binary, "zeta"); { Spec subspec = spec.add_subtable_column("eta"); - subspec.add_column(COLUMN_TYPE_INT, "foo"); + subspec.add_column(type_Int, "foo"); { Spec subsubspec = subspec.add_subtable_column("bar"); - subsubspec.add_column(COLUMN_TYPE_INT, "value"); + subsubspec.add_column(type_Int, "value"); } } - spec.add_column(COLUMN_TYPE_MIXED, "theta"); + spec.add_column(type_Mixed, "theta"); } table->update_from_spec(); table->insert_empty_row(0, 1); diff --git a/test/testtable.cpp b/test/testtable.cpp index 769ed515046..405e9768511 100644 --- a/test/testtable.cpp +++ b/test/testtable.cpp @@ -11,11 +11,11 @@ using namespace tightdb; TEST(Table1) { Table table; - table.add_column(COLUMN_TYPE_INT, "first"); - table.add_column(COLUMN_TYPE_INT, "second"); + table.add_column(type_Int, "first"); + table.add_column(type_Int, "second"); - CHECK_EQUAL(COLUMN_TYPE_INT, table.get_column_type(0)); - CHECK_EQUAL(COLUMN_TYPE_INT, table.get_column_type(1)); + CHECK_EQUAL(type_Int, table.get_column_type(0)); + CHECK_EQUAL(type_Int, table.get_column_type(1)); CHECK_EQUAL("first", table.get_column_name(0)); CHECK_EQUAL("second", table.get_column_name(1)); @@ -50,11 +50,11 @@ TEST(Table1) TEST(Table_floats) { Table table; - table.add_column(COLUMN_TYPE_FLOAT, "first"); - table.add_column(COLUMN_TYPE_DOUBLE, "second"); + table.add_column(type_Float, "first"); + table.add_column(type_Double, "second"); - CHECK_EQUAL(COLUMN_TYPE_FLOAT, table.get_column_type(0)); - CHECK_EQUAL(COLUMN_TYPE_DOUBLE, table.get_column_type(1)); + CHECK_EQUAL(type_Float, table.get_column_type(0)); + CHECK_EQUAL(type_Double, table.get_column_type(1)); CHECK_EQUAL("first", table.get_column_name(0)); CHECK_EQUAL("second", table.get_column_name(1)); @@ -241,17 +241,17 @@ void setup_multi_table(Table& table, const size_t rows, const size_t sub_rows) { // Create table with all column types Spec& s = table.get_spec(); - s.add_column(COLUMN_TYPE_INT, "int"); - s.add_column(COLUMN_TYPE_BOOL, "bool"); - s.add_column(COLUMN_TYPE_DATE, "date"); - s.add_column(COLUMN_TYPE_STRING, "string"); - s.add_column(COLUMN_TYPE_STRING, "string_long"); - s.add_column(COLUMN_TYPE_STRING, "string_enum"); // becomes ColumnStringEnum - s.add_column(COLUMN_TYPE_BINARY, "binary"); - s.add_column(COLUMN_TYPE_MIXED, "mixed"); + s.add_column(type_Int, "int"); + s.add_column(type_Bool, "bool"); + s.add_column(type_Date, "date"); + s.add_column(type_String, "string"); + s.add_column(type_String, "string_long"); + s.add_column(type_String, "string_enum"); // becomes ColumnStringEnum + s.add_column(type_Binary, "binary"); + s.add_column(type_Mixed, "mixed"); Spec sub = s.add_subtable_column("tables"); - sub.add_column(COLUMN_TYPE_INT, "sub_first"); - sub.add_column(COLUMN_TYPE_STRING, "sub_second"); + sub.add_column(type_Int, "sub_first"); + sub.add_column(type_String, "sub_second"); table.update_from_spec(); // Add some rows @@ -313,8 +313,8 @@ void setup_multi_table(Table& table, const size_t rows, const size_t sub_rows) // Add subtable to mixed column if (i % 6 == 5) { TableRef subtable = table.get_subtable(7, i); - subtable->add_column(COLUMN_TYPE_INT, "first"); - subtable->add_column(COLUMN_TYPE_STRING, "second"); + subtable->add_column(type_Int, "first"); + subtable->add_column(type_String, "second"); for (size_t j=0; j<2; j++) { subtable->insert_int(0, j, i*i*j); subtable->insert_string(1, j, "mixed sub"); @@ -413,12 +413,12 @@ TEST(Table_test_json_simple) // Create table with all column types Table table; Spec& s = table.get_spec(); - s.add_column(COLUMN_TYPE_INT, "int"); - s.add_column(COLUMN_TYPE_BOOL, "bool"); - s.add_column(COLUMN_TYPE_DATE, "date"); + s.add_column(type_Int, "int"); + s.add_column(type_Bool, "bool"); + s.add_column(type_Date, "date"); // FIXME: Add float, double - s.add_column(COLUMN_TYPE_STRING, "string"); - s.add_column(COLUMN_TYPE_BINARY, "binary"); + s.add_column(type_String, "string"); + s.add_column(type_Binary, "binary"); table.update_from_spec(); // Add some rows @@ -884,11 +884,11 @@ TEST(Table_Spec) // Create specification with sub-table Spec& s = table->get_spec(); - s.add_column(COLUMN_TYPE_INT, "first"); - s.add_column(COLUMN_TYPE_STRING, "second"); + s.add_column(type_Int, "first"); + s.add_column(type_String, "second"); Spec sub = s.add_subtable_column("third"); - sub.add_column(COLUMN_TYPE_INT, "sub_first"); - sub.add_column(COLUMN_TYPE_STRING, "sub_second"); + sub.add_column(type_Int, "sub_first"); + sub.add_column(type_String, "sub_second"); table->update_from_spec(); CHECK_EQUAL(3, table->get_column_count()); @@ -948,16 +948,16 @@ TEST(Table_Spec_RenameColumns) TableRef table = group.get_table("test"); // Create specification with sub-table - table->add_column(COLUMN_TYPE_INT, "first"); - table->add_column(COLUMN_TYPE_STRING, "second"); - table->add_column(COLUMN_TYPE_TABLE, "third"); + table->add_column(type_Int, "first"); + table->add_column(type_String, "second"); + table->add_column(type_Table, "third"); // Create path to sub-table column vector column_path; column_path.push_back(2); // third - table->add_subcolumn(column_path, COLUMN_TYPE_INT, "sub_first"); - table->add_subcolumn(column_path, COLUMN_TYPE_STRING, "sub_second"); + table->add_subcolumn(column_path, type_Int, "sub_first"); + table->add_subcolumn(column_path, type_String, "sub_second"); // Add a row table->insert_int(0, 0, 4); @@ -999,16 +999,16 @@ TEST(Table_Spec_DeleteColumns) TableRef table = group.get_table("test"); // Create specification with sub-table - table->add_column(COLUMN_TYPE_INT, "first"); - table->add_column(COLUMN_TYPE_STRING, "second"); - table->add_column(COLUMN_TYPE_TABLE, "third"); + table->add_column(type_Int, "first"); + table->add_column(type_String, "second"); + table->add_column(type_Table, "third"); // Create path to sub-table column vector column_path; column_path.push_back(2); // third - table->add_subcolumn(column_path, COLUMN_TYPE_INT, "sub_first"); - table->add_subcolumn(column_path, COLUMN_TYPE_STRING, "sub_second"); + table->add_subcolumn(column_path, type_Int, "sub_first"); + table->add_subcolumn(column_path, type_String, "sub_second"); // Put in an index as well table->set_index(1); @@ -1092,16 +1092,16 @@ TEST(Table_Spec_AddColumns) TableRef table = group.get_table("test"); // Create specification with sub-table - table->add_column(COLUMN_TYPE_INT, "first"); - table->add_column(COLUMN_TYPE_STRING, "second"); - table->add_column(COLUMN_TYPE_TABLE, "third"); + table->add_column(type_Int, "first"); + table->add_column(type_String, "second"); + table->add_column(type_Table, "third"); // Create path to sub-table column vector column_path; column_path.push_back(2); // third - table->add_subcolumn(column_path, COLUMN_TYPE_INT, "sub_first"); - table->add_subcolumn(column_path, COLUMN_TYPE_STRING, "sub_second"); + table->add_subcolumn(column_path, type_Int, "sub_first"); + table->add_subcolumn(column_path, type_String, "sub_second"); // Put in an index as well table->set_index(1); @@ -1132,22 +1132,22 @@ TEST(Table_Spec_AddColumns) CHECK_EQUAL(1, table->get_subtable_size(2, 0)); // Add a new bool column - table->add_column(COLUMN_TYPE_BOOL, "fourth"); + table->add_column(type_Bool, "fourth"); CHECK_EQUAL(4, table->get_column_count()); CHECK_EQUAL(false, table->get_bool(3, 0)); // Add a new string column - table->add_column(COLUMN_TYPE_STRING, "fifth"); + table->add_column(type_String, "fifth"); CHECK_EQUAL(5, table->get_column_count()); CHECK_EQUAL("", table->get_string(4, 0)); // Add a new table column - table->add_column(COLUMN_TYPE_TABLE, "sixth"); + table->add_column(type_Table, "sixth"); CHECK_EQUAL(6, table->get_column_count()); CHECK_EQUAL(0, table->get_subtable_size(5, 0)); // Add a new mixed column - table->add_column(COLUMN_TYPE_MIXED, "seventh"); + table->add_column(type_Mixed, "seventh"); CHECK_EQUAL(7, table->get_column_count()); CHECK_EQUAL(0, table->get_mixed(6, 0).get_int()); @@ -1156,7 +1156,7 @@ TEST(Table_Spec_AddColumns) column_path.push_back(2); // third // Add new int column to sub-table - table->add_subcolumn(column_path, COLUMN_TYPE_INT, "sub_third"); + table->add_subcolumn(column_path, type_Int, "sub_third"); // Get the sub-table again and see if the values // still match. @@ -1171,7 +1171,7 @@ TEST(Table_Spec_AddColumns) } // Add new table column to sub-table - table->add_subcolumn(column_path, COLUMN_TYPE_TABLE, "sub_fourth"); + table->add_subcolumn(column_path, type_Table, "sub_fourth"); // Get the sub-table again and see if the values // still match. @@ -1188,7 +1188,7 @@ TEST(Table_Spec_AddColumns) // Add new column to new sub-table column_path.push_back(3); // sub_forth - table->add_subcolumn(column_path, COLUMN_TYPE_STRING, "first"); + table->add_subcolumn(column_path, type_String, "first"); // Get the sub-table again and see if the values // still match. @@ -1212,18 +1212,18 @@ TEST(Table_Spec_DeleteColumnsBug) table = Table::create(); // Create specification with sub-table - table->add_column(COLUMN_TYPE_STRING, "name"); + table->add_column(type_String, "name"); table->set_index(0); - table->add_column(COLUMN_TYPE_INT, "age"); - table->add_column(COLUMN_TYPE_BOOL, "hired"); - table->add_column(COLUMN_TYPE_TABLE, "phones"); + table->add_column(type_Int, "age"); + table->add_column(type_Bool, "hired"); + table->add_column(type_Table, "phones"); // Create path to sub-table column vector column_path; column_path.push_back(3); // phones - table->add_subcolumn(column_path, COLUMN_TYPE_STRING, "type"); - table->add_subcolumn(column_path, COLUMN_TYPE_STRING, "number"); + table->add_subcolumn(column_path, type_String, "type"); + table->add_subcolumn(column_path, type_String, "number"); // Add rows table->add_empty_row(); @@ -1264,7 +1264,7 @@ TEST(Table_Spec_DeleteColumnsBug) } // Add new column - table->add_column(COLUMN_TYPE_MIXED, "extra"); + table->add_column(type_Mixed, "extra"); table->set_mixed(4, 0, true); table->set_mixed(4, 2, "Random string!"); @@ -1282,11 +1282,11 @@ TEST(Table_Spec_DeleteColumnsBug) TEST(Table_Mixed) { Table table; - table.add_column(COLUMN_TYPE_INT, "first"); - table.add_column(COLUMN_TYPE_MIXED, "second"); + table.add_column(type_Int, "first"); + table.add_column(type_Mixed, "second"); - CHECK_EQUAL(COLUMN_TYPE_INT, table.get_column_type(0)); - CHECK_EQUAL(COLUMN_TYPE_MIXED, table.get_column_type(1)); + CHECK_EQUAL(type_Int, table.get_column_type(0)); + CHECK_EQUAL(type_Mixed, table.get_column_type(1)); CHECK_EQUAL("first", table.get_column_name(0)); CHECK_EQUAL("second", table.get_column_name(1)); @@ -1295,7 +1295,7 @@ TEST(Table_Mixed) table.set_mixed(1, ndx, true); CHECK_EQUAL(0, table.get_int(0, 0)); - CHECK_EQUAL(COLUMN_TYPE_BOOL, table.get_mixed(1, 0).get_type()); + CHECK_EQUAL(type_Bool, table.get_mixed(1, 0).get_type()); CHECK_EQUAL(true, table.get_mixed(1, 0).get_bool()); table.insert_int(0, 1, 43); @@ -1304,8 +1304,8 @@ TEST(Table_Mixed) CHECK_EQUAL(0, table.get_int(0, ndx)); CHECK_EQUAL(43, table.get_int(0, 1)); - CHECK_EQUAL(COLUMN_TYPE_BOOL, table.get_mixed(1, 0).get_type()); - CHECK_EQUAL(COLUMN_TYPE_INT, table.get_mixed(1, 1).get_type()); + CHECK_EQUAL(type_Bool, table.get_mixed(1, 0).get_type()); + CHECK_EQUAL(type_Int, table.get_mixed(1, 1).get_type()); CHECK_EQUAL(true, table.get_mixed(1, 0).get_bool()); CHECK_EQUAL(12, table.get_mixed(1, 1).get_int()); @@ -1315,9 +1315,9 @@ TEST(Table_Mixed) CHECK_EQUAL(0, table.get_int(0, 0)); CHECK_EQUAL(43, table.get_int(0, 1)); - CHECK_EQUAL(COLUMN_TYPE_BOOL, table.get_mixed(1, 0).get_type()); - CHECK_EQUAL(COLUMN_TYPE_INT, table.get_mixed(1, 1).get_type()); - CHECK_EQUAL(COLUMN_TYPE_STRING, table.get_mixed(1, 2).get_type()); + CHECK_EQUAL(type_Bool, table.get_mixed(1, 0).get_type()); + CHECK_EQUAL(type_Int, table.get_mixed(1, 1).get_type()); + CHECK_EQUAL(type_String, table.get_mixed(1, 2).get_type()); CHECK_EQUAL(true, table.get_mixed(1, 0).get_bool()); CHECK_EQUAL(12, table.get_mixed(1, 1).get_int()); CHECK_EQUAL("test", table.get_mixed(1, 2).get_string()); @@ -1329,10 +1329,10 @@ TEST(Table_Mixed) CHECK_EQUAL(0, table.get_int(0, 0)); CHECK_EQUAL(43, table.get_int(0, 1)); CHECK_EQUAL(0, table.get_int(0, 3)); - CHECK_EQUAL(COLUMN_TYPE_BOOL, table.get_mixed(1, 0).get_type()); - CHECK_EQUAL(COLUMN_TYPE_INT, table.get_mixed(1, 1).get_type()); - CHECK_EQUAL(COLUMN_TYPE_STRING, table.get_mixed(1, 2).get_type()); - CHECK_EQUAL(COLUMN_TYPE_DATE, table.get_mixed(1, 3).get_type()); + CHECK_EQUAL(type_Bool, table.get_mixed(1, 0).get_type()); + CHECK_EQUAL(type_Int, table.get_mixed(1, 1).get_type()); + CHECK_EQUAL(type_String, table.get_mixed(1, 2).get_type()); + CHECK_EQUAL(type_Date, table.get_mixed(1, 3).get_type()); CHECK_EQUAL(true, table.get_mixed(1, 0).get_bool()); CHECK_EQUAL(12, table.get_mixed(1, 1).get_int()); CHECK_EQUAL("test", table.get_mixed(1, 2).get_string()); @@ -1346,11 +1346,11 @@ TEST(Table_Mixed) CHECK_EQUAL(43, table.get_int(0, 1)); CHECK_EQUAL(0, table.get_int(0, 3)); CHECK_EQUAL(43, table.get_int(0, 4)); - CHECK_EQUAL(COLUMN_TYPE_BOOL, table.get_mixed(1, 0).get_type()); - CHECK_EQUAL(COLUMN_TYPE_INT, table.get_mixed(1, 1).get_type()); - CHECK_EQUAL(COLUMN_TYPE_STRING, table.get_mixed(1, 2).get_type()); - CHECK_EQUAL(COLUMN_TYPE_DATE, table.get_mixed(1, 3).get_type()); - CHECK_EQUAL(COLUMN_TYPE_BINARY, table.get_mixed(1, 4).get_type()); + CHECK_EQUAL(type_Bool, table.get_mixed(1, 0).get_type()); + CHECK_EQUAL(type_Int, table.get_mixed(1, 1).get_type()); + CHECK_EQUAL(type_String, table.get_mixed(1, 2).get_type()); + CHECK_EQUAL(type_Date, table.get_mixed(1, 3).get_type()); + CHECK_EQUAL(type_Binary, table.get_mixed(1, 4).get_type()); CHECK_EQUAL(true, table.get_mixed(1, 0).get_bool()); CHECK_EQUAL(12, table.get_mixed(1, 1).get_int()); CHECK_EQUAL("test", table.get_mixed(1, 2).get_string()); @@ -1367,12 +1367,12 @@ TEST(Table_Mixed) CHECK_EQUAL(0, table.get_int(0, 3)); CHECK_EQUAL(43, table.get_int(0, 4)); CHECK_EQUAL(0, table.get_int(0, 5)); - CHECK_EQUAL(COLUMN_TYPE_BOOL, table.get_mixed(1, 0).get_type()); - CHECK_EQUAL(COLUMN_TYPE_INT, table.get_mixed(1, 1).get_type()); - CHECK_EQUAL(COLUMN_TYPE_STRING, table.get_mixed(1, 2).get_type()); - CHECK_EQUAL(COLUMN_TYPE_DATE, table.get_mixed(1, 3).get_type()); - CHECK_EQUAL(COLUMN_TYPE_BINARY, table.get_mixed(1, 4).get_type()); - CHECK_EQUAL(COLUMN_TYPE_TABLE, table.get_mixed(1, 5).get_type()); + CHECK_EQUAL(type_Bool, table.get_mixed(1, 0).get_type()); + CHECK_EQUAL(type_Int, table.get_mixed(1, 1).get_type()); + CHECK_EQUAL(type_String, table.get_mixed(1, 2).get_type()); + CHECK_EQUAL(type_Date, table.get_mixed(1, 3).get_type()); + CHECK_EQUAL(type_Binary, table.get_mixed(1, 4).get_type()); + CHECK_EQUAL(type_Table, table.get_mixed(1, 5).get_type()); CHECK_EQUAL(true, table.get_mixed(1, 0).get_bool()); CHECK_EQUAL(12, table.get_mixed(1, 1).get_int()); CHECK_EQUAL("test", table.get_mixed(1, 2).get_string()); @@ -1382,8 +1382,8 @@ TEST(Table_Mixed) // Get table from mixed column and add schema and some values TableRef subtable = table.get_subtable(1, 5); - subtable->add_column(COLUMN_TYPE_STRING, "name"); - subtable->add_column(COLUMN_TYPE_INT, "age"); + subtable->add_column(type_String, "name"); + subtable->add_column(type_Int, "age"); subtable->insert_string(0, 0, "John"); subtable->insert_int(1, 0, 40); @@ -1410,14 +1410,14 @@ TEST(Table_Mixed) CHECK_EQUAL(0, table.get_int(0, 5)); CHECK_EQUAL(31, table.get_int(0, 6)); CHECK_EQUAL(0, table.get_int(0, 7)); - CHECK_EQUAL(COLUMN_TYPE_BOOL, table.get_mixed(1, 0).get_type()); - CHECK_EQUAL(COLUMN_TYPE_INT, table.get_mixed(1, 1).get_type()); - CHECK_EQUAL(COLUMN_TYPE_STRING, table.get_mixed(1, 2).get_type()); - CHECK_EQUAL(COLUMN_TYPE_DATE, table.get_mixed(1, 3).get_type()); - CHECK_EQUAL(COLUMN_TYPE_BINARY, table.get_mixed(1, 4).get_type()); - CHECK_EQUAL(COLUMN_TYPE_TABLE, table.get_mixed(1, 5).get_type()); - CHECK_EQUAL(COLUMN_TYPE_FLOAT, table.get_mixed(1, 6).get_type()); - CHECK_EQUAL(COLUMN_TYPE_DOUBLE, table.get_mixed(1, 7).get_type()); + CHECK_EQUAL(type_Bool, table.get_mixed(1, 0).get_type()); + CHECK_EQUAL(type_Int, table.get_mixed(1, 1).get_type()); + CHECK_EQUAL(type_String, table.get_mixed(1, 2).get_type()); + CHECK_EQUAL(type_Date, table.get_mixed(1, 3).get_type()); + CHECK_EQUAL(type_Binary, table.get_mixed(1, 4).get_type()); + CHECK_EQUAL(type_Table, table.get_mixed(1, 5).get_type()); + CHECK_EQUAL(type_Float, table.get_mixed(1, 6).get_type()); + CHECK_EQUAL(type_Double, table.get_mixed(1, 7).get_type()); CHECK_EQUAL(true, table.get_mixed(1, 0).get_bool()); CHECK_EQUAL(12, table.get_mixed(1, 1).get_int()); CHECK_EQUAL("test", table.get_mixed(1, 2).get_string()); @@ -1447,10 +1447,10 @@ TEST(Table_Mixed2) table.add(Date(1234)); table.add("test"); - CHECK_EQUAL(COLUMN_TYPE_INT, table[0].first.get_type()); - CHECK_EQUAL(COLUMN_TYPE_BOOL, table[1].first.get_type()); - CHECK_EQUAL(COLUMN_TYPE_DATE, table[2].first.get_type()); - CHECK_EQUAL(COLUMN_TYPE_STRING, table[3].first.get_type()); + CHECK_EQUAL(type_Int, table[0].first.get_type()); + CHECK_EQUAL(type_Bool, table[1].first.get_type()); + CHECK_EQUAL(type_Date, table[2].first.get_type()); + CHECK_EQUAL(type_String, table[3].first.get_type()); CHECK_EQUAL(1, table[0].first.get_int()); CHECK_EQUAL(true, table[1].first.get_bool()); @@ -1465,9 +1465,9 @@ TEST(Table_SubtableSizeAndClear) Spec& spec = table.get_spec(); { Spec subspec = spec.add_subtable_column("subtab"); - subspec.add_column(COLUMN_TYPE_INT, "int"); + subspec.add_column(type_Int, "int"); } - spec.add_column(COLUMN_TYPE_MIXED, "mixed"); + spec.add_column(type_Mixed, "mixed"); table.update_from_spec(); table.insert_subtable(0, 0); @@ -1495,7 +1495,7 @@ TEST(Table_SubtableSizeAndClear) TableRef subtab2 = table.get_subtable(1, 0); { Spec& subspec = subtab2->get_spec(); - subspec.add_column(COLUMN_TYPE_INT, "int"); + subspec.add_column(type_Int, "int"); subtab2->update_from_spec(); } @@ -1707,9 +1707,9 @@ TEST(Table_Test_Clear_With_Subtable_AND_Group) // Create specification with sub-table Spec& s = table->get_spec(); - s.add_column(COLUMN_TYPE_STRING, "name"); + s.add_column(type_String, "name"); Spec sub = s.add_subtable_column("sub"); - sub.add_column(COLUMN_TYPE_INT, "num"); + sub.add_column(type_Int, "num"); table->update_from_spec(); CHECK_EQUAL(2, table->get_column_count()); diff --git a/test/testtransactions_lasse.cpp b/test/testtransactions_lasse.cpp index 19d6506a714..17c8de707cf 100644 --- a/test/testtransactions_lasse.cpp +++ b/test/testtransactions_lasse.cpp @@ -154,7 +154,7 @@ TEST(Transactions_Stress1) WriteTransaction wt(sg); TableRef table = wt.get_table("table"); Spec& spec = table->get_spec(); - spec.add_column(COLUMN_TYPE_INT, "row"); + spec.add_column(type_Int, "row"); table->update_from_spec(); table->insert_empty_row(0, 1); table->set_int(0, 0, 0); @@ -315,7 +315,7 @@ TEST(Transactions_Stress3) WriteTransaction wt(sg); TableRef table = wt.get_table("table"); Spec& spec = table->get_spec(); - spec.add_column(COLUMN_TYPE_INT, "row"); + spec.add_column(type_Int, "row"); table->update_from_spec(); wt.commit(); } @@ -412,7 +412,7 @@ TEST(Transactions_Stress4) WriteTransaction wt(sg); TableRef table = wt.get_table("table"); Spec& spec = table->get_spec(); - spec.add_column(COLUMN_TYPE_INT, "row"); + spec.add_column(type_Int, "row"); table->update_from_spec(); table->insert_empty_row(0, 1); table->set_int(0, 0, 0); diff --git a/test/transactions.cpp b/test/transactions.cpp index 041e581ca5e..797944ba76d 100644 --- a/test/transactions.cpp +++ b/test/transactions.cpp @@ -226,7 +226,7 @@ void round(SharedGroup& db, int index) WriteTransaction wt(db); // Write transaction #14 MyTable::Ref table = wt.get_table("my_table"); MyTable::Ref subtable; - if (table[1].theta.get_type() == COLUMN_TYPE_TABLE) { + if (table[1].theta.get_type() == type_Table) { subtable = table[1].theta.get_subtable(); } else { @@ -266,7 +266,7 @@ void round(SharedGroup& db, int index) MyTable::Ref table = wt.get_table("my_table"); MyTable::Ref subtable = table[1].theta.get_subtable(); MyTable::Ref subsubtable; - if (subtable[0].theta.get_type() == COLUMN_TYPE_TABLE) { + if (subtable[0].theta.get_type() == type_Table) { subsubtable = subtable[0].theta.get_subtable(); } else { @@ -291,7 +291,7 @@ void round(SharedGroup& db, int index) MyTable::Ref table = wt.get_table("my_table"); MyTable::Ref subtable = table[1].theta.get_subtable(); MySubtable::Ref subsubtable; - if (subtable[1].theta.get_type() == COLUMN_TYPE_TABLE) { + if (subtable[1].theta.get_type() == type_Table) { subsubtable = subtable[1].theta.get_subtable(); } else { @@ -329,7 +329,7 @@ void round(SharedGroup& db, int index) MyTable::Ref table = wt.get_table("my_table"); MyTable::Ref subtable = table[1].theta.get_subtable(); MySubsubtable::Ref subsubtable; - if (subtable[2].theta.get_type() == COLUMN_TYPE_TABLE) { + if (subtable[2].theta.get_type() == type_Table) { subsubtable = subtable[2].theta.get_subtable(); } else { @@ -349,7 +349,7 @@ void round(SharedGroup& db, int index) MyTable::Ref table = wt.get_table("my_table"); MyTable::Ref subtable = table[1].theta.get_subtable(); MySubsubtable::Ref subsubtable; - if (subtable[3].theta.get_type() == COLUMN_TYPE_TABLE) { + if (subtable[3].theta.get_type() == type_Table) { subsubtable = subtable[3].theta.get_subtable(); } else { @@ -493,7 +493,7 @@ TEST(Transactions) CHECK_EQUAL(BinaryData(0,0), subtable[i].zeta); CHECK_EQUAL(0u, subtable[i].eta->size()); if (4 <= i) { - CHECK_EQUAL(COLUMN_TYPE_INT, subtable[i].theta.get_type()); + CHECK_EQUAL(type_Int, subtable[i].theta.get_type()); } } CHECK_EQUAL(size_t(num_threads*num_rounds*5), diff --git a/tightdb.xcodeproj/project.pbxproj b/tightdb.xcodeproj/project.pbxproj index b0c21ce060d..614e1746acd 100644 --- a/tightdb.xcodeproj/project.pbxproj +++ b/tightdb.xcodeproj/project.pbxproj @@ -187,6 +187,8 @@ 4142C98F1623478700B3B902 /* string_buffer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 36D6FC3715E3813700B02534 /* string_buffer.hpp */; }; 4142C9901623478700B3B902 /* table_basic_fwd.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 36D6FC3815E3813700B02534 /* table_basic_fwd.hpp */; }; 4142C9911623478700B3B902 /* terminate.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 36D6FC3A15E3813700B02534 /* terminate.hpp */; }; + 520588C716C1DA71009DA6D8 /* data_type.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 520588C616C1DA71009DA6D8 /* data_type.hpp */; }; + 520588CA16C1DA9D009DA6D8 /* data_type.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 520588C916C1DA9D009DA6D8 /* data_type.hpp */; }; 52113CDB16C27ED400C301FB /* lang_bind_helper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52113CDA16C27ED400C301FB /* lang_bind_helper.cpp */; }; 52113CDE16C27EF800C301FB /* lang_bind_helper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52113CDD16C27EF800C301FB /* lang_bind_helper.cpp */; }; 52C3965416BC669D003619FF /* pthread_helpers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52C3965316BC669D003619FF /* pthread_helpers.cpp */; }; @@ -427,6 +429,8 @@ 36FD6F3414BDC61A009E0003 /* TestQuery.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestQuery.cpp; sourceTree = ""; }; 36FD6F3514BDC61A009E0003 /* testTableView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = testTableView.cpp; sourceTree = ""; }; 4142C9951623478700B3B902 /* liblibtightdb ios.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "liblibtightdb ios.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 520588C616C1DA71009DA6D8 /* data_type.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = data_type.hpp; path = src/tightdb/data_type.hpp; sourceTree = ""; }; + 520588C916C1DA9D009DA6D8 /* data_type.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = data_type.hpp; path = src/tightdb/data_type.hpp; sourceTree = ""; }; 52113CDA16C27ED400C301FB /* lang_bind_helper.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = lang_bind_helper.cpp; path = src/tightdb/lang_bind_helper.cpp; sourceTree = ""; }; 52113CDD16C27EF800C301FB /* lang_bind_helper.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = lang_bind_helper.cpp; path = src/tightdb/lang_bind_helper.cpp; sourceTree = ""; }; 52C3965316BC669D003619FF /* pthread_helpers.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = pthread_helpers.cpp; path = src/tightdb/pthread_helpers.cpp; sourceTree = ""; }; @@ -476,6 +480,8 @@ 3611F2FA14209B7000017263 = { isa = PBXGroup; children = ( + 520588C916C1DA9D009DA6D8 /* data_type.hpp */, + 520588C616C1DA71009DA6D8 /* data_type.hpp */, 52113CDD16C27EF800C301FB /* lang_bind_helper.cpp */, 52113CDA16C27ED400C301FB /* lang_bind_helper.cpp */, 52E38B8716BDA00E0009C055 /* unique_ptr.hpp */, @@ -823,6 +829,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 520588C716C1DA71009DA6D8 /* data_type.hpp in Headers */, 52E38B8616BD9FEA0009C055 /* unique_ptr.hpp in Headers */, 365CCE35157CC37D00172BF8 /* alloc_slab.hpp in Headers */, 365CCE36157CC37D00172BF8 /* alloc.hpp in Headers */, @@ -883,6 +890,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 520588CA16C1DA9D009DA6D8 /* data_type.hpp in Headers */, 52E38B8816BDA00E0009C055 /* unique_ptr.hpp in Headers */, 4142C95A1623478700B3B902 /* alloc_slab.hpp in Headers */, 4142C95B1623478700B3B902 /* alloc.hpp in Headers */,