medit/moo/mooutils/moofilewriter-private.h

77 lines
2.0 KiB
C
Raw Normal View History

/*
2010-11-23 21:54:39 -08:00
* moofilewriter-private.h
*
2016-01-19 03:54:06 -08:00
* Copyright (C) 2004-2016 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/>.
*/
2016-01-19 03:54:06 -08:00
#pragma once
2010-11-23 21:54:39 -08:00
#include "mooutils/moofilewriter.h"
2016-01-19 03:54:06 -08:00
struct MooFileReader
{
MooFileReader();
~MooFileReader();
2016-01-19 03:54:06 -08:00
void close_file();
2016-01-19 03:54:06 -08:00
MOO_DISABLE_COPY_OPS(MooFileReader);
2016-01-19 03:54:06 -08:00
MGW_FILE *file;
};
2016-01-19 03:54:06 -08:00
struct MooFileWriter
{
virtual ~MooFileWriter() {}
2016-01-19 03:54:06 -08:00
virtual bool write (const char* data,
gsize len) = 0;
virtual bool printf (const char* fmt,
va_list args) G_GNUC_PRINTF (2, 0) = 0;
virtual bool close (moo::gerrp& error) = 0;
};
2016-01-19 03:54:06 -08:00
struct MooLocalFileWriter : public MooFileWriter
{
MooLocalFileWriter();
~MooLocalFileWriter();
2016-01-19 03:54:06 -08:00
bool write (const char* data,
gsize len) override;
bool printf (const char* fmt,
va_list args) G_GNUC_PRINTF (2, 0) override;
bool close (moo::gerrp& error) override;
2016-01-19 03:54:06 -08:00
MOO_DISABLE_COPY_OPS(MooLocalFileWriter);
2016-01-19 03:54:06 -08:00
moo::g::FilePtr file;
moo::g::FileOutputStreamPtr stream;
MooFileWriterFlags flags;
moo::gerrp error;
};
2016-01-19 03:54:06 -08:00
struct MooStringWriter : public MooFileWriter
{
MooStringWriter();
~MooStringWriter();
2016-01-19 03:54:06 -08:00
bool write (const char* data,
gsize len) override;
bool printf (const char* fmt,
va_list args) G_GNUC_PRINTF (2, 0) override;
bool close (moo::gerrp& error) override;
2016-01-19 03:54:06 -08:00
MOO_DISABLE_COPY_OPS(MooStringWriter);
2016-01-19 03:54:06 -08:00
GString *string;
};