当前位置: 首页>>代码示例>>C++>>正文


C++ CArchive::GetFile方法代码示例

本文整理汇总了C++中CArchive::GetFile方法的典型用法代码示例。如果您正苦于以下问题:C++ CArchive::GetFile方法的具体用法?C++ CArchive::GetFile怎么用?C++ CArchive::GetFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CArchive的用法示例。


在下文中一共展示了CArchive::GetFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ParseFile

void CFormulaParser::ParseFile(CArchive& formula_file) {
  InitNewParse();
  p_function_collection->DeleteAll(false, true);
  p_function_collection->SetTitle(formula_file.GetFile()->GetFileName());
  p_function_collection->SetPath(formula_file.GetFile()->GetFilePath());
  while (true) {
    int starting_line = _formula_file_splitter.starting_line_of_current_function();
    _formula_file_splitter.ScanForNextFunctionOrList(formula_file);
    CString function_header = _formula_file_splitter.GetFunctionHeader(); 
    if (function_header.GetLength() <= 0) {
	    write_log(preferences.debug_parser(), 
	      "[FormulaParser] Empty function received. Parse finished.\n");
	    goto ExitLoop;
    }
    if (!VerifyFunctionHeader(function_header)) {
      // Skip this function
      continue;
    }
    ParseSingleFormula(_formula_file_splitter.GetFunctionText(), starting_line);
  }
ExitLoop:
  FinishParse();
  // Dump function collection to log
  write_log(preferences.debug_formula() || preferences.debug_parser(),
    "[CFormulaParser] ParseFile() done: %s\n",
    formula_file.GetFile()->GetFileName());
  p_function_collection->Dump();
}
开发者ID:sushiomsky,项目名称:openholdembot,代码行数:28,代码来源:CFormulaParser.cpp

示例2: ReadFormula

void COpenHoldemDoc::ReadFormula(CArchive& ar) 
{
	// Clear everything
	p_formula->ClearFormula();

	// There are two types of formulas
	//   * ohf 
	//   * whf and optional whx
	// In the latter case we have to read both files. 
	p_formula->ReadFormulaFile(ar, true);

	CFile *cf_whf = ar.GetFile();  
	CString CSpath = cf_whf->GetFilePath(); 

	if (IsWinHoldemFormat(CSpath))
		{
			CFile *cf_whf = ar.GetFile();
			CFile cf_whx; 
			CString CSpath = cf_whf->GetFilePath();
			CSpath.Replace(".whf", ".whx");

			if (cf_whx.Open(CSpath, CFile::modeNoTruncate | CFile::modeRead| CFile::shareDenyWrite)) 
			{ 
				CArchive ar_whx(&cf_whx, CArchive::load);   
				// Read whx file, too. //???	
				p_formula->ReadFormulaFile(ar_whx, false);	
			}
	}

	// Check and add missing...
	p_formula->CheckForDefaultFormulaEntries();
}
开发者ID:buranela,项目名称:OpenHoldemV12,代码行数:32,代码来源:OpenHoldemDoc.cpp

示例3: Serialize

/*************************************************************************
 *
 * \函数名称:
 *   Serialize()
 *
 * \输入参数:
 *   CArchive&	ar			- 指向应用程序归档对象
 *
 * \返回值:
 *   无
 *
 * \说明:
 *   该函数进行串行化过程,将CDib数据进行读入或者写出
 *
 ************************************************************************
 */
void CDib::Serialize(CArchive& ar)
{
	DWORD dwPos;

	// 获得此归档文件的CFile对象指针
	dwPos = ar.GetFile()->GetPosition();
	TRACE("CDib::Serialize -- pos = %d\n", dwPos);

	// 从归档文件缓冲区中冲掉未写入数据
	ar.Flush();

	// 重新获得此归档文件的CFile对象指针
	dwPos = ar.GetFile()->GetPosition();
	TRACE("CDib::Serialize -- pos = %d\n", dwPos);

	// 确定归档文件是否被存储,是则进行存储	
	if(ar.IsStoring()) {
		Write(ar.GetFile());
	}

	// 否则进行加载
	else {
		Read(ar.GetFile());
	}
}
开发者ID:contarna,项目名称:iRayDetector,代码行数:41,代码来源:cdib.cpp

示例4: Write

