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

# 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 #define dkcMemoryStreamAdapterWrite(a,b,c) dkcMemoryStreamWrite(a,b,c)
    00155 #define dkcMemoryStreamAdapterRead(a,b,c,d) dkcMemoryStreamRead(a,b,c,d)
    00156 #define dkcMemroyStreamAdapterSeek(a,b,c) dkcMemoryStreamSeek(a,b,c)
    00157 #define dkcMemoryStreamAdapterTell(a) dkcMemoryStreamTell(a)
    00158 #define dkcMemoryStreamAdapterClear(a) dkcMemoryStreamClear(a)
    00159 /*
    00160 DKC_EXTERN BYTE *WINAPI dkcMemoryStreamAdapterPointer(DKC_MEMORYSTREAM_ADAPTER *p);
    00161
    00162 DKC_EXTERN size_t WINAPI dkcMemoryStreamAdapterSize(DKC_MEMORYSTREAM_ADAPTER *p);
    00163
    00164 DKC_EXTERN int WINAPI dkcMemoryStreamAdapterSetOffset(DKC_MEMORYSTREAM_ADAPTER *ptr,size_t offset);
    00165
    00166 DKC_EXTERN size_t WINAPI dkcMemoryStreamAdapterGetOffset(DKC_MEMORYSTREAM_ADAPTER *p);
    00167
    00168 DKC_EXTERN int WINAPI dkcMemoryStreamAdapterRead(DKC_MEMORYSTREAM_ADAPTER *p,void *buff,size_t buffsize,size_t *readsize);
    00169
    00170
    00172 #define dkcMemoryStreamAdapterWrite(p,buff,write_size) dkcMemoryStreamAdapterPushBack(p,buff,write_size)
    00173
    00174 DKC_EXTERN int WINAPI dkcMemoryStreamAdapterGetChar(DKC_MEMORYSTREAM_ADAPTER *p,BYTE *t);
    00175 */
    00176 //**********************************************************
    00177 //stream generic macro
    00178 /*
    00180 #define dkcmMemoryStreamDump(ptr,filename,buffer_all) {\
    00181     if(buffer_all){\
    00182         dkcSaveBinary(ptr->mBuffer,ptr->mSize,filename);\
    00183     }else{\
    00184         dkcSaveBinary(ptr->mBuffer,ptr->mNowOffset,filename);\
    00185     }\
    00186 }
    00187 */
    00188 enum{
    00189     edkcDumpRegistBufferAll = 0,
    00190     edkcDumpNowOffset = 1,
    00191 };
    00192 DKC_EXTERN int WINAPI dkcMemoryStreamDump(DKC_MEMORYSTREAM *ptr,const char *filename,UINT flag);
    00193
    00195 DKC_EXTERN int WINAPI dkcMemoryStreamWriteToMemory(const DKC_MEMORYSTREAM *ptr,void *buffer,size_t buffsize,UINT flag);
    00197 DKC_EXTERN int WINAPI dkcMemoryStreamLoadFromMemory( DKC_MEMORYSTREAM *ptr,const void *buffer,size_t buffsize);
    00199 DKC_EXTERN int WINAPI dkcMemoryStreamLoadFromFile(DKC_MEMORYSTREAM *ptr,const char *filename,size_t permit_size,UINT flag);
    00200
    00201 DKC_EXTERN int WINAPI dkcMemoryStreamGet8(DKC_MEMORYSTREAM *ptr,BYTE *t);
    00202 DKC_EXTERN int WINAPI dkcMemoryStreamPut8(DKC_MEMORYSTREAM *Ptr,BYTE t);
    00203
    00204 #endif