⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 writer.h

📁 Linux下比较早的基于命令行的DVD播放器
💻 H
字号:
//// Copyright (c) 2003 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#ifndef DXR3PLAYER_IFODUMP_WRITER_H#define DXR3PLAYER_IFODUMP_WRITER_H//------------------------------------------------------------------------------#include "dvd/DVDDump.h"#include "util/FileWriter.h"extern "C" {#include <libmpdvdkit/ifo_types.h>}//------------------------------------------------------------------------------namespace ifodump {//------------------------------------------------------------------------------/** * Base class for different writers. */template <class Leaf>class Writer : public FileWriter{protected:    /**     * The current dump version.     */    unsigned version;public:    /**     * Construct the writer.     */    Writer(FILE* file);    /**     * Write a pointer to a given structure. A byte of 0 is written,     * if the pointer is 0. A byte of 1, followed by the pointed     * structure is written if the pointer is valid.     */    template <typename T>    void writePointer(const T* ptr);    /**     * Write an array's size and the array itself. If the array     * pointer is 0, a 0 size is written as well.     */    template <typename T>    void writeArray(uint32_t size, const T* array);    /**     * Write a fixed array.      */    template <typename T>    void writeFixedArray(size_t size, const T* array);    /**     * Write an array the size of which is determined by a "last byte"     * member.      */    template <typename T>    void writeLastArray(uint32_t lastByte, const T* array);    /**     * Write a VM command.     */    void write(const vm_cmd_t& cmd);    /**     * Write a user operations structure.     */    void write(const user_ops_t& userOperations);};//------------------------------------------------------------------------------// Inline and template definitions//------------------------------------------------------------------------------template <class Leaf>inline Writer<Leaf>::Writer(FILE* file) :    FileWriter(file),    version(dvd::DVDDump::currentVersion){}//------------------------------------------------------------------------------template <class Leaf>template <typename T>void Writer<Leaf>::writePointer(const T* ptr){    if (ptr==0) FileWriter::write( (uint8_t)0 );    else {        FileWriter::write( (uint8_t)1 );        static_cast<Leaf*>(this)->write(*ptr);    }}//------------------------------------------------------------------------------template <class Leaf>template <typename T>void Writer<Leaf>::writeArray(uint32_t size, const T* array){    if (array==0) {        size = 0;    }    FileWriter::write(size);        for(size_t i = 0; i<size; ++i) {        static_cast<Leaf*>(this)->write(array[i]);    }}//------------------------------------------------------------------------------template <class Leaf>template <typename T>void Writer<Leaf>::writeFixedArray(size_t size, const T* array){    size_t numEntries = size / sizeof(T);    for(size_t i = 0; i<numEntries; ++i) {        static_cast<Leaf*>(this)->write(array[i]);    }}//------------------------------------------------------------------------------template <class Leaf>template <typename T>inline void Writer<Leaf>::writeLastArray(uint32_t lastByte, const T* array){    FileWriter::write(lastByte);    writeFixedArray(lastByte, array);}//------------------------------------------------------------------------------template <class Leaf>inline void Writer<Leaf>::write(const vm_cmd_t& cmd){    FileWriter::write(cmd.bytes, sizeof(cmd.bytes));}//------------------------------------------------------------------------------template <class Leaf>inline void Writer<Leaf>::write(const user_ops_t& userOperations){    FileWriter::write(&userOperations, sizeof(userOperations));}//------------------------------------------------------------------------------} /* namespace ifodump *///------------------------------------------------------------------------------#endif // IFODUMP_WRITER_H// Local variables:// mode: c++// End:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -