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 #include "LampBasic.h" 00026 #include "Core/InputOutput/BinaryWriter.h" 00027 00028 namespace Lamp{ 00029 00030 //------------------------------------------------------------------------------ 00031 // コンストラクタ 00032 BinaryWriter::BinaryWriter() : Writer(){ 00033 } 00034 //------------------------------------------------------------------------------ 00035 // デストラクタ 00036 BinaryWriter::~BinaryWriter(){ 00037 } 00038 //------------------------------------------------------------------------------ 00039 // boolの書き出し 00040 void BinaryWriter::writeBool(bool value){ 00041 writeBytes(&value, sizeof(bool)); 00042 } 00043 //------------------------------------------------------------------------------ 00044 // charの書き出し 00045 void BinaryWriter::writeChar(char value){ 00046 writeBytes(&value, sizeof(char)); 00047 } 00048 //------------------------------------------------------------------------------ 00049 // u_charの書き出し 00050 void BinaryWriter::writeUChar(u_char value){ 00051 writeBytes(&value, sizeof(u_char)); 00052 } 00053 //------------------------------------------------------------------------------ 00054 // shortの書き出し 00055 void BinaryWriter::writeShort(short value){ 00056 writeBytes(&value, sizeof(short)); 00057 } 00058 //------------------------------------------------------------------------------ 00059 // u_shortの書き出し 00060 void BinaryWriter::writeUShort(u_short value){ 00061 writeBytes(&value, sizeof(u_short)); 00062 } 00063 //------------------------------------------------------------------------------ 00064 // intの書き出し 00065 void BinaryWriter::writeInt(int value){ 00066 writeBytes(&value, sizeof(int)); 00067 } 00068 //------------------------------------------------------------------------------ 00069 // u_intの書き出し 00070 void BinaryWriter::writeUInt(u_int value){ 00071 writeBytes(&value, sizeof(u_int)); 00072 } 00073 //------------------------------------------------------------------------------ 00074 // floatの書き出し 00075 void BinaryWriter::writeFloat(float value){ 00076 writeBytes(&value, sizeof(float)); 00077 } 00078 //------------------------------------------------------------------------------ 00079 // doubleの書き出し 00080 void BinaryWriter::writeDouble(double value){ 00081 writeBytes(&value, sizeof(double)); 00082 } 00083 //------------------------------------------------------------------------------ 00084 // Stringの書き出し 00085 void BinaryWriter::writeString(const String& string){ 00086 int size = string.getSize(); 00087 writeBytes(&size, sizeof(int)); 00088 writeBytes(string.getBytes(), size); 00089 } 00090 //------------------------------------------------------------------------------ 00091 // 配列の書き出し 00092 void BinaryWriter::writeArray( 00093 const void* array, int elementSize, int elementCount){ 00094 writeBytes(array, elementSize * elementCount); 00095 } 00096 //------------------------------------------------------------------------------ 00097 } // End of namespace Lamp 00098 //------------------------------------------------------------------------------