本文整理汇总了C++中Locale::SetDefaultLanguage方法的典型用法代码示例。如果您正苦于以下问题:C++ Locale::SetDefaultLanguage方法的具体用法?C++ Locale::SetDefaultLanguage怎么用?C++ Locale::SetDefaultLanguage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Locale
的用法示例。
在下文中一共展示了Locale::SetDefaultLanguage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main( int argc, char *argv[] ) {
int status;
unsigned short i;
if ( (argc < 3) || (argc > 4) ) {
cerr << "Invalid number of arguments\n"
"Usage: " << argv[0] << " <datafile> <outfile> [<gfxdir>]" << endl;
exit(-1);
}
if ( SDL_Init(0) < 0 ) {
cerr << "Couldn't init SDL: " << SDL_GetError() << endl;
exit(-1);
}
atexit(SDL_Quit);
status = 0;
UnitsetHeader info;
vector<EdUnitType> units;
map<string, Language> names;
CFParser parser;
SectionHandler *h;
UnitsetCallback cb;
Locale locale;
parser.AddHandler( "unitset", new UnitsetHandler( info ) );
h = new UnitHandler( info, units, names );
h->SetEnabled( false );
parser.AddHandler( "unit", h );
parser.SetCallback( &cb );
status = parser.Parse( argv[1] );
if ( status == 0 ) {
// validate what we have parsed
if ( info.images.size() == 0 ) {
cerr << "Error: No images defined" << endl;
status = -1;
} else {
if ( argc == 4 ) {
string gfxdir( argv[3] );
append_path_delim( gfxdir );
info.images.insert( 0, gfxdir );
}
if ( !File::Exists( info.images ) ) {
cerr << "Error: Could not find file " << info.images << endl;
status = -1;
}
}
if ( units.size() == 0 ) {
cerr << "Error: No units defined" << endl;
status = -1;
}
for ( map<string, Language>::iterator it = names.begin();
it != names.end(); ++it ) {
locale.AddLanguage( it->second );
}
if ( !locale.SetDefaultLanguage( CF_LANG_DEFAULT ) ) {
cerr << "Error: Could not find info for default language (" << CF_LANG_DEFAULT << ")" << endl;
status = -1;
}
}
if ( status == 0 ) {
File out( argv[2] );
if ( !out.Open( "wb" ) ) {
cerr << "Couldn't open output file " << argv[2] << endl;
status = -1;
} else {
// write data file header
out.Write32( FID_UNITSET );
out.Write16( units.size() );
// write sound file names
out.Write8( info.sfx.size() );
for ( i = 0; i < info.sfx.size(); ++i ) {
out.Write8( info.sfx[i].size() );
out.WriteS( info.sfx[i] );
}
// write unit data
for ( i = 0; i < units.size(); ++i ) {
out.Write16( units[i].Terrain() );
out.Write16( units[i].Image() );
out.Write16( units[i].Flags() );
out.Write8( units[i].Speed() );
out.Write8( units[i].Weight() );
out.Write8( units[i].Armour() );
out.Write8( units[i].Firepower( U_GROUND) );
out.Write8( units[i].Firepower( U_SHIP ) );
out.Write8( units[i].Firepower( U_AIR ) );
out.Write8( units[i].MinFOF( U_GROUND ) );
out.Write8( units[i].MaxFOF( U_GROUND ) );
out.Write8( units[i].MinFOF( U_SHIP ) );
out.Write8( units[i].MaxFOF( U_SHIP ) );
out.Write8( units[i].MinFOF( U_AIR ) );
//.........这里部分代码省略.........