📄 filewriter.h
字号:
//// Copyright (c) 2005 by Istv醤 V醨adi//// This file is part of dxr3Player, a DVD player written specifically // for the DXR3 (aka Hollywood+) decoder card.// 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 2 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, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA//------------------------------------------------------------------------------#include <cstdio>#include <inttypes.h>//------------------------------------------------------------------------------/** * Class to facilitate the writing of certain data types into an stdio * FILE. */class FileWriter{protected: /** * The file to read from. */ FILE* file;public: /** * Construct the reader with the given file. */ FileWriter(FILE* file); /** * Write out an 8-bit unsigned value. */ bool write(uint8_t x); /** * Write out an 8-bit unsigned value. */ bool write8(unsigned x); /** * Write out an 8-bit signed value. */ bool write(int8_t x); /** * Write out an 8-bit signed value. */ bool writeS8(int x); /** * Write out a 16-bit unsigned value. */ bool write(uint16_t x); /** * Write out an 16-bit unsigned value. */ bool write16(unsigned x); /** * Write out a 32-bit unsigned value. */ bool write(uint32_t x); /** * Write out a 32-bit unsigned value. */ bool write32(unsigned x); /** * Write out a 64-bit unsigned value. */ bool write(uint64_t x); /** * Write out a 64-bit unsigned value. */ bool write64(unsigned long long x); /** * Write out an array of bytes. */ bool write(const void* buffer, size_t length);};//------------------------------------------------------------------------------// Inline definitions//------------------------------------------------------------------------------inline bool FileWriter::write8(unsigned x){ return write( static_cast<uint8_t>(x) );}//------------------------------------------------------------------------------inline bool FileWriter::writeS8(int x){ return write( static_cast<int8_t>(x) );}//------------------------------------------------------------------------------inline bool FileWriter::write16(unsigned x){ return write( static_cast<uint16_t>(x) );}//------------------------------------------------------------------------------inline bool FileWriter::write32(unsigned x){ return write( static_cast<uint32_t>(x) );}//------------------------------------------------------------------------------inline bool FileWriter::write64(unsigned long long x){ return write( static_cast<uint64_t>(x) );}//------------------------------------------------------------------------------// Local variables:// mode: c++// End:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -