本文整理汇总了C++中OFormatter::flush方法的典型用法代码示例。如果您正苦于以下问题:C++ OFormatter::flush方法的具体用法?C++ OFormatter::flush怎么用?C++ OFormatter::flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OFormatter
的用法示例。
在下文中一共展示了OFormatter::flush方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveRules_SQL
void LexicalAutomat::SaveRules_SQL( OFormatter &out, OFormatter &alters, const SQL_Production &sql_version )
{
if( sql_version.norules )
return;
PM_Automat::SaveRules_SQL( "la", out, alters, sql_version );
lem::Ptr<LS_ResultSet> rs_predicates( GetStorage().ListPredicateTemplate() );
while( rs_predicates->Fetch() )
{
int id = rs_predicates->GetInt(0);
lem::Ptr<PredicateTemplate> t( GetStorage().LoadPredicateTemplate(id) );
lem::UFString src( sql_version.SqlStr(t->GetSrc()) );
lem::UFString params;
for( lem::Container::size_type i=0; i<t->GetParams().size(); ++i )
if( i>0 )
{
params.Add_Dirty( L"," );
params.Add_Dirty( t->GetParams()[i].c_str() );
}
else
{
params.Add_Dirty( t->GetParams()[i].c_str() );
}
out.printf( "INSERT INTO predicate_template( src, params ) VALUES ( '%us', '%us' );\n", src.c_str(), params.c_str() );
}
rs_predicates.Delete();
out.eol();
out.flush();
lem::Ptr<LS_ResultSet> rs_assocs( GetStorage().ListAssociatedEntries() );
while( rs_assocs->Fetch() )
{
const int id = rs_assocs->GetInt(0);
lem::Ptr<WordAssociation> assoc( GetStorage().LoadAssocitation(id) );
assoc->SaveSQL( out, sql_version );
}
rs_assocs.Delete();
out.flush();
out.printf( "\n\n" );
lem::Ptr<LS_ResultSet> misspelling( GetStorage().ListMisspelling() );
while( misspelling->Fetch() )
{
int id_language = misspelling->GetInt(1);
UFString old_word = sql_version.SqlStr(misspelling->GetUFString(2));
UFString new_word = sql_version.SqlStr(misspelling->GetUFString(3));
old_word = sql_version.SqlStr(old_word);
new_word = sql_version.SqlStr(new_word);
out.printf( "INSERT INTO misspelling( id_language, original_word, substitution ) VALUES ( %d, '%us', '%us' );\n",
id_language, old_word.c_str(), new_word.c_str() );
}
misspelling.Delete();
out.eol();
lem::Ptr<WordEntrySetEnumerator> wordentry_sets( wordentry_set->ListWordEntrySets() );
while( wordentry_sets->Fetch() )
{
const WordEntrySetItem &wes = wordentry_sets->GetItem();
lem::UFString s;
for( std::set<int>::const_iterator it=wes.ies.begin(); it!=wes.ies.end(); ++it )
{
if( !s.empty() )
s.Add_Dirty(L' ');
s.Add_Dirty( lem::to_ustr(*it).c_str() );
}
out.printf( "INSERT INTO word_entry_set( id, name, ies ) VALUES ( %d, '%us', '%us' );\n",
wes.GetId(), lem::to_upper(wes.GetName()).c_str(), s.c_str() );
}
wordentry_sets.Delete();
out.eol();
lem::Ptr<WordSetEnumerator> word_sets( wordentry_set->ListWordSets() );
while( word_sets->Fetch() )
{
const WordSetItem &wes = word_sets->GetItem();
lem::UFString s;
for( std::set<lem::UCString>::const_iterator it=wes.words.begin(); it!=wes.words.end(); ++it )
{
if( !s.empty() )
s.Add_Dirty(LexiconStorage::WORD_SET_DELIMITER);
s.Add_Dirty( sql_version.SqlStr(*it) );
}
out.printf( "INSERT INTO word_set( id, name, words, case_sensitive ) VALUES ( %d, '%us', '%us', %d );\n",
//.........这里部分代码省略.........
示例2: PrintMap
// ******************************************************
// Распечатка КАРТЫ - служебной информации об автомате в
// указанный текстовый поток.
// ******************************************************
void GraphGram::PrintMap(OFormatter &txtfile)
{
Grammar::PrintMap(txtfile);
Report(txtfile);
// The simple list of classes (not ordered - listed as they are in container)
txtfile.printf(
"\n%14h-List of classes:%14h-\nid class name number of entries\n"
);
MCollect< pair<int/*id_class*/, int/*nentry*/> > class_info;
class_info.reserve(classes().Count());
int max_entries = 0;
std::unique_ptr<ClassEnumerator> cenum(classes().Enumerate());
while (cenum->Fetch())
{
const int id_class = cenum->GetId();
// Сколько статей относится к данному классу
int nentry = 0;
std::unique_ptr<SymbolEnumerator> senum(symbols->Enumerate());
while (senum->Fetch())
{
if (senum->GetItem().GetClass() == id_class)
nentry++;
}
txtfile.printf(
"%W3d %W20us %d\n"
, id_class
, classes()[id_class].GetName().c_str()
, nentry
);
class_info.push_back(make_pair(id_class, nentry));
max_entries = std::max(max_entries, nentry);
}
txtfile.eol();
// Going to make more impressing list of classes - ordered by number
// of entries belong to each of them.
sort_desc_pairs(class_info);
if (!max_entries)
max_entries = 1;
txtfile.printf("Ordered list of classes (weighted by number of belonging entries\n");
for (int j = 0; j < classes().Count(); j++)
{
txtfile.printf(
"%W3d %W20us %W4d |%H#\n"
, class_info[j].first
, classes()[class_info[j].first].GetName().c_str()
, class_info[j].second
, int(36 * class_info[j].second / max_entries)
);
}
txtfile.flush();
// Перечень имен координат
txtfile.printf("\nList of coordinates:");
std::unique_ptr<CoordEnumerator> coenum(coords().Enumerate());
while (coenum->Fetch())
{
const GramCoord &c = coenum->GetItem();
txtfile.printf(
" %us (# of states: %d)"
, c.GetName().front().c_str()
, c.states().size()
);
}
txtfile.eol();
txtfile.flush();
txtfile.printf("%10h- END OF <GG> SECTION %10h-\n\n\n");
GetIO().mecho().printf("Ok\n");
txtfile.flush();
return;
}