本文整理汇总了C++中CDictionary::Load方法的典型用法代码示例。如果您正苦于以下问题:C++ CDictionary::Load方法的具体用法?C++ CDictionary::Load怎么用?C++ CDictionary::Load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDictionary
的用法示例。
在下文中一共展示了CDictionary::Load方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
if (argc != 4)
PrintUsage();
if ( !strcmp (argv[1], "-h")
|| !strcmp (argv[1], "-help")
|| !strcmp (argv[1], "/h")
|| !strcmp (argv[1], "/help")
)
PrintUsage();
string Action = argv[1];
if ( (Action != "ToTxt")
&& (Action != "FromTxt")
)
PrintUsage();
string FileName = argv[2];
CDictionary Dict;
if (Action == "FromTxt")
{
if (access (FileName.c_str(), 04) != 0)
{
fprintf (stderr, "Cannot read %s\n",FileName.c_str());
return 1;
};
if (!Dict.LoadOnlyConstants(argv[3]))
{
fprintf (stderr, "Cannot load an empty dictionary from %s\n",argv[3]);
return 1;
};
Dict.m_bShouldSaveComments = true;
string Messages;
bool bResult = Dict.ImportFromText(FileName,false, iceSkip,1, Messages);
fprintf (stderr, "%s", Messages.c_str() );
if (bResult)
if (Dict.Save())
return 0;
return 1;
}
else
{
if (!Dict.Load(argv[3]) || !Dict.ReadUnitComments())
{
fprintf (stderr, "Cannot load dictionary from %s\n",argv[3]);
return 1;
};
FILE * fp = fopen (FileName.c_str(),"wb");
if (!fp)
{
fprintf (stderr, "Cannot write to %s\n",FileName.c_str());
return 1;
};
CTempArticle A;
A.m_pRoss = &Dict;
for (WORD i = 0; i < Dict.m_Units.size(); i++)
{
fprintf (fp,"============\r\n");
fprintf (fp,"%s", Dict.GetUnitTextHeader(i).c_str());
try
{
A.ReadFromDictionary(i, false, true);
if (!A.ArticleToText())
{
fprintf (fp,"Error! Cannot get the entry No %i\r\n", i);
return 1;
};
fprintf (fp,"%s",A.GetArticleStr().c_str());
}
catch (...)
{
fprintf (fp,"Error! Cannot get the entry No %i\r\n", i);
return 1;
}
};
fclose(fp);
return 0;
};
}
示例2: LoadDictionary
void CViewport::LoadDictionary(void)
{
CSV::CSVDocument doc;
CSV::CSVDocument::row_index_type row_count;
//Parse from the document
try
{
row_count = doc.load_file("captionmod/dictionary.csv");
}
catch(std::exception &err)
{
Sys_ErrorEx("%s\n%s", "LoadDictionary: ", err.what());
}
if(row_count < 2)
return;
IScheme *ischeme = scheme()->GetIScheme(GetScheme());
if(!ischeme)
return;
Color defaultColor = ischeme->GetColor("BaseText", Color(255, 255, 255, 200));
//Initialize the dictionary hashtable
m_StringsHashTable.SetSize(2048);
for (int i = 0; i < m_StringsHashTable.Count(); i++)
m_StringsHashTable[i].next = NULL;
EmptyDictionaryHash();
int nRowCount = row_count;
//parse the dictionary line by line...
for (int i = 1;i < nRowCount; ++i)
{
CSV::CSVDocument::row_type row = doc.get_row(i);
if(row.size() < 1)
continue;
const char *title = row[0].c_str();
if(!title || !title[0])
continue;
CDictionary *Dict = new CDictionary;
Dict->Load(row, defaultColor, ischeme);
m_Dictionary.AddToTail(Dict);
AddDictionaryHash(Dict, Dict->m_szTitle);
}
//Link the dictionaries
for(int i = 0; i < m_Dictionary.Count(); ++i)
{
CDictionary *Dict = m_Dictionary[i];
if(Dict->m_szNext[0])
{
Dict->m_pNext = FindDictionary(Dict->m_szNext);
}
}
}