本文整理汇总了C++中CArchive::WriteString方法的典型用法代码示例。如果您正苦于以下问题:C++ CArchive::WriteString方法的具体用法?C++ CArchive::WriteString怎么用?C++ CArchive::WriteString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CArchive
的用法示例。
在下文中一共展示了CArchive::WriteString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteFormula
void CFormula::WriteFormula(CArchive& ar)
{
CString s = "";
char nowtime[26] = {0};
// First write the standard formula functions...
// These are functions and symbols, that
// * are essential to control the behaviour
// of (nearly) every poker bot.
// * configure some very important constants.
//
s.Format("##%s##\r\n\r\n", get_time(nowtime)); ar.WriteString(s);
WriteStandardFunction(ar, "notes");
WriteStandardFunction(ar, "dll");
// ToDo: Check, if that can be done the normal way too?
WriteStandardFunction(ar, "f$prwin_number_of_iterations");
WriteStandardFunction(ar, "f$alli");
WriteStandardFunction(ar, "f$betsize");
WriteStandardFunction(ar, "f$betpot_2_1");
WriteStandardFunction(ar, "f$betpot_1_1");
WriteStandardFunction(ar, "f$betpot_3_4");
WriteStandardFunction(ar, "f$betpot_2_3");
WriteStandardFunction(ar, "f$betpot_1_2");
WriteStandardFunction(ar, "f$betpot_1_3");
WriteStandardFunction(ar, "f$betpot_1_4");
WriteStandardFunction(ar, "f$rais");
WriteStandardFunction(ar, "f$call");
WriteStandardFunction(ar, "f$prefold");
WriteStandardFunction(ar, "f$rebuy");
WriteStandardFunction(ar, "f$delay");
WriteStandardFunction(ar, "f$chat");
WriteStandardFunction(ar, "f$prwin_number_of_opponents");
WriteStandardFunction(ar, "f$sitin");
WriteStandardFunction(ar, "f$sitout");
WriteStandardFunction(ar, "f$leave");
WriteStandardFunction(ar, "f$close");
WriteStandardFunction(ar, "f$test");
WriteStandardFunction(ar, "f$debug");
// handlists for both ohf and old whf style
for (int i=0; i<(int) _formula.mHandList.GetSize(); i++)
ar.WriteString("##" + _formula.mHandList[i].list + "##\r\n" + _formula.mHandList[i].list_text + "\r\n\r\n");
// User defined functions for new ohf style only.
// We don't ever have to save them, as for a conversion
// we only have to generate an ohf file and (for technical reasons)
// recreate the old whf (which is already open for storing).
//
for (int i=0; i<(int) _formula.mFunction.GetSize(); i++)
{
if (!IsStandardFormula(_formula.mFunction[i].func))
{
ar.WriteString("##" + _formula.mFunction[i].func + "##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
}
}
}
示例2: Serialize
void CMarkdownEditorDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
ar.WriteString(Util::ANSIToUTF8(_strText.c_str()).c_str());
// TODO: 在此添加存储代码
}
else
{
CString str;
const int BUF_SIZE = 64*1024;
unsigned char buf[BUF_SIZE + 1];
while(true){
UINT uRead = ar.Read(buf, BUF_SIZE);
buf[uRead] = '\0';
str += (const char*)buf;
if(uRead < BUF_SIZE)
break;
}
_strText = Util::UTF8ToANSI(str);
this->UpdateAllViews(NULL);
// TODO: 在此添加加载代码
}
}
示例3: SaveSettings
void CChildView::SaveSettings(CArchive &ar)
{
ar << m_crBackColor;
ar << m_WndTextColor;
ar << m_crGraphBkClr;
ar << m_crBorderClr;
ar << m_iBorderStyle;
ar << m_iBorderWidth;
if (m_bBorder) ar << 1;
else ar << 0;
if (IsBlackAndWhite()) ar << 1;
else ar << 0;
if(m_WndLogFont.lfCharSet == 0) m_WndLogFont.lfCharSet = DEFAULT_CHARSET;
ar << m_WndLogFont.lfCharSet;
ar << m_WndLogFont.lfClipPrecision;
ar << m_WndLogFont.lfEscapement;
ar << m_WndLogFont.lfHeight;
ar << m_WndLogFont.lfItalic;
ar << m_WndLogFont.lfOrientation;
ar << m_WndLogFont.lfOutPrecision;
ar << m_WndLogFont.lfPitchAndFamily;
ar << m_WndLogFont.lfQuality;
ar << m_WndLogFont.lfStrikeOut;
ar << m_WndLogFont.lfUnderline;
ar << m_WndLogFont.lfWeight;
ar << m_WndLogFont.lfWidth;
CString strong;
strong = m_WndLogFont.lfFaceName;//let MFC do the conversion...
ar << strong.GetLength();
ar.WriteString(strong);
m_DefaultGraph.Serialize(ar);
}
示例4: WriteStandardFunction
void CFormula::WriteStandardFunction(CArchive& ar, CString name)
{
int number_of_functions = (int) _formula.mFunction.GetSize();
for (int i=0; i<number_of_functions; i++)
if (_formula.mFunction[i].func == name)
ar.WriteString("##" + name + "##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
}
示例5: SaveOpenFiles
void CProjectDoc::SaveOpenFiles(CArchive &ar)
// Unlike CWideApp::SaveOpenFiles, this version saves them
// remembers their positions and closes them. It is called
// when the project is being closed.
{
if (theApp.m_pMFW->PrologGet())
{
AfxMessageBox(_T("Let Prolog query finish first (Ctrl-Break will stop it)"));
return;
}
_TCHAR szFormat[] = _T("%u,%u,%d,%d,%d,%d,%d,%d,%d,%d");
_TCHAR szBuffer[sizeof(_T("-32767"))*8 + sizeof(_T("65535"))*2];
POSITION posDoc = theApp.m_dplateEdit->GetFirstDocPosition();
CEditDoc* pEditDoc;
CEditFrame* pEditFr;
WINDOWPLACEMENT wp;
wp.length = sizeof wp;
while(posDoc != NULL)
{
pEditDoc = (CEditDoc*)theApp.m_dplateEdit->GetNextDoc(posDoc);
if (pEditDoc->IsModified())
pEditDoc->DoSave(pEditDoc->GetPathName());
CString pathName = pEditDoc->GetPathName();
if (pathName.IsEmpty()) continue;
pEditFr = pEditDoc->GetEditFrame();
pEditFr->GetWindowPlacement(&wp);
wsprintf(szBuffer, szFormat,
wp.flags, wp.showCmd,
wp.ptMinPosition.x, wp.ptMinPosition.y,
wp.ptMaxPosition.x, wp.ptMaxPosition.y,
wp.rcNormalPosition.left, wp.rcNormalPosition.top,
wp.rcNormalPosition.right, wp.rcNormalPosition.bottom);
ar.WriteString( pathName );
ar.WriteString(_T("="));
ar.WriteString(szBuffer);
ar.WriteString(CRLF);
//pEditFr->SendMessage(WM_CLOSE);
}
}
示例6: Serialize
void RectangleFigure::Serialize(CArchive& ar)
{
if(ar.IsStoring())
{
CString line;
line.Format(_T("%d %d %d %d %d \r\n"), 2, this->topLeftX, this->topLeftY, this->downRightX, this->downRightY);
ar.WriteString(line);
}
}
示例7: SaveObject
void CFunctionCollection::SaveObject(
CArchive &ar,
COHScriptObject *function_or_list) {
CSLock lock(m_critsec);
if (function_or_list == NULL) return;
// Don't save OpenPPL-symbols from the OpenPPL-library
// to user-defined bot-logic files
if (function_or_list->IsOpenPPLSymbol()) return;
ar.WriteString(function_or_list->Serialize());
}
示例8: Save
void CFunctionCollection::Save(CArchive &ar)
{
CSLock lock(m_critsec);
// First write the date
char nowtime[26] = {0};
CString s;
s.Format("##%s##\r\n\r\n", get_time(nowtime));
ar.WriteString(s);
// DLL and notes are a bit special "functions",
// so they get extra treatment.
SaveObject(ar, LookUp("notes"));
SaveObject(ar, LookUp("dll"));
// Then write the standard formula functions...
// These are functions and symbols, that
// * are essential to control the behaviour
// of (nearly) every poker bot.
// * configure some very important constants.
for (int i=k_autoplayer_function_allin;
i<k_number_of_standard_functions;
++i) {
SaveObject(ar, LookUp(k_standard_function_names[i]));
}
// f$test and f$debug are again special
SaveObject(ar, LookUp("f$test"));
SaveObject(ar, LookUp("f$debug"));
// Handlists
COHScriptObject *next_object = GetFirst();
while (next_object != NULL) {
if (next_object->IsList()) {
SaveObject(ar, next_object);
}
next_object = GetNext();
}
// OpenPPL-functions
for (int i=k_betround_preflop; i<=k_betround_river; ++i) {
assert(k_OpenPPL_function_names[i] != "");
SaveObject(ar, LookUp(k_OpenPPL_function_names[i]));
}
// User defined functions
// We already saved the standard-functions
next_object = GetFirst();
while (next_object != NULL) {
if (next_object->IsUserDefinedFunction()) {
SaveObject(ar, next_object);
}
next_object = GetNext();
}
}
示例9: SerializeAlias
void SerializeAlias( CArchive & ar, CAliasArray & aAliases )
{
char szFileMagic[] = "NETTSALIAS";
DWORD dwFileVersion = 0x20040825;
if( ar.IsStoring() )
{
ar.WriteString( szFileMagic );
ar << dwFileVersion;
ar << (int)aAliases.GetSize();
for( int i=0; i<aAliases.GetSize(); i++ )
{
CAlias & a = aAliases.ElementAt(i);
ar << a.m_strName;
ar << a.m_strValue;
}
}
else
{
TCHAR buffer[64];
memset( buffer, 0, sizeof(buffer) );
ar.ReadString( buffer, strlen(szFileMagic) );
if( 0 != strncmp( szFileMagic, buffer, strlen(szFileMagic) ) )
return;
DWORD dwVer;
ar >> dwVer;
if( dwVer > dwFileVersion )
return;
int size;
ar >> size;
if( size < 0 || size > 10000 ) // too big
return;
aAliases.SetSize( 0, size+2 );
for( int i=0; i<size; i++ )
{
CAlias a;
ar >> a.m_strName;
ar >> a.m_strValue;
aAliases.Add( a );
}
}
}
示例10: Serialize
void CIBADoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
CString strTmp;
strTmp = _T("FFFFFFFFFFFF");
//char c1 = 0xFF, c2 = 0xFE;
//ar << c1 << c2 << strTmp;
ar.WriteString(strTmp);
}
else
{
// TODO: add loading code here
}
}
示例11: Serialize
void NNLayer::Serialize(CArchive &ar)
{
VectorNeurons::iterator nit;
VectorWeights::iterator wit;
VectorConnections::iterator cit;
int ii, jj;
if (ar.IsStoring())
{
// TODO: add storing code here
ar.WriteString( label.c_str() );
ar.WriteString( _T("\r\n") ); // ar.ReadString will look for \r\n when loading from the archive
ar << m_Neurons.size();
ar << m_Weights.size();
for ( nit=m_Neurons.begin(); nit<m_Neurons.end(); nit++ )
{
NNNeuron& n = *(*nit);
ar.WriteString( n.label.c_str() );
ar.WriteString( _T("\r\n") );
ar << n.m_Connections.size();
for ( cit=n.m_Connections.begin(); cit<n.m_Connections.end(); cit++ )
{
ar << (*cit).NeuronIndex;
ar << (*cit).WeightIndex;
}
}
for ( wit=m_Weights.begin(); wit<m_Weights.end(); wit++ )
{
ar.WriteString( (*wit)->label.c_str() );
ar.WriteString( _T("\r\n") );
ar << (*wit)->value;
}
}
else
{
// TODO: add loading code here
CString str;
ar.ReadString( str );
label = str;
int iNumNeurons, iNumWeights, iNumConnections;
double value;
NNNeuron* pNeuron;
NNWeight* pWeight;
NNConnection conn;
ar >> iNumNeurons;
ar >> iNumWeights;
for ( ii=0; ii<iNumNeurons; ++ii )
{
ar.ReadString( str );
pNeuron = new NNNeuron( (LPCTSTR)str );
m_Neurons.push_back( pNeuron );
ar >> iNumConnections;
for ( jj=0; jj<iNumConnections; ++jj )
{
ar >> conn.NeuronIndex;
ar >> conn.WeightIndex;
pNeuron->AddConnection( conn );
}
}
for ( jj=0; jj<iNumWeights; ++jj )
{
ar.ReadString( str );
ar >> value;
pWeight = new NNWeight( (LPCTSTR)str, value );
m_Weights.push_back( pWeight );
}
}
}
示例12: WriteFormula
void CFormula::WriteFormula(CArchive& ar, bool use_new_OHF_style)
{
CString s = "";
int i = 0, N = (int) _formula.mFunction.GetSize();
char nowtime[26] = {0};
// First write the standard formula functions...
// These are functions and symbols, that
// * are essential to control the behaviour
// of (nearly) every poker bot.
// * configure some very important constants.
//
s.Format("##%s##\r\n\r\n", get_time(nowtime)); ar.WriteString(s);
for (i=0; i<N; i++)
if (_formula.mFunction[i].func == "notes")
ar.WriteString("##notes##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
for (i=0; i<N; i++)
if (_formula.mFunction[i].func == "dll")
ar.WriteString("##dll##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
s.Format("##bankroll##\r\n%f\r\n\r\n", _formula.dBankroll); ar.WriteString(s);
s.Format("##defcon##\r\n%f\r\n\r\n", _formula.dDefcon); ar.WriteString(s);
s.Format("##rake##\r\n%f\r\n\r\n", _formula.dRake); ar.WriteString(s);
s.Format("##nit##\r\n%d\r\n\r\n", (int) _formula.dNit); ar.WriteString(s);
for (i=0; i<N; i++)
if (_formula.mFunction[i].func == "f$alli")
ar.WriteString("##f$alli##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
for (i=0; i<N; i++)
if (_formula.mFunction[i].func == "f$swag")
ar.WriteString("##f$swag##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
for (i=0; i<N; i++)
if (_formula.mFunction[i].func == "f$srai")
ar.WriteString("##f$srai##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
for (i=0; i<N; i++)
if (_formula.mFunction[i].func == "f$rais")
ar.WriteString("##f$rais##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
for (i=0; i<N; i++)
if (_formula.mFunction[i].func == "f$call")
ar.WriteString("##f$call##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
for (i=0; i<N; i++)
if (_formula.mFunction[i].func == "f$prefold")
ar.WriteString("##f$prefold##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
// New standard formulas are
// * f$delay
// * f$chat
//
// Old standard formulas are:
// * f$evrais
// * f§evcall
//
if (use_new_OHF_style)
{
for (i=0; i<N; i++)
if (_formula.mFunction[i].func == "f$delay")
ar.WriteString("##f$delay##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
for (i=0; i<N; i++)
if (_formula.mFunction[i].func == "f$chat")
ar.WriteString("##f$chat##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
}
else
{
for (i=0; i<N; i++)
if (_formula.mFunction[i].func == "f$evrais")
ar.WriteString("##f$evrais##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
for (i=0; i<N; i++)
if (_formula.mFunction[i].func == "f$evcall")
ar.WriteString("##f$evcall##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
}
for (i=0; i<N; i++)
if (_formula.mFunction[i].func == "f$P")
ar.WriteString("##f$P##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
for (i=0; i<N; i++)
if (_formula.mFunction[i].func == "f$play")
ar.WriteString("##f$play##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
for (i=0; i<N; i++)
if (_formula.mFunction[i].func == "f$test")
ar.WriteString("##f$test##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
for (i=0; i<N; i++)
if (_formula.mFunction[i].func == "f$debug")
ar.WriteString("##f$debug##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
// handlists for both ohf and old whf style
//.........这里部分代码省略.........
示例13: Serialize
void CWedDoc::Serialize(CArchive& ar, const char *docname)
{
CString num, str;
CString filename = docname;
PathToFname(filename);
if (ar.IsStoring())
{
// Writing
CWaitCursor cursor;
POSITION pos;
pos = strlist.GetHeadPosition();
origlines = 0;
while(TRUE)
{
CString line;
if(!(origlines % 100))
{
num.Format("Writing %s line %d", filename, origlines);
message(num);
}
origlines++;
if (!pos)
break;
line = strlist.GetNext(pos);
// Obey tab save option
if(Tab2Space || spaceify)
ExpandTabs(line);
// Dispose space from EOL
line.TrimRight();
// Write out to file
ar.WriteString(line);
// Do end of line according to settings
if(unix)
ar.WriteString("\n");
else
ar.WriteString("\r\n");
}
num.Format("Wrote %s", filename); message(num);
// If user decides to save, save undo/redo info as well
SaveUndo(); SaveRedo();
}
else
{
// Reading
CWaitCursor cursor;
char buff[DETECTSIZE];
strlist.RemoveAll();
// Determine file type
CFile* fp = ar.GetFile();
int rlen = fp->Read(buff, DETECTSIZE);
// File without a newline ---> default to DOS
if(!strstr(buff, "\n"))
unix = FALSE;
else if (strstr(buff, "\r\n"))
unix = FALSE;
else
unix = TRUE;
// Take a wild guess for tabs
if(!strstr(buff, "\t") && rlen > DETECTSIZE/2 )
{
spaceify = TRUE;
}
// Start over on file
fp->Seek(0,CFile::begin);
origlines = 0;
// Load file
while(TRUE)
{
str = "";
if(!(origlines % 100))
{
CString num;
num.Format("Reading %s line %d", filename, origlines);
message(num);
}
if(YieldToWinEx())
{
readonly = TRUE;
AfxMessageBox("Aborted load, partial buffer is readonly.");
break;
}
TRY
{
if(!ar.ReadString(str))
//.........这里部分代码省略.........
示例14: Serialize
void CProjectDoc::Serialize(CArchive& ar)
{
CProjectView* pview = GetProjectView();
int i, l;
if (ar.IsStoring())
{ // Output
#ifdef _UNICODE
_TCHAR uniflag = 0xfeff; // written as fffe, which is right for PC unicode
ar.Write(&uniflag, 2);
#endif
pview->UpdateData(TRUE);
ar.WriteString(_T("amzirel=4")); // so we can check for valid ppj files
ar.WriteString(CRLF);
ar.WriteString(_T("xplfile="));
ar.WriteString(pview->m_xplfile);
ar.WriteString(CRLF);
ar.WriteString(_T("directory="));
ar.WriteString(pview->m_directory);
ar.WriteString(CRLF);
ar.WriteString(_T("opdefs="));
ar.WriteString(pview->m_opdefs);
ar.WriteString(CRLF);
CListBox* pLB;
CString s;
pLB = (CListBox*)(pview->GetDlgItem(IDP_FILELIST));
l = pLB->GetCount();
for (i=0; i<l; i++)
{
pLB->GetText(i, s);
ar.WriteString(_T("file="));
ar.WriteString(s);
ar.WriteString(CRLF);
}
pLB = (CListBox*)(pview->GetDlgItem(IDP_LIBLIST));
l = pLB->GetCount();
for (i=0; i<l; i++)
{
pLB->GetText(i, s);
ar.WriteString(_T("library="));
ar.WriteString(s);
ar.WriteString(CRLF);
}
SaveOpenFiles(ar);
}
else
{ // Input
ReadArchive(ar);
}
}
示例15: WriteGWorldToVRML
void CGWorldOpenGL::WriteGWorldToVRML(CArchive& file,STATIONSHOW SS)
{
char szBuffer[128];
file.WriteString("#VRML V1.0 ascii\n");
//We should probably just use the defaults and make things run faster instead of setting
//a light source.
file.WriteString("Separator {\n\tDEF SceneInfo Info {\n\t\tstring ");
file<<'"';
file.WriteString("Modeled using On Station 3.1");
file<<'"';
file.WriteString("\n\t}\n}\n");
int iTriangleGroupCount=m_TriangleGroupArray.GetSize();
for (int i=0; i<iTriangleGroupCount; i++)
{
sprintf(szBuffer,"DEF TriangleStrip%i Separator {\n",i+1);
file.WriteString(szBuffer);
CGWorldTriangleGroup const * pGroup=m_TriangleGroupArray.GetAt(i);
pGroup->DumpToVRML(file);
file.WriteString("}\n");
}
//Next, do the fixed points if appropriate
int iFixedPointCount=m_ConstraintArray.GetSize();
CPosMatrix ptPos;
CPosMatrix transformedPos;
for (i=0; i<iFixedPointCount; i++)
{
sprintf(szBuffer,"DEF FixedPoint%i Separator {\n",i+1);
file.WriteString(szBuffer);
const CGWorldOpenGLConstraint & fixedPoint=m_ConstraintArray.GetAt(i);
file.WriteString("\tMaterial {\n\t\tdiffuseColor 1.0 0.0 0.0\n\t}\n");
sprintf(szBuffer,"\tTranslation {\n\t\ttranslation %f %f %f\n\t}\n",fixedPoint.position[0],fixedPoint.position[1],fixedPoint.position[2]);
file.WriteString(szBuffer);
file.WriteString("\tSphere {\n\t\tradius 3\n\t}\n");
file.WriteString("}\n");
}
}