void	CDib::Serialize(CArchive&	ar)
{
    ar.Flush();
    if(ar.IsStoring())
        Write(ar.GetFile());
    else
        Read(ar.GetFile());
}
开发者ID:fightx,项目名称:Script.NET,代码行数:8,代码来源:DIB.CPP

示例5: Serialize

void CChordEaseDoc::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
		WriteSongText(*ar.GetFile(), m_SongText);
	}
	else
	{
		ReadSongText(*ar.GetFile(), m_SongText);
	}
}
开发者ID:victimofleisure,项目名称:ChordEase,代码行数:11,代码来源:ChordEaseDoc.cpp

示例6: Serialize

void CDib::Serialize(CArchive& ar)
{
	DWORD dwPos;
	dwPos = ar.GetFile()->GetPosition();
	TRACE(_T("CDib::Serialize -- pos = %d\n"), dwPos);
	ar.Flush();
	dwPos = ar.GetFile()->GetPosition();
	TRACE(_T("CDib::Serialize -- pos = %d\n"), dwPos);
	if(ar.IsStoring()) {
		Write(ar.GetFile());
	}
	else {
		Read(ar.GetFile());
	}
}
开发者ID:jcampos73,项目名称:DraftCable,代码行数:15,代码来源:CDib.cpp

示例7: Serialize

void CMyFirstDocWindowDoc::Serialize(CArchive& ar)
{
	// CEditView contains an edit control which handles all serialization
	if (!m_viewList.IsEmpty())
	{
		reinterpret_cast<CEditView*>(m_viewList.GetHead())->SerializeRaw(ar);
	}
#ifdef SHARED_HANDLERS

	if (m_viewList.IsEmpty() && ar.IsLoading())
	{
		CFile* pFile = ar.GetFile();
		pFile->Seek(0, FILE_BEGIN);
		ULONGLONG nFileSizeBytes = pFile->GetLength();
		ULONGLONG nFileSizeChars = nFileSizeBytes/sizeof(TCHAR);
		LPTSTR lpszText = (LPTSTR)malloc(((size_t)nFileSizeChars + 1) * sizeof(TCHAR));
		if (lpszText != NULL)
		{
			ar.Read(lpszText, (UINT)nFileSizeBytes);
			lpszText[nFileSizeChars] = '\0';
			m_strThumbnailContent = lpszText;
			m_strSearchContent = lpszText;
		}
	}
#endif
}
开发者ID:seanedwards,项目名称:COS-420,代码行数:26,代码来源:MyFirstDocWindowDoc.cpp

示例8: Serialize

void CGelDoc::Serialize(CArchive& ar)
{
	CFile* pFile = ar.GetFile();

	if (ar.IsStoring())
	{
		pFile->Seek(0L, CFile::begin);
		pFile->Write(m_abyTransform, sizeof(m_abyTransform));
	}
	else
	{
		int i;
		for (i = 0; i < 256; i++)
			m_abySelection[i] = 0xFF;
		BYTE byMask = m_pUntransformed->GetPixel(CPoint(0, 0));
		m_abySelection[byMask] = 0x00;

		pFile->Seek(0L, CFile::begin);
		DWORD dwSize = pFile->Read(m_abyTransform, sizeof(m_abyTransform));

		ApplyGel();

		if (sizeof(m_abyTransform) != dwSize)
			AfxThrowArchiveException(CArchiveException::generic);
	}
}
开发者ID:AlleyCat1976,项目名称:Meridian59_103,代码行数:26,代码来源:GelDoc.cpp

示例9: Serialize

void CResourceListDoc::Serialize(CArchive& ar)
{
    if (ar.IsStoring())
    {
        // There is nothing to save.
        int x = 0;
    }
    else
    {
        CFile *pFile = ar.GetFile();

        // Set the current directory, so we know where to look for the resource files.
        // If not, clicking on an item in the recent documents list won't work
        CString path = pFile->GetFilePath();
        path.MakeLower();
        int iFileOffset = path.Find(TEXT("\\resource.map"));
        if (iFileOffset > 0)
        {
            path.SetAt(iFileOffset, 0); // Null terminate it

            // Set this folder as our new game folder
            CResourceMap &map = theApp.GetResourceMap();
            map.SetGameFolder((PCSTR)path);

            theApp.LogInfo(TEXT("Open game: %s"), (PCTSTR)path);

            UpdateAllViews(NULL, VIEWUPDATEHINT_RESOURCEMAPCHANGED, pFile);
        }
        else
        {
            AfxMessageBox(TEXT("SCI game resources must be called resource.map"), MB_OK | MB_ICONEXCLAMATION);
        }
    }
}
开发者ID:OmerMor,项目名称:SciCompanion,代码行数:34,代码来源:ResourceListDoc.cpp

