virtual bool SetUp(MkDataNode& sharingNode) { // [ data 형태 정의 ] //------------------------------------------------------------------------------------------------// // int a; // float b; // MkVec3 c; // wchar_t d[64]; //------------------------------------------------------------------------------------------------// // srcArray 생성 MkInterfaceForDataWriting dwInterface; dwInterface.SetInputSize(ePDT_Int, SIZE_COUNT); dwInterface.SetInputSize(ePDT_Float, SIZE_COUNT); dwInterface.SetInputSize(ePDT_Vec3, SIZE_COUNT); dwInterface.SetInputSize(ePDT_Str, SIZE_COUNT); dwInterface.UpdateInputSize(); for (int i=0; i<SIZE_COUNT; ++i) { float f = static_cast<float>(i); dwInterface.Write(static_cast<int>(i)); dwInterface.Write(static_cast<float>(f * -10.f)); dwInterface.Write(MkVec3(f, f * -2.f, f * 3.f)); dwInterface.Write(MkStr(L"잘생겨서 죄송요~")); } MkByteArray srcArray; dwInterface.Flush(srcArray); dwInterface.Clear(); // srcArray -> 파일로 출력 MkInterfaceForFileWriting fwInterface; fwInterface.SetUp(L"test.data", true, true); fwInterface.Write(srcArray, MkArraySection(0)); fwInterface.Clear(); srcArray.Clear(); // 파일을 destBuffer에 읽음 MkByteArray destBuffer; MkInterfaceForFileReading frInterface; frInterface.SetUp(L"test.data"); frInterface.Read(destBuffer, MkArraySection(0)); frInterface.Clear(); MK_DEV_PANEL.MsgToLog(MkStr::EMPTY); // 빈 칸 하나 넣고, // 읽어들인 결과 출력. 첫번째와 마지막 unit 대상 MkInterfaceForDataReading drInterface; drInterface.SetUp(destBuffer, 0); for (int i=0; i<SIZE_COUNT; ++i) { int a = 0; drInterface.Read(a); float b = 0.f; drInterface.Read(b); MkVec3 c = MkVec3::Zero; drInterface.Read(c); MkStr d; drInterface.Read(d); if (i == 0) { MK_DEV_PANEL.MsgToLog(L"[ First unit ]"); MK_DEV_PANEL.MsgToLog(L" a : " + MkStr(a)); MK_DEV_PANEL.MsgToLog(L" b : " + MkStr(b)); MK_DEV_PANEL.MsgToLog(L" c : " + MkStr(c)); MK_DEV_PANEL.MsgToLog(L" d : " + MkStr(d)); } else if (i == (SIZE_COUNT - 1)) { MK_DEV_PANEL.MsgToLog(L"[ Last unit ]"); MK_DEV_PANEL.MsgToLog(L" a : " + MkStr(a)); MK_DEV_PANEL.MsgToLog(L" b : " + MkStr(b)); MK_DEV_PANEL.MsgToLog(L" c : " + MkStr(c)); MK_DEV_PANEL.MsgToLog(L" d : " + MkStr(d)); } } destBuffer.Clear(); // 출력 폴더 열기 MkPathName::GetRootDirectory().OpenDirectoryInExplorer(); return true; }
// vorbis call back size_t _read_func(void *ptr, size_t size, size_t nmemb, void *datasource) { MkInterfaceForDataReading* drInterface = reinterpret_cast<MkInterfaceForDataReading*>(datasource); size_t copySize = GetMin<size_t>(size * nmemb, drInterface->GetEndPosition() - drInterface->GetCurrentPosition()); return drInterface->Read(reinterpret_cast<unsigned char*>(ptr), copySize) ? copySize : 0; }