当前位置: 首页>>代码示例>>C++>>正文


C++ Locale::AddLanguage方法代码示例

本文整理汇总了C++中Locale::AddLanguage方法的典型用法代码示例。如果您正苦于以下问题:C++ Locale::AddLanguage方法的具体用法?C++ Locale::AddLanguage怎么用?C++ Locale::AddLanguage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Locale的用法示例。


在下文中一共展示了Locale::AddLanguage方法的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 ) );
//.........这里部分代码省略.........
开发者ID:drodin,项目名称:Crimson,代码行数:101,代码来源:mkunitset.cpp


注:本文中的Locale::AddLanguage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。