示例10: SerializeRaw

void CEditView::SerializeRaw( CArchive &ar )
/******************************************/
{
    if( ar.IsStoring() ) {
        int     nLength = ::GetWindowTextLength( m_hWnd );
        LPCTSTR lpszBuffer = LockBuffer();
        if( lpszBuffer != NULL ) {
            ar.Write( lpszBuffer, nLength );
        }
    } else {
        CFile *pFile = ar.GetFile();
        ASSERT( pFile != NULL );

        ULONGLONG   nLength = pFile->GetLength();
        LRESULT     lLimit = ::SendMessage( m_hWnd, EM_GETLIMITTEXT, 0, 0L );
        if( nLength > lLimit ) {
            throw new CArchiveException( CArchiveException::badIndex );
        } else if( nLength == 0LL ) {
            ::SetWindowText( m_hWnd, NULL );
        } else {
            LPTSTR lpszBuffer = new TCHAR[nLength + 1];
            ar.Read( lpszBuffer, (UINT)nLength * sizeof( TCHAR ) );
            lpszBuffer[nLength] = _T('\0');
            ::SetWindowText( m_hWnd, lpszBuffer );
        }
    }
}
开发者ID:Ukusbobra,项目名称:open-watcom-v2,代码行数:27,代码来源:editview.cpp

示例11: IsArchiveXML

// returns true if archive turns out to be XML
bool IsArchiveXML (CArchive& ar)
  {

  // auto-detect XML files

  char buf [500],     // should be even number of bytes in case Unicode
       buf2 [500];

  memset (buf, 0, sizeof (buf));
  ar.GetFile ()->Read (buf, sizeof (buf) - 2);   // allow for Unicode 00 00
  ar.GetFile ()->SeekToBegin ();  // back to start for further serialisation

  // look for Unicode (FF FE)
  if ((unsigned char) buf [0] == 0xFF &&
      (unsigned char) buf [1] == 0xFE)
    WideCharToMultiByte (CP_UTF8, 0, (LPCWSTR) &buf [2], -1, buf2, sizeof buf2, NULL, NULL);
  else
    // look for UTF-8 indicator bytes (EF BB BF)
    if ((unsigned char) buf [0] == 0xEF &&
        (unsigned char) buf [1] == 0xBB &&
        (unsigned char) buf [2] == 0xBF)
      strcpy (buf2, &buf [3]);   // skip them
  else 
    strcpy (buf2, buf);

  char * p = buf2;

  // skip leading whitespace
  while (isspace (*p))
    p++;

  // can't see them squeezing much into less than 15 chars
  //  (eg. minimum would be <macros></macros> )
  if (strlen (p) < 15)
    return false;

  for (int i = 0; i < NUMITEMS (sigs); i++)
    if (COMPARE_MEMORY (sigs [i]))
      return true;

  return false;

  } // end of IsArchiveXML
开发者ID:RKelson93,项目名称:mushclient,代码行数:44,代码来源:xml_serialize.cpp

示例12: Serialize

// DIB is stored as a standard Windows bitmap file 
void CDIB::Serialize(CArchive& ar)
{
    ar.Flush();
    CFile *fp = ar.GetFile();

    if (ar.IsStoring()) {
        Save(fp);
    } else {
        Load(fp);
    }
}
开发者ID:BoonieBear,项目名称:7000m,代码行数:12,代码来源:DIB.cpp

示例13: Serialize

