medit/moo/mooutils/moofilewriter.h
Yevgen Muntyan c640dc0edf More C++
2016-01-19 03:54:06 -08:00

90 lines
3.8 KiB
C

/*
* mooutils-file.h
*
* Copyright (C) 2004-2010 by Yevgen Muntyan <emuntyan@users.sourceforge.net>
*
* This file is part of medit. medit is free software; you can
* redistribute it and/or modify it under the terms of the
* GNU Lesser General Public License as published by the
* Free Software Foundation; either version 2.1 of the License,
* or (at your option) any later version.
*
* You should have received a copy of the GNU Lesser General Public
* License along with medit. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <mooutils/mooutils-misc.h>
#ifdef __cplusplus
#include <moocpp/gobjtypes-gio.h>
struct MooFileReader;
struct MooFileWriter;
void g_object_ref(MooFileReader*) = delete;
void g_object_unref(MooFileReader*) = delete;
void g_object_ref(MooFileWriter*) = delete;
void g_object_unref(MooFileWriter*) = delete;
MooFileReader *moo_file_reader_new (const char *filename,
moo::gerrp& error);
MooFileReader *moo_text_reader_new (const char *filename,
moo::gerrp& error);
gboolean moo_file_reader_read (MooFileReader *reader,
char *buf,
gsize buf_size,
gsize *size_read,
moo::gerrp& error);
void moo_file_reader_close (MooFileReader *reader);
typedef enum /*< flags >*/
{
MOO_FILE_WRITER_FLAGS_NONE = 0,
MOO_FILE_WRITER_SAVE_BACKUP = 1 << 0,
MOO_FILE_WRITER_CONFIG_MODE = 1 << 1,
MOO_FILE_WRITER_TEXT_MODE = 1 << 2
} MooFileWriterFlags;
MOO_DEFINE_FLAGS(MooFileWriterFlags);
MooFileWriter *moo_file_writer_new (const char *filename,
MooFileWriterFlags flags,
moo::gerrp& error);
MooFileWriter *moo_file_writer_new_for_file (moo::g::File file,
MooFileWriterFlags flags,
moo::gerrp& error);
MooFileWriter *moo_config_writer_new (const char *filename,
gboolean save_backup,
moo::gerrp& error);
MooFileWriter *moo_string_writer_new (void);
gboolean moo_file_writer_close (MooFileWriter *writer,
moo::gerrp& error);
#endif // __cplusplus
G_BEGIN_DECLS
typedef struct MooFileWriter MooFileWriter;
MooFileWriter *moo_config_writer_new (const char *filename,
gboolean save_backup,
GError **error);
gboolean moo_file_writer_write (MooFileWriter *writer,
const char *data,
gssize len);
gboolean moo_file_writer_printf (MooFileWriter *writer,
const char *fmt,
...) G_GNUC_PRINTF (2, 3);
gboolean moo_file_writer_printf_markup (MooFileWriter *writer,
const char *fmt,
...) G_GNUC_PRINTF (2, 3);
gboolean moo_file_writer_close (MooFileWriter *writer,
GError **error);
G_END_DECLS