boost::python::object wrap_array(const k3d::array* Wrapped) { if(Wrapped) return wrap_array(*Wrapped); return boost::python::object(); }
static object get_item1(const_table_wrapper& Self, const string_t& Key) { k3d::table::const_iterator iterator = Self.wrapped().find(Key); if(iterator == Self.wrapped().end()) throw std::runtime_error("unknown key: " + Key); return wrap_array(iterator->second.get()); }
static object get_item2(const_table_wrapper& Self, int Item) { if(Item < 0 || Item >= Self.wrapped().column_count()) throw std::out_of_range("index out-of-range"); k3d::table::const_iterator iterator = Self.wrapped().begin(); std::advance(iterator, Item); return wrap_array(iterator->second.get()); }
int main() { Tree *tree = NULL; IntList *list = NULL; int nums[12] = {10, 15, 5, 3, 14, 7, 2, 11, 9, 0, 16, 15}; // NULL Tree. printf("Attempting to make and print a NULL Tree...\n"); tree = new_tree_from_list(list); print_tree(tree); // Few elements at a time. printf("Adding a few elements at a time...\n"); tree = new_tree(); insert(tree, 5); printf("One leaf...\n"); print_tree(tree); insert(tree, 3); printf("Two leaves...\n"); print_tree(tree); insert(tree, 7); printf("Three leaves...\n"); print_tree(tree); // From a list. printf("Making a Tree from an IntList...\n"); list = wrap_array(nums, 12); tree = new_tree_from_list(list); print_tree(tree); // Testing contains. test_contains(tree, 1); test_contains(tree, 16); test_contains(tree, 15); test_contains(tree, 5); test_contains(tree, 7); test_contains(tree, 0); test_contains(tree, 6); return 0; }
/// /// << operator for opening a new subarray in the core builder. /// /// @param _ /// An open_array_type token /// BSONCXX_INLINE array_context<base> operator<<(const open_array_type) { _core->open_array(); return wrap_array(); }
array_ctx<array_ctx> operator<<(builder::helpers::open_array_t) { _concrete->open_array_append(); return wrap_array(); }