Subversion Repositories WoWGM

Rev

Rev 31 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#ifndef  _CDATASTORE_H_
#define  _CDATASTORE_H_


/****************************************************************************
*
*         CDataStore class
*
***/

class CDataStore {

        private:

                //=======================================================================
                virtual void vfptr() {};  // To create the VTable
                char*        m_data;      // Buffer
                unsigned int m_base;      // Buffer index base
                unsigned int m_alloc;     // Number of memory-allocated buffer bytes
                unsigned int m_size;      // Size of buffer
                unsigned int m_read;      // Read bytes

                //=======================================================================
                void Initialize (CDataStore *pData);

                //=======================================================================
                void Destroy (CDataStore *pData);

                
        public:

                //=======================================================================
                CDataStore ();

                //=======================================================================
                ~CDataStore ();

                //=======================================================================
                inline bool IsRead () {
                        // Return true if the data was read in its entirety
                        return m_size==m_read;
                }

                //=======================================================================
                inline bool IsFinal () {
                        // Return true if the data is finalized and ready for sending
                        return m_read!=-1;
                }

                //=======================================================================
                CDataStore* Reset ();

                //=======================================================================
                inline void Finalize () { m_read = 0; }

                //=======================================================================
                CDataStore& Set (DWORD pos, CHAR bytes);

                //=======================================================================
                CDataStore& Set (DWORD pos, UCHAR bytes);

                //=======================================================================
                CDataStore& Set (DWORD pos, SHORT bytes);

                //=======================================================================
                CDataStore& Set (DWORD pos, USHORT bytes);

                //=======================================================================
                CDataStore& Set (DWORD pos, INT bytes);

                //=======================================================================
                CDataStore& Set (DWORD pos, UINT bytes);

                //=======================================================================
                CDataStore& Set (DWORD pos, LONG bytes);

                //=======================================================================
                CDataStore& Set (DWORD pos, ULONG bytes);

                //=======================================================================
                CDataStore& Set (DWORD pos, INT64 bytes);

                //=======================================================================
                CDataStore& Set (DWORD pos, UINT64 bytes);

                //=======================================================================
                CDataStore& Set (DWORD pos, float bytes);

                //=======================================================================
                CDataStore& Put (CHAR val);

                //=======================================================================
                CDataStore& Put (UCHAR val);

                //=======================================================================
                CDataStore& Put (SHORT val);

                //=======================================================================
                CDataStore& Put (USHORT val);

                //=======================================================================
                CDataStore& Put (INT val);

                //=======================================================================
                CDataStore& Put (UINT val);

                //=======================================================================
                CDataStore& Put (LONG val);

                //=======================================================================
                CDataStore& Put (ULONG val);

                //=======================================================================
                CDataStore& Put (INT64 val);

                //=======================================================================
                CDataStore& Put (UINT64 val);

                //=======================================================================
                CDataStore& Put (float val);

                //=======================================================================
                CDataStore& PutString (LPCSTR pval);

                //=======================================================================
                CDataStore& PutArray (UCHAR CONST* pval, DWORD bytes);

                //=======================================================================
                CDataStore& PutArray (USHORT CONST* pval, DWORD bytes);

                //=======================================================================
                CDataStore& PutArray (ULONG CONST* pval, DWORD bytes);

                //=======================================================================
                CDataStore& PutArray (UINT64 CONST* pval, DWORD bytes);

                //=======================================================================
                CDataStore& PutArray (float const* pval, DWORD bytes);

                //=======================================================================
                CDataStore& PutData (LPCVOID pval, DWORD bytes);
                
                //=======================================================================
                CDataStore& Get (CHAR& pval);

                //=======================================================================
                CDataStore& Get (UCHAR& pval);

                //=======================================================================
                CDataStore& Get (SHORT& pval);

                //=======================================================================
                CDataStore& Get (USHORT& pval);

                //=======================================================================
                CDataStore& Get (INT& pval);

                //=======================================================================
                CDataStore& Get (UINT& pval);

                //=======================================================================
                CDataStore& Get (LONG& pval);

                //=======================================================================
                CDataStore& Get (ULONG& pval);

                //=======================================================================
                CDataStore& Get (INT64& pval);

                //=======================================================================
                CDataStore& Get (UINT64& pval);

                //=======================================================================
                CDataStore& Get (float& pval);

                //=======================================================================
                CDataStore& GetString (LPSTR pval, DWORD maxChars);

                //=======================================================================
                CDataStore& GetString (LPWSTR pval, DWORD maxChars);

                //=======================================================================
                CDataStore& GetArray (UCHAR* pval, DWORD count);

                //=======================================================================
                CDataStore& GetArray (USHORT* pval, DWORD count);

                //=======================================================================
                CDataStore& GetArray (ULONG* pval, DWORD count);

                //=======================================================================
                CDataStore& GetArray (UINT64* pval, DWORD count);

                //=======================================================================
                CDataStore& GetArray (float* pval, DWORD count);

                //=======================================================================
                virtual void GetBufferParams (LPCVOID*  dataPtr,
                                  UINT*     sizePtr,
                                  UINT*     allocPtr) const;

                //=======================================================================
                void DetachBuffer (PVOID* dataPtr, UINT* sizePtr, UINT* allocPtr);

};

#endif// _CDATASTORE_H_