void o_document_field_set(struct o_document * doc, char * field_name, struct o_document_value* value) { struct o_document_value * old = o_map_string_put(doc->fields, field_name, value); if (old != 0) { if (doc->fields_old_values == 0) doc->fields_old_values = o_map_string_new(); o_map_string_put(doc->fields_old_values, field_name, old); } }
struct o_document * o_document_copy(struct o_document * doc) { struct o_document * new_doc = o_document_new(); int i; int size; char ** keys = o_map_string_keys(doc->fields, &size); for (i = 0; i < size; ++i) o_map_string_put(new_doc->fields, keys[i], o_map_string_get(new_doc->fields, keys[i])); return new_doc; }
struct o_storage_factory * o_engine_get_factory(enum o_url_type type, char *path) { struct o_engine *cur_engine = o_engine_get_instance(); struct o_storage_factory * new_con; if ((new_con = o_map_string_get(cur_engine->factories, path)) == 0) { new_con = o_storage_factory_new(type, path); o_map_string_put(cur_engine->factories, path, new_con); } return new_con; }
struct o_connection * o_engine_get_connection(enum o_url_type type, char *path, char * username) { struct o_engine *cur_engine = o_engine_get_instance(); struct o_connection * new_con; char * key = createKey(path, username); if ((new_con = o_map_string_get(cur_engine->connections, key)) == 0) { new_con = o_connection_new(type, path); o_map_string_put(cur_engine->connections, key, new_con); } o_free(key); return new_con; }
struct o_storage * o_connection_storage_open(struct o_connection * conn, char * name, char * username, char * password) { char * store_name = o_connection_build_storage_name(name, username); struct o_storage * str = o_map_string_get(conn->storages, store_name); if (str == 0) { conn->last_user = username; str = conn->storage_open(conn, name, username, password); o_map_string_put(conn->storages, store_name, str); } o_storage_reference(str); o_free(store_name); return str; }