void CmdwEditorDoc::Serialize(CArchive& ar)
{
	POSITION pos = this->GetFirstViewPosition();
	CView* cv = NULL;
	CEditView* pEv = NULL;
	
	do {
		cv = this->GetNextView(pos);
		if( cv != NULL && cv->IsKindOf(RUNTIME_CLASS(CEditView))) {
			pEv = (CEditView*)cv;  
			break;
		}
	} while(cv != NULL);

	if(pEv == NULL) return;

	//CString htmlpath;
	CFile *pCF = ar.GetFile();
	//if(pCF != NULL)
	//	htmlpath = pCF->GetFilePath() + _T(".html");

	if (ar.IsStoring())
	{
		// TODO: add storing code here
		/**
			unicode data 修改後儲存時轉換回 utf-8
			再由sundown 轉換成 html,通知 HtmlView 顯示
		*/
		LPCTSTR lpszText = pEv->LockBuffer();
		ASSERT(lpszText != NULL);
		UINT nLen = pEv->GetBufferLength();
		TRY
		{
			//ar.Write(lpszText, nLen*sizeof(TCHAR));
			getEditText(lpszText, nLen);

			pCF->SeekToBegin();
			pCF->Write(mib_utf8->data, mib_utf8->size);

			m_bHtmlExisted = convMd2Html((LPCTSTR)m_htmlPath, m_cssPath);
			this->UpdateAllViews(NULL, (LPARAM)(LPCTSTR)m_htmlPath, NULL);
		}
		CATCH_ALL(e)
		{
			pEv->UnlockBuffer();
			THROW_LAST();
		}
		END_CATCH_ALL

		pEv->UnlockBuffer();
	}
开发者ID:skyblue168,项目名称:winsundown,代码行数:51,代码来源:mdwEditorDoc.cpp

示例14: Serialize

void CKaiDoc::Serialize (CArchive& ar)
{
    CFile * pco_file = ar.GetFile();

    ULONGLONG qwLength = pco_file->GetLength();
    if (qwLength > INT_MAX)
    {
        AfxMessageBox (_T("File too long."), MB_ICONEXCLAMATION);
        return;
    }

    bool b_result = true;
    if (ar.IsStoring())
    {
        b_result = pco_Doc_->b_Store (*pco_file);
        if (b_result)
        {
//            SetModifiedFlag(0);
            v_ClearModified();
            pco_Doc_->b_Imported_ = false;
        }
    }
    else
    {
        pco_Doc_->b_Unrenderable_ = false;

        unsigned int ui_version = 0;
        b_result = pco_Doc_->b_CheckDocFormat (*pco_file, ui_version);
        if (b_result)
        {
            b_result = pco_Doc_->b_Load (*pco_file);
        }
        else
        {
            b_result = pco_Doc_->b_ImportTextFile (*pco_file);
            if (b_result)
            {
//                SetModifiedFlag();
                v_SetModified();
            }
            else
            {
                pco_Doc_->b_Unrenderable_ = true;
            }
        }
        if (!b_result)
        {
            AfxMessageBox (_T("Unable to read this file."), MB_ICONEXCLAMATION);
        }
    }
}
开发者ID:kbogatyrev,项目名称:Kai,代码行数:51,代码来源:KaiDoc.cpp

示例15: Serialize

void CBZDoc::Serialize(CArchive& ar)
{
    MEMORYSTATUS ms;
    GlobalMemoryStatus(&ms);

    CFile *pFile = ar.GetFile();
    ar.Flush();

    if (ar.IsLoading())	{
        // TODO: add loading code here
        m_dwTotal = GetFileLength(pFile);
#ifdef FILE_MAPPING
        if(IsFileMapping()) {
            if(!MapView()) return;
        } else
#endif //FILE_MAPPING
        {
            if(!(m_pData = (LPBYTE)MemAlloc(m_dwTotal))) {
                AfxMessageBox(IDS_ERR_MALLOC);
                return;
            }
            DWORD len = pFile->Read(m_pData, m_dwTotal);
            if(len < m_dwTotal) {
                AfxMessageBox(IDS_ERR_READFILE);
                MemFree(m_pData);	// ###1.61
                m_pData = NULL;
                return;
            }
            m_bReadOnly = options.bReadOnlyOpen;
        }
    } else {
        // TODO: add storing code here
#ifdef FILE_MAPPING
        if(IsFileMapping()) {
            BOOL bResult = (m_pMapStart) ? ::FlushViewOfFile(m_pMapStart, m_dwMapSize) : ::FlushViewOfFile(m_pData, m_dwTotal);
            if(!bResult) {
                ErrorMessageBox();
            }
        } else
#endif //FILE_MAPPING
            pFile->Write(m_pData, m_dwTotal);
        m_dwUndoSaved = m_dwUndo;		// ###1.54
        TouchDoc();
        /*		if(m_pUndo) {
        			MemFree(m_pUndo);
        			m_pUndo = NULL;
        		}
        */
    }
}
开发者ID:tnzk,项目名称:bz,代码行数:50,代码来源:BZDoc.cpp


注:本文中的CArchive::GetFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。