forked from GitHub/gf-core
added function pgf_write
This commit is contained in:
@@ -76,6 +76,8 @@ libpgf_la_SOURCES = \
|
|||||||
pgf/literals.h \
|
pgf/literals.h \
|
||||||
pgf/reader.h \
|
pgf/reader.h \
|
||||||
pgf/reader.c \
|
pgf/reader.c \
|
||||||
|
pgf/writer.h \
|
||||||
|
pgf/writer.c \
|
||||||
pgf/linearizer.c \
|
pgf/linearizer.c \
|
||||||
pgf/typechecker.c \
|
pgf/typechecker.c \
|
||||||
pgf/reasoner.c \
|
pgf/reasoner.c \
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include <pgf/data.h>
|
#include <pgf/data.h>
|
||||||
#include <pgf/expr.h>
|
#include <pgf/expr.h>
|
||||||
#include <pgf/reader.h>
|
#include <pgf/reader.h>
|
||||||
|
#include <pgf/writer.h>
|
||||||
#include <pgf/linearizer.h>
|
#include <pgf/linearizer.h>
|
||||||
#include <gu/file.h>
|
#include <gu/file.h>
|
||||||
#include <gu/string.h>
|
#include <gu/string.h>
|
||||||
@@ -44,6 +45,28 @@ pgf_read_in(GuIn* in,
|
|||||||
return pgf;
|
return pgf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PGF_API_DECL void
|
||||||
|
pgf_write(PgfPGF* pgf, const char* fpath, GuExn* err)
|
||||||
|
{
|
||||||
|
FILE* outfile = fopen(fpath, "wb");
|
||||||
|
if (outfile == NULL) {
|
||||||
|
gu_raise_errno(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GuPool* tmp_pool = gu_local_pool();
|
||||||
|
|
||||||
|
// Create an input stream from the input file
|
||||||
|
GuOut* out = gu_file_out(outfile, tmp_pool);
|
||||||
|
|
||||||
|
PgfWriter* wtr = pgf_new_writer(out, tmp_pool, err);
|
||||||
|
pgf_write_pgf(pgf, wtr);
|
||||||
|
|
||||||
|
gu_pool_free(tmp_pool);
|
||||||
|
|
||||||
|
fclose(outfile);
|
||||||
|
}
|
||||||
|
|
||||||
PGF_API GuString
|
PGF_API GuString
|
||||||
pgf_abstract_name(PgfPGF* pgf)
|
pgf_abstract_name(PgfPGF* pgf)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -57,6 +57,9 @@ pgf_concrete_load(PgfConcr* concr, GuIn* in, GuExn* err);
|
|||||||
PGF_API_DECL void
|
PGF_API_DECL void
|
||||||
pgf_concrete_unload(PgfConcr* concr);
|
pgf_concrete_unload(PgfConcr* concr);
|
||||||
|
|
||||||
|
PGF_API_DECL void
|
||||||
|
pgf_write(PgfPGF* pgf, const char* fpath, GuExn* err);
|
||||||
|
|
||||||
PGF_API_DECL GuString
|
PGF_API_DECL GuString
|
||||||
pgf_abstract_name(PgfPGF*);
|
pgf_abstract_name(PgfPGF*);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user