int sb_trie_save (SBTrie *sb_trie) { if (!sb_trie) return -1; return trie_save (sb_trie->trie); }
void ATTrie :: save(const char * path) { if (data->trie == NULL) return; int ret = trie_save(data->trie, path); if (ret != 0) throw "TrieSaveException"; }
/** Testuje zapisywanie drzewa. @param state Środowisko testowe. */ static void trie_save_test(void** state) { Trie *trie = trie_new(); FILE *stream; wchar_t *buf = NULL; size_t len; stream = open_wmemstream(&buf, &len); if (stream == NULL) { fprintf(stderr, "Failed to open memory stream\n"); exit(EXIT_FAILURE); } IO *io = io_new(stdin, stream, stderr); assert_true(trie_save(trie, io) == 0); fflush(stream); assert_true(wcscmp(L"\n", buf) == 0); fseek(stream, 0, SEEK_SET); trie_insert_word(trie, L"ciupaga"); assert_true(trie_save(trie, io) == 0); fflush(stream); assert_true(wcscmp(L"ciupaga*^^^^^^^\n", buf) == 0); fseek(stream, 0, SEEK_SET); trie_delete_word(trie, L"ciupaga"); assert_true(trie_save(trie, io) == 0); fflush(stream); assert_true(wcscmp(L"\n", buf) == 0); fclose(stream); io_done(io); # undef free free(buf); # define free(ptr) _test_free(ptr, __FILE__, __LINE__) trie_done(trie); }
static int p_trie_save(void) { const char *file_str; FILE *file; /* check args */ if (!YAP_IsIntTerm(arg_trie)) return FALSE; if (!YAP_IsAtomTerm(arg_file)) return FALSE; /* open file */ file_str = YAP_AtomName(YAP_AtomOfTerm(arg_file)); if (!(file = fopen(file_str, "w"))) return FALSE; /* save trie and close file */ trie_save((TrEntry) YAP_IntOfTerm(arg_trie), file); if (fclose(file)) return FALSE; return TRUE; }
int sb_trie_save (SBTrie *sb_trie) { return trie_save (sb_trie->trie); }
int dictionary_save(const struct dictionary *dict, FILE* stream) { return trie_save(dict->tree, stream); }