Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

Writer.h

Go to the documentation of this file.
00001 //------------------------------------------------------------------------------
00002 // Lamp : Open source game middleware
00003 // Copyright (C) 2004  Junpei Ohtani ( Email : junpee@users.sourceforge.jp )
00004 //
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 //------------------------------------------------------------------------------
00019 
00020 /** @file
00021  * ライタヘッダ
00022  * @author Junpee
00023  */
00024 
00025 #ifndef WRITER_H_
00026 #define WRITER_H_
00027 
00028 #include <Core/InputOutput/OutputStream.h>
00029 
00030 namespace Lamp{
00031 
00032 //------------------------------------------------------------------------------
00033 /**
00034  * ライタ
00035  *
00036  * データ書き出しのインターフェース
00037  */
00038 class Writer{
00039 public:
00040     /**
00041      * バイトデータの書き出し
00042      * @param data 書き出すバイトデータ
00043      * @param size 書き出すサイズ
00044      */
00045     void writeBytes(const void* data, int size){
00046         Assert(stream_ != NULL);
00047         stream_->writeBytes(data, size);
00048     }
00049 
00050     /**
00051      * サイズの取得
00052      * @return 書き込んだバイト数
00053      */
00054     int getSize(){
00055         Assert(stream_ != NULL);
00056         return stream_->getSize();
00057     }
00058 
00059     /**
00060      * スキップ
00061      *
00062      * 指定されたバイト数、0を書き出します。
00063      * @param size 0を書き出すバイト数
00064      */
00065     void skip(int size){
00066         Assert(stream_ != NULL);
00067         stream_->skip(size);
00068     }
00069 
00070     /**
00071      * アライメントを取る
00072      *
00073      * 指定されたバイト数のアライメントまで0を書き出します。
00074      * @param size アライメントをとるバイト数
00075      * @return 0を書き出したバイト数
00076      */
00077     int align(int size){
00078         Assert(stream_ != NULL);
00079         return stream_->align(size);
00080     }
00081 
00082     /**
00083      * フラッシュ
00084      *
00085      * ストリームをフラッシュします。
00086      */
00087     void flush(){
00088         Assert(stream_ != NULL);
00089         stream_->flush();
00090     }
00091 
00092     /**
00093      * 書き込み位置の取得
00094      * @return 書き込み位置
00095      */
00096     int getPosition(){
00097         Assert(stream_ != NULL);
00098         return stream_->getPosition();
00099     }
00100 
00101     /**
00102      * 書き込み位置の設定
00103      *
00104      * 指定された位置に書き込み位置を変更します。
00105      * @param position 書き込み位置
00106      */
00107     void setPosition(int position){
00108         Assert(stream_ != NULL);
00109         stream_->setPosition(position);
00110     }
00111 
00112 protected:
00113     /**
00114      * コンストラクタ
00115      */
00116     Writer(){ stream_ = NULL; }
00117 
00118     /**
00119      * デストラクタ
00120      */
00121     virtual ~Writer(){
00122         Assert(stream_ != NULL);
00123         delete stream_;
00124         stream_ = NULL;
00125     }
00126 
00127     /// 出力ストリーム
00128     OutputStream* stream_;
00129 
00130 private:
00131     // コピーコンストラクタの隠蔽
00132     Writer(const Writer& copy);
00133 
00134     // 代入コピーの隠蔽
00135     void operator =(const Writer& copy);
00136 
00137 };
00138 
00139 //------------------------------------------------------------------------------
00140 } // End of namespace Lamp
00141 #endif // End of WRITER_H_
00142 //------------------------------------------------------------------------------

Generated on Wed Mar 16 10:29:38 2005 for Lamp by doxygen 1.3.2