メインページ | アルファベット順一覧 | 構成 | ファイル一覧 | 構成メンバ | ファイルメンバ | 関連ページ

# dkcMemoryStream.h

説明を見る。

    00001
    00013 #ifndef DKUTIL_C_MEMORYSTREAM_H
    00014 #define DKUTIL_C_MEMORYSTREAM_H
    00015
    00016
    00017 #include "dkcOSIndependent.h"
    00018
    00019 #include "dkcDefined.h"
    00020 #include "dkcBuffer.h"
    00021
    00026 typedef struct dkc_MemoryStream{
    00028     BYTE *mBuffer;
    00030     size_t mSize;
    00032     size_t mNowOffset;
    00033
    00034 }DKC_MEMORYSTREAM;
    00035
    00036
    00037
    00038
    00039
    00040 enum edkcMemoryStream{
    00042     edkcMemoryStreamSeekCurrent = edkcSeekCurrent,
    00044     edkcMemoryStreamSeekEnd = edkcSeekEnd,
    00046     edkcMemoryStreamSeekSet = edkcSeekSet,
    00047
    00048
    00049 };
    00050
    00051
    00052
    00062
    00063 DKC_EXTERN DKC_MEMORYSTREAM * WINAPI dkcAllocMemoryStream(size_t size);
    00064
    00065
    00069
    00070 DKC_EXTERN int WINAPI dkcFreeMemoryStream(DKC_MEMORYSTREAM **ptr);
    00071
    00072
    00074 DKC_EXTERN int WINAPI dkcMemoryStreamSeek(DKC_MEMORYSTREAM *ptr,int offset,int origin);
    00075
    00077 DKC_EXTERN size_t WINAPI dkcMemoryStreamGetSeekPoint(DKC_MEMORYSTREAM *ptr);
    00078
    00079 #define dkcMemoryStreamTell(tt) dkcMemoryStreamGetSeekPoint(tt)
    00080
    00087
    00088 DKC_EXTERN int WINAPI dkcMemoryStreamRead(DKC_MEMORYSTREAM *ptr,void *buffer,size_t size,size_t *readsize);
    00095
    00096 DKC_EXTERN int WINAPI dkcMemoryStreamWrite(DKC_MEMORYSTREAM *ptr,const void *buffer,size_t size);
    00097
    00099 DKC_EXTERN int WINAPI dkcMemoryStreamDynamicWrite(DKC_MEMORYSTREAM *ptr,const void *buffer,size_t size);
    00100
    00102 DKC_EXTERN int WINAPI dkcMemoryStreamResize(DKC_MEMORYSTREAM *ptr,size_t want_size);
    00104 DKC_EXTERN size_t WINAPI dkcMemoryStreamNowOffset(DKC_MEMORYSTREAM *p);
    00106 DKC_EXTERN BYTE *WINAPI dkcMemoryStreamPointer(DKC_MEMORYSTREAM *p);
    00107
    00108
    00109
    00111 DKC_EXTERN int WINAPI dkcMemoryStreamClear(DKC_MEMORYSTREAM *ptr);
    00112
    00113
    00120 DKC_EXTERN DKC_MEMORYSTREAM * WINAPI dkcAllocMemoryStreamCopy(const DKC_MEMORYSTREAM *ptr);
    00121
    00122
    00123 //DKC_EXTERN int WINAPI dkcMemoryStreamPushBack(DKC_MEMORYSTREAM *p,const BYTE *buff,size_t size);
    00124
    00126 #define dkcMemoryStreamPushBackMacro(type,p,x) {\
    00127     *((type *)&( (p)->mBuff[(p)->mNowOffset])) = (type)x;(p)->mNowOffset += sizeof(type);\
    00128 }
    00129
    00130 #define dkcMemoryStreamIsEnd(p) ( (p)->mNowOffset >= (p)->mSize )
    00131
    00132 DKC_EXTERN int WINAPI dkcMemoryStreamPopBack(DKC_MEMORYSTREAM *p,size_t size);
    00133
    00134 //**********************************************************
    00135 //memory stream adapter
    00136
    00137 #if 0
    00138 typedef struct dkc_MemoryStreamAdapter{
    00139     BYTE *mBuffer;
    00140     size_t mSize;
    00141     size_t mNowOffset;
    00142 }DKC_MEMORYSTREAM_ADAPTER;
    00143 #else
    00144
    00145 typedef DKC_MEMORYSTREAM DKC_MEMORYSTREAM_ADAPTER;
    00146 #endif
    00147
    00148 DKC_EXTERN void WINAPI dkcMemoryStreamAdapterInit(DKC_MEMORYSTREAM_ADAPTER *p,BYTE *buff,size_t size);
    00149
    00150 DKC_EXTERN DKC_MEMORYSTREAM_ADAPTER *WINAPI dkcAllocMemoryStreamAdapter(BYTE *buff,size_t size);
    00151
    00152 DKC_EXTERN int WINAPI dkcFreeMemoryStreamAdapter(DKC_MEMORYSTREAM_ADAPTER **);
    00153
    00154 DKC_EXTERN DKC_MEMORYSTREAM_ADAPTER *dkcAllocMemoryStreamAdapterCopy(DKC_MEMORYSTREAM_ADAPTER *);
    00155
    00156
    00157 #define dkcMemoryStreamAdapterWrite(a,b,c) dkcMemoryStreamWrite(a,b,c)
    00158 #define dkcMemoryStreamAdapterRead(a,b,c,d) dkcMemoryStreamRead(a,b,c,d)
    00159 #define dkcMemroyStreamAdapterSeek(a,b,c) dkcMemoryStreamSeek(a,b,c)
    00160 #define dkcMemoryStreamAdapterTell(a) dkcMemoryStreamTell(a)
    00161 #define dkcMemoryStreamAdapterClear(a) dkcMemoryStreamClear(a)
    00162 /*
    00163 DKC_EXTERN BYTE *WINAPI dkcMemoryStreamAdapterPointer(DKC_MEMORYSTREAM_ADAPTER *p);
    00164
    00165 DKC_EXTERN size_t WINAPI dkcMemoryStreamAdapterSize(DKC_MEMORYSTREAM_ADAPTER *p);
    00166
    00167 DKC_EXTERN int WINAPI dkcMemoryStreamAdapterSetOffset(DKC_MEMORYSTREAM_ADAPTER *ptr,size_t offset);
    00168
    00169 DKC_EXTERN size_t WINAPI dkcMemoryStreamAdapterGetOffset(DKC_MEMORYSTREAM_ADAPTER *p);
    00170
    00171 DKC_EXTERN int WINAPI dkcMemoryStreamAdapterRead(DKC_MEMORYSTREAM_ADAPTER *p,void *buff,size_t buffsize,size_t *readsize);
    00172
    00173
    00175 #define dkcMemoryStreamAdapterWrite(p,buff,write_size) dkcMemoryStreamAdapterPushBack(p,buff,write_size)
    00176
    00177 DKC_EXTERN int WINAPI dkcMemoryStreamAdapterGetChar(DKC_MEMORYSTREAM_ADAPTER *p,BYTE *t);
    00178 */
    00179 //**********************************************************
    00180 //stream generic macro
    00181 /*
    00183 #define dkcmMemoryStreamDump(ptr,filename,buffer_all) {\
    00184     if(buffer_all){\
    00185         dkcSaveBinary(ptr->mBuffer,ptr->mSize,filename);\
    00186     }else{\
    00187         dkcSaveBinary(ptr->mBuffer,ptr->mNowOffset,filename);\
    00188     }\
    00189 }
    00190 */
    00191 enum{
    00192     edkcDumpRegistBufferAll = 0,
    00193     edkcDumpNowOffset = 1,
    00194 };
    00195 DKC_EXTERN int WINAPI dkcMemoryStreamDump(DKC_MEMORYSTREAM *ptr,const char *filename,UINT flag);
    00196
    00198 DKC_EXTERN int WINAPI dkcMemoryStreamWriteToMemory(const DKC_MEMORYSTREAM *ptr,void *buffer,size_t buffsize,UINT flag);
    00200 DKC_EXTERN int WINAPI dkcMemoryStreamLoadFromMemory( DKC_MEMORYSTREAM *ptr,const void *buffer,size_t buffsize);
    00202 DKC_EXTERN int WINAPI dkcMemoryStreamLoadFromFile(DKC_MEMORYSTREAM *ptr,const char *filename,size_t permit_size,UINT flag);
    00203
    00204 DKC_EXTERN int WINAPI dkcMemoryStreamGet8(DKC_MEMORYSTREAM *ptr,BYTE *t);
    00205 DKC_EXTERN int WINAPI dkcMemoryStreamPut8(DKC_MEMORYSTREAM *Ptr,BYTE t);
    00206
    00207
    00208 #endif