本文整理汇总了C++中TFile::WriteString方法的典型用法代码示例。如果您正苦于以下问题:C++ TFile::WriteString方法的具体用法?C++ TFile::WriteString怎么用?C++ TFile::WriteString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TFile
的用法示例。
在下文中一共展示了TFile::WriteString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnGoogleShowlocation
void CFrameLocs::OnGoogleShowlocation()
{
// TODO: Add your command handler code here
TString str;
int n;
CLocation * loc = NULL;
POSITION pos;
pos = m_wndLocs.GetFirstSelectedItemPosition();
if (pos != NULL && (n = m_wndLocs.GetNextSelectedItem(pos),n>=0))
{
loc = (CLocation *)m_wndLocs.GetItemData(n);
if (loc != NULL)
{
str.Format("<html><head><meta http-equiv=\"REFRESH\" content=\"0;url=http://maps.google.com/?ie=UTF8&ll=%f,%f&spn=0.774196,1.235962&z=10"
"\"></head><body></body><html>", loc->m_fLatitude, loc->m_fLongitude);
TFile file;
TString fileName;
fileName = GCalApp_GetFileName(GSTR_TEMFOLDER);
fileName += "temp.html";
if (file.Open(fileName, "w") == TRUE)
{
file.WriteString(str);
file.Close();
ShellExecute(this->m_hWnd, NULL, fileName, NULL, NULL, SW_SHOW);
}
/* str.Format("http://maps.google.com/?ie=UTF8&ll=%f,%f&spn=0.774196,1.235962&z=10", loc->m_fLatitude, loc->m_fLongitude);
if (p_wndWeb != NULL)
{
p_wndWeb->Navigate(str.c_str());
m_wndTab.SetCurSel(1);
ShowControlsForTab(1);
}*/
}
}
return;
}
示例2: OnExport
void DlgObservedEvents::OnExport()
{
CFileDialog d(FALSE, "txt", "events", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST, "Text file (*.txt)|*.txt|XML File (*.xml)|*.xml||");
CString strc;
if (d.DoModal() == IDOK)
{
TString str, str2, str3;
TFile f;
if (f.Open(d.GetPathName(), "w") == TRUE)
{
int i, m;
switch(d.m_ofn.nFilterIndex)
{
case 1:
m = m_list.GetCount();
for(i = 0; i < m; i++)
{
m_list.GetText(i, strc);
f.WriteString(strc);
f.WriteString("\n");
}
break;
case 2:
{
int n;
f.WriteString("<xml>\n");
for(i = 0; i < 360; i++)
{
n = 0;
if (GCStrings::getString(200+i).IsEmpty() == FALSE)
{
str2 = GCStrings::getString(200 + i);
n = str2.Find("#");
while(n >= 0)
{
str2.Left(n, str3);
str.Format("\t<event name=\"%s\" tithi=\"%s\" paksa=\"%s\" masa=\"%s\" />\n", str3.c_str(), GCStrings::GetTithiName(i % 30),
GCStrings::GetPaksaName((i/15)%2), GCStrings::GetMasaName(i/30));
str2.Delete(0, n+1);
f.WriteString(str);
n = str2.Find("#");
}
if (str2.IsEmpty() == FALSE)
{
str.Format("\t<event name=\"%s\" tithi=\"%s\" paksa=\"%s\" masa=\"%s\" />\n", str2.c_str(),
GCStrings::GetTithiName(i % 30), GCStrings::GetPaksaName((i/15)%2), GCStrings::GetMasaName(i/30));
f.WriteString(str);
}
}
}
f.WriteString("\t<event name=\"");
f.WriteString(GCStrings::GetSpecFestivalName(SPEC_JANMASTAMI));
f.WriteString("\" tithi=\"Astami\" paksa=\"Krsna\" masa=\"Hrsikesa\" />\n");
f.WriteString("\t<event name=\"");
f.WriteString(GCStrings::GetSpecFestivalName(SPEC_GOVARDHANPUJA));
f.WriteString("\" tithi=\"Pratipat\" paksa=\"Gaura\" masa=\"Damodara\" />\n");
f.WriteString("\t<event name=\"");
f.WriteString(GCStrings::GetSpecFestivalName(SPEC_RATHAYATRA));
f.WriteString("\" tithi=\"Dvitiya\" paksa=\"Gaura\" masa=\"Vamana\" />\n");
f.WriteString("\t<event name=\"");
f.WriteString(GCStrings::GetSpecFestivalName(SPEC_GAURAPURNIMA));
f.WriteString("\" tithi=\"Purnima\" paksa=\"Gaura\" masa=\"Govinda\" />\n");
f.WriteString("\t<event name=\"");
f.WriteString(GCStrings::GetSpecFestivalName(SPEC_NANDAUTSAVA));
f.WriteString("\" depends=\"Sri Krsna Janmastami\" rel=\"+1\"/>\n");
f.WriteString("\t<event name=\"");
f.WriteString(GCStrings::GetSpecFestivalName(SPEC_PRABHAPP));
f.WriteString("\" depends=\"Sri Krsna Janmastami\" rel=\"+1\"/>\n");
f.WriteString("\t<event name=\"");
f.WriteString(GCStrings::GetSpecFestivalName(SPEC_MISRAFESTIVAL));
f.WriteString("\" depends=\"Gaura Purnima\" rel=\"+1\"/>\n");
f.WriteString("\t<event name=\"");
f.WriteString(GCStrings::GetSpecFestivalName(SPEC_HERAPANCAMI));
f.WriteString("\" depends=\"Ratha Yatra\" rel=\"+4\"/>\n");
f.WriteString("\t<event name=\"");
f.WriteString(GCStrings::GetSpecFestivalName(SPEC_RETURNRATHA));
f.WriteString("\" depends=\"Ratha Yatra\" rel=\"+8\"/>\n");
f.WriteString("\t<event name=\"");
f.WriteString(GCStrings::GetSpecFestivalName(SPEC_GUNDICAMARJANA));
f.WriteString("\" depends=\"Ratha Yatra\" rel=\"-1\"/>\n");
f.WriteString("\t<event name=\"");
f.WriteString(GCStrings::getString(78));
f.WriteString("\" sankranti=\"Makara\" rel=\"0\"/>\n");
f.WriteString("\t<event name=\"");
f.WriteString(GCStrings::getString(79));
f.WriteString("\" sankranti=\"Mesha\" rel=\"0\"/>\n");
f.WriteString("\t<event name=\"");
f.WriteString(GCStrings::getString(80));
f.WriteString("\" sankranti=\"Vrsabha\" rel=\"-1\"/>\n");
f.WriteString("\t<event name=\"");
f.WriteString(GCStrings::GetSpecFestivalName(SPEC_RAMANAVAMI));
f.WriteString("\" tithi=\"Navami\" paksa=\"Gaura\" masa=\"Visnu\" />\n");
f.WriteString("</xml>\n");
}
break;
default:
break;
//.........这里部分代码省略.........
示例3: SaveAs
BOOL CLocationList::SaveAs(const char * lpszFileName, int nType)
{
TString key, val, str, strTemp;
TFile f;
CLocation * lc;
int i, ni;
if (f.Open(lpszFileName, "w") == FALSE)
{
return FALSE;
}
switch(nType)
{
case 1:
f.WriteString("<xml>\n");
f.WriteString("\t<countries>\n");
ni = TCountry::GetCountryCount();
for(i = 0; i < ni; i++)
{
str.Format("\t<ccn country=\"%s\" continent=\"%s\" />\n", TCountry::GetCountryNameByIndex(i),
TCountry::GetCountryContinentNameByIndex(i));
f.WriteString(str);
}
f.WriteString("\t</countries>\n");
f.WriteString("\t<dsts>\n");
ni = TTimeZone::GetTimeZoneCount();
for(i = 1; i < ni; i++)
{
TTimeZone::GetXMLString(str, i);
f.WriteString(str);
}
f.WriteString("\t</dsts>\n");
f.WriteString("\t<cities>\n");
lc = list;
while(lc)
{
str.Format("\t<loc city=\"%s\" lon=\"%f\" lat=\"%f\" tzone=\"%f\"\n\t\tcountry=\"%s\" />\n",
lc->m_strCity.c_str(), lc->m_fLongitude, lc->m_fLatitude,
lc->m_fTimezone, lc->m_strCountry.c_str());
str.Replace("&", "&");
f.WriteString(str);
lc = lc->next;
}
f.WriteString("\t</cities>\n");
f.WriteString("</xml>");
break;
case 2:
f.WriteString("Countries:\n");
ni = TCountry::GetCountryCount();
for(i = 0; i < ni; i++)
{
str.Format("%s, %s\n", TCountry::GetCountryNameByIndex(i),
TCountry::GetCountryContinentNameByIndex(i));
f.WriteString(str);
}
f.WriteString("Daylight Saving Time Systems:\n");
ni = TTimeZone::GetTimeZoneCount();
for(i = 1; i < ni; i++)
{
str.Format("\t%s\n", TTimeZone::GetTimeZoneName(i));
f.WriteString(str);
}
f.WriteString("Cities:\n");
lc = list;
while(lc)
{
str.Format("\t%-23s%-17s %+03.6f %+03.6f %+02.6f\n",
lc->m_strCity.c_str(),
lc->m_strCountry.c_str(),
lc->m_fLongitude,
lc->m_fLatitude,
lc->m_fTimezone);
f.WriteString(str);
lc = lc->next;
}
break;
case 3:
lc = list;
while(lc)
{
// city
f.WriteString("@city=");
f.WriteString(lc->m_strCity);
f.WriteString("\n");
f.WriteString("@country=");
f.WriteString(lc->m_strCountry);
f.WriteString("\n");
f.WriteString("@lat=");
strTemp.Format("%f", lc->m_fLatitude);
f.WriteString(strTemp);
f.WriteString("\n");
f.WriteString("@long=");
strTemp.Format("%f", lc->m_fLongitude);
f.WriteString(strTemp);
f.WriteString("\n");
//.........这里部分代码省略.........