From 68d41d3b214856f8d321b4dbdffc0cd4c7333c36 Mon Sep 17 00:00:00 2001 From: Krzysztof Dermont Date: Mon, 23 Jun 2014 23:19:55 +0200 Subject: More work on streams --- src/common/resources/inputstreambuffer.h | 48 ++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/common/resources/inputstreambuffer.h (limited to 'src/common/resources/inputstreambuffer.h') diff --git a/src/common/resources/inputstreambuffer.h b/src/common/resources/inputstreambuffer.h new file mode 100644 index 0000000..93cb43c --- /dev/null +++ b/src/common/resources/inputstreambuffer.h @@ -0,0 +1,48 @@ +// * This file is part of the COLOBOT source code +// * Copyright (C) 2014 Polish Portal of Colobot (PPC) +// * +// * This program is free software: you can redistribute it and/or modify +// * it under the terms of the GNU General Public License as published by +// * the Free Software Foundation, either version 3 of the License, or +// * (at your option) any later version. +// * +// * This program is distributed in the hope that it will be useful, +// * but WITHOUT ANY WARRANTY; without even the implied warranty of +// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// * GNU General Public License for more details. +// * +// * You should have received a copy of the GNU General Public License +// * along with this program. If not, see http://www.gnu.org/licenses/. + +#pragma once + +#include +#include +#include + +class CInputStreamBuffer : public std::streambuf +{ +public: + CInputStreamBuffer(size_t buffer_size = 512); + virtual ~CInputStreamBuffer(); + + void open(const std::string &filename); + void close(); + bool is_open(); + size_t size(); + +private: + int_type underflow(); + + std::streampos seekpos(std::streampos sp, std::ios_base::openmode which); + std::streampos seekoff(std::streamoff off, std::ios_base::seekdir way, std::ios_base::openmode which); + + // copy ctor and assignment not implemented; + // copying not allowed + CInputStreamBuffer(const CInputStreamBuffer &); + CInputStreamBuffer &operator= (const CInputStreamBuffer &); + + PHYSFS_File *m_file; + char *m_buffer; + size_t m_buffer_size; +}; -- cgit v1.2.3-1-g7c22 From 6a1ceba8c0914691ebc873fd666e7cde1cffdb64 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 7 Sep 2014 19:26:06 +0200 Subject: Some cleaning up --- src/common/resources/inputstreambuffer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/common/resources/inputstreambuffer.h') diff --git a/src/common/resources/inputstreambuffer.h b/src/common/resources/inputstreambuffer.h index 93cb43c..384ebfb 100644 --- a/src/common/resources/inputstreambuffer.h +++ b/src/common/resources/inputstreambuffer.h @@ -25,7 +25,7 @@ class CInputStreamBuffer : public std::streambuf public: CInputStreamBuffer(size_t buffer_size = 512); virtual ~CInputStreamBuffer(); - + void open(const std::string &filename); void close(); bool is_open(); @@ -41,7 +41,7 @@ private: // copying not allowed CInputStreamBuffer(const CInputStreamBuffer &); CInputStreamBuffer &operator= (const CInputStreamBuffer &); - + PHYSFS_File *m_file; char *m_buffer; size_t m_buffer_size; -- cgit v1.2.3-1-g7c22 From 47ea8a1175488564c11e09f71447cb19515c6e6c Mon Sep 17 00:00:00 2001 From: krzys-h Date: Wed, 15 Oct 2014 21:14:34 +0200 Subject: Updated some more license headers --- src/common/resources/inputstreambuffer.h | 33 +++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'src/common/resources/inputstreambuffer.h') diff --git a/src/common/resources/inputstreambuffer.h b/src/common/resources/inputstreambuffer.h index 384ebfb..8c45c22 100644 --- a/src/common/resources/inputstreambuffer.h +++ b/src/common/resources/inputstreambuffer.h @@ -1,18 +1,21 @@ -// * This file is part of the COLOBOT source code -// * Copyright (C) 2014 Polish Portal of Colobot (PPC) -// * -// * This program is free software: you can redistribute it and/or modify -// * it under the terms of the GNU General Public License as published by -// * the Free Software Foundation, either version 3 of the License, or -// * (at your option) any later version. -// * -// * This program is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// * GNU General Public License for more details. -// * -// * You should have received a copy of the GNU General Public License -// * along with this program. If not, see http://www.gnu.org/licenses/. +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ #pragma once -- cgit v1.2.3-1-g7c22