Browse Subversion Repository
Contents of /SocketX/SocketHelper.cpp
Parent Directory
| Revision Log
Revision 16 -
( show annotations)
( download)
( as text)
Mon Jun 28 05:40:57 2010 UTC
(13 years, 8 months ago)
by sho1get
File MIME type: text/x-c++src
File size: 997 byte(s)
Update_20100628
| 1 |
#pragma once |
| 2 |
|
| 3 |
#include "stdafx.h" |
| 4 |
#include "SocketX.h" |
| 5 |
|
| 6 |
////////////////////////////////////////////////////////////////////////// |
| 7 |
|
| 8 |
CSocketHelper::CSocketHelper() |
| 9 |
{ |
| 10 |
} |
| 11 |
|
| 12 |
CSocketHelper::~CSocketHelper() |
| 13 |
{ |
| 14 |
} |
| 15 |
|
| 16 |
void CSocketHelper::ByteArrayToString(CString &dst, const CByteArray &src) |
| 17 |
{ |
| 18 |
dst.SetString(reinterpret_cast<LPTSTR>(const_cast<LPBYTE>(src.GetData())), src.GetSize() / sizeof(TCHAR)); |
| 19 |
} |
| 20 |
|
| 21 |
void CSocketHelper::StringToByteArray(CByteArray &dst, const CString &src) |
| 22 |
{ |
| 23 |
CString cs = src; |
| 24 |
LPBYTE lpData; |
| 25 |
|
| 26 |
lpData = reinterpret_cast<LPBYTE>(static_cast<LPTSTR>(cs.GetBuffer())); |
| 27 |
dst.SetSize(cs.GetLength() * sizeof(TCHAR)); |
| 28 |
dst.FreeExtra(); |
| 29 |
CopyMemory(dst.GetData(), lpData, dst.GetSize()); |
| 30 |
cs.ReleaseBuffer(); |
| 31 |
} |
| |
|