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


C++ NarrowString::Format方法代码示例

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


在下文中一共展示了NarrowString::Format方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SendCommand

bool
WPASupplicant::SelectNetwork(unsigned id)
{
  NarrowString<64> cmd;
  cmd.Format("SELECT_NETWORK %u", id);
  return SendCommand(cmd) && ExpectOK();
}
开发者ID:CnZoom,项目名称:XcSoarPull,代码行数:7,代码来源:WPASupplicant.cpp

示例2: SetConfig

bool
FlarmDevice::SetBaudRate(unsigned baud_id, OperationEnvironment &env)
{
  NarrowString<32> buffer;
  buffer.Format("%u", baud_id);
  return SetConfig("BAUD", buffer, env);
}
开发者ID:DRIZO,项目名称:xcsoar,代码行数:7,代码来源:Device.cpp

示例3: SendRequest

bool
LiveTrack24::StartTracking(SessionID session, const TCHAR *username,
                           const TCHAR *password, unsigned tracking_interval,
                           VehicleType vtype, const TCHAR *vname,
                           OperationEnvironment &env)
{
  // http://www.livetrack24.com/track.php?leolive=2&sid=42664778&pid=1&
  //   client=YourProgramName&v=1&user=yourusername&pass=yourpass&
  //   phone=Nokia 2600c&gps=BT GPS&trk1=4&vtype=16388&
  //   vname=vehicle name and model

  const WideToUTF8Converter username2(username);
  const WideToUTF8Converter password2(password);
  const WideToUTF8Converter vname2(vname);
  if (!username2.IsValid() || !password2.IsValid() || !vname2.IsValid())
    return false;

#ifdef _UNICODE
  NarrowString<32> version;
  version.SetASCII(XCSoar_VersionLong);
#else
  const char *version = XCSoar_VersionLong;
#endif

  NarrowString<2048> url;
  url.Format("http://%s/track.php?leolive=2&sid=%u&pid=%u&"
             "client=%s&v=%s&user=%s&pass=%s&vtype=%u&vname=%s",
             GetServer(), session, 1, "XCSoar", version,
             (const char *)username2, (const char *)password, vtype, vname);

  return SendRequest(url, env);
}
开发者ID:Advi42,项目名称:XCSoar,代码行数:32,代码来源:LiveTrack24.cpp

示例4: FormatPolarShape

void
PlaneGlue::Write(const Plane &plane, KeyValueFileWriter &writer)
{
  NarrowString<255> tmp;

  writer.Write("Registration", plane.registration);
  writer.Write("CompetitionID", plane.competition_id);
  writer.Write("Type", plane.type);

  tmp.Format("%u", plane.handicap);
  writer.Write("Handicap", tmp);

  writer.Write("PolarName", plane.polar_name);

  FormatPolarShape(plane.polar_shape, tmp.buffer(), tmp.MAX_SIZE);
  writer.Write("PolarInformation", tmp);

  tmp.Format("%f", (double)plane.reference_mass);
  writer.Write("PolarReferenceMass", tmp);
  tmp.Format("%f", (double)plane.dry_mass);
  writer.Write("PolarDryMass", tmp);
  tmp.Format("%f", (double)plane.max_ballast);
  writer.Write("MaxBallast", tmp);
  tmp.Format("%f", (double)plane.dump_time);
  writer.Write("DumpTime", tmp);
  tmp.Format("%f", (double)plane.max_speed);
  writer.Write("MaxSpeed", tmp);
  tmp.Format("%f", (double)plane.wing_area);
  writer.Write("WingArea", tmp);
}
开发者ID:MindMil,项目名称:XCSoar,代码行数:30,代码来源:PlaneFileGlue.cpp

示例5: SendRequest

bool
LiveTrack24::Client::EndTracking(OperationEnvironment &env)
{
  // http://www.livetrack24.com/track.php?leolive=3&sid=42664778&pid=453&prid=0

  NarrowString<1024> url;
  url.Format("http://%s/track.php?leolive=3&sid=%u&pid=%u&prid=0",
             (const char *)server, session_id, packet_id);

  return SendRequest(url, env);
}
开发者ID:grafal,项目名称:xcsoar-dev,代码行数:11,代码来源:Client.cpp

示例6: Send

bool
FlarmDevice::SetConfig(const char *setting, const char *value,
                       OperationEnvironment &env)
{
  NarrowString<256> buffer;
  buffer.Format("PFLAC,S,%s,%s", setting, value);

  NarrowString<256> expected_answer(buffer);
  expected_answer[6u] = 'A';

  Send(buffer, env);
  return port.ExpectString(expected_answer, env, 2000) &&
    ExpectChecksum(port, NMEAChecksum(expected_answer), env);
}
开发者ID:DRIZO,项目名称:xcsoar,代码行数:14,代码来源:Device.cpp

示例7: Receive

bool
FlarmDevice::GetConfig(const char *setting, char *buffer, size_t length,
                       OperationEnvironment &env)
{
  NarrowString<256> request;
  request.Format("PFLAC,R,%s", setting);

  NarrowString<256> expected_answer(request);
  expected_answer[6u] = 'A';
  expected_answer += ',';

  Send(request, env);
  return Receive(expected_answer, buffer, length, env, 2000);
}
开发者ID:DRIZO,项目名称:xcsoar,代码行数:14,代码来源:Device.cpp

示例8: Receive

bool
FlarmDevice::GetConfig(const char *setting, char *buffer, size_t length,
                       OperationEnvironment &env)
{
  NarrowString<90> request;
  request.Format("PFLAC,R,%s", setting);

  NarrowString<90> expected_answer(request);
  expected_answer[6u] = 'A';
  expected_answer.push_back(',');

  Send(request, env);
  return Receive(expected_answer, buffer, length,
                 env, std::chrono::seconds(2));
}
开发者ID:XCSoar,项目名称:XCSoar,代码行数:15,代码来源:Device.cpp

示例9: narrow_value

bool
FlarmDevice::SetConfig(const char *setting, const TCHAR *value)
{
  NarrowPathName narrow_value(value);

  NarrowString<256> buffer;
  buffer.Format("PFLAC,S,%s,", setting);
  buffer.append(narrow_value);

  NarrowString<256> expected_answer(buffer);
  expected_answer[6u] = 'A';

  Send(buffer);
  return port.ExpectString(expected_answer);
}
开发者ID:pascaltempez,项目名称:xcsoar,代码行数:15,代码来源:Device.cpp

示例10: assert

bool
LiveTrack24::Client::GenerateSessionID(const TCHAR *_username, const TCHAR *_password,
                                       OperationEnvironment &env)
{
  // http://www.livetrack24.com/client.php?op=login&user=<username>&pass=<pass>

  assert(_username != NULL);
  assert(!StringIsEmpty(_username));
  assert(_password != NULL);
  assert(!StringIsEmpty(_password));

  const WideToUTF8Converter username2(_username);
  const WideToUTF8Converter password2(_password);
  if (!username2.IsValid() || !password2.IsValid())
    return false;

  NarrowString<1024> url;
  url.Format("http://%s/client.php?op=login&user=%s&pass=%s",
             (const char *)server, (const char *)username2, (const char *)_password);

  // Open download session
  Net::Session session;

  // Request the file
  char buffer[1024];
  size_t size = Net::DownloadToBuffer(session, url, buffer, sizeof(buffer) - 1,
                                      env);
  if (size == 0 || size == size_t(-1))
    return false;

  buffer[size] = 0;

  char *p_end;
  UserID user_id = strtoul(buffer, &p_end, 10);
  if (buffer == p_end) {
      return false;
  }

  username.SetASCII(_username);
  password.SetASCII(_password);
  session_id = RandomSessionID();
  session_id |= (user_id & 0x00ffffff);
  return true;
}
开发者ID:grafal,项目名称:xcsoar-dev,代码行数:44,代码来源:Client.cpp

示例11: Send

bool
FlarmDevice::GetConfig(const char *setting, TCHAR *buffer, size_t length)
{
  NarrowString<256> request;
  request.Format("PFLAC,R,%s", setting);

  NarrowString<256> expected_answer(request);
  expected_answer[6u] = 'A';
  expected_answer += ',';

  char narrow_buffer[length];

  Send(request);
  if (!Receive(expected_answer, narrow_buffer, length, 1000))
    return false;

  _tcscpy(buffer, PathName(narrow_buffer));
  return true;
}
开发者ID:pascaltempez,项目名称:xcsoar,代码行数:19,代码来源:Device.cpp

示例12: assert

LiveTrack24::UserID
LiveTrack24::GetUserID(const TCHAR *username, const TCHAR *password,
                       OperationEnvironment &env)
{
  // http://www.livetrack24.com/client.php?op=login&user=<username>&pass=<pass>

  assert(username != NULL);
  assert(!StringIsEmpty(username));
  assert(password != NULL);
  assert(!StringIsEmpty(password));

  const WideToUTF8Converter username2(username);
  const WideToUTF8Converter password2(password);
  if (!username2.IsValid() || !password2.IsValid())
    return 0;

  NarrowString<1024> url;
  url.Format("http://%s/client.php?op=login&user=%s&pass=%s",
             GetServer(), (const char *)username2, (const char *)password);

  // Open download session
  Net::Session session;

  // Request the file
  char buffer[1024];
  size_t size = Net::DownloadToBuffer(session, url, buffer, sizeof(buffer) - 1,
                                      env);
  if (size == 0 || size == size_t(-1))
    return 0;

  buffer[size] = 0;

  char *p_end;
  UserID user_id = strtoul(buffer, &p_end, 10);
  if (buffer == p_end)
    return 0;

  return user_id;
}
开发者ID:Advi42,项目名称:XCSoar,代码行数:39,代码来源:LiveTrack24.cpp

示例13: assert

void
Profile::SetFont(const char *key, LOGFONT &logfont)
{
  assert(key != NULL);
  assert(key[0] != '\0');

#ifdef _UNICODE
  char face[256];
  WideCharToMultiByte(CP_UTF8, 0, logfont.lfFaceName, -1,
                      face, ARRAY_SIZE(face),
                      nullptr, nullptr);
#else
  const char *face = logfont.lfFaceName;
#endif

  NarrowString<256> buffer;
  buffer.Format("%d,%d,0,0,%d,%d,0,0,0,0,0,%d,%d,%s", logfont.lfHeight,
                logfont.lfWidth, logfont.lfWeight, logfont.lfItalic,
                logfont.lfQuality, logfont.lfPitchAndFamily,
                face);

  Profile::Set(key, buffer);
}
开发者ID:DRIZO,项目名称:xcsoar,代码行数:23,代码来源:FontConfig.cpp

示例14: fixed

bool
FlarmDevice::DeclareInternal(const Declaration &declaration,
                             OperationEnvironment &env)
{
  unsigned size = declaration.Size();

  env.SetProgressRange(6 + size);
  env.SetProgressPosition(0);

  if (!SetPilot(declaration.pilot_name.c_str(), env))
    return false;

  env.SetProgressPosition(1);

  if (!SetPlaneRegistration(declaration.aircraft_registration.c_str(), env))
    return false;

  env.SetProgressPosition(2);

  if (!SetPlaneType(declaration.aircraft_type.c_str(), env))
    return false;

  env.SetProgressPosition(3);

  if (!SetConfig("NEWTASK", "Task", env))
    return false;

  env.SetProgressPosition(4);

  if (!SetConfig("ADDWP", "0000000N,00000000E,T", env))
    return false;

  env.SetProgressPosition(5);

  for (unsigned i = 0; i < size; ++i) {
    int DegLat, DegLon;
    fixed tmp, MinLat, MinLon;
    char NoS, EoW;

    tmp = declaration.GetLocation(i).latitude.Degrees();
    if (negative(tmp)) {
      NoS = 'S';
      tmp = -tmp;
    } else {
      NoS = 'N';
    }
    DegLat = (int)tmp;
    MinLat = (tmp - fixed(DegLat)) * 60 * 1000;

    tmp = declaration.GetLocation(i).longitude.Degrees();
    if (negative(tmp)) {
      EoW = 'W';
      tmp = -tmp;
    } else {
      EoW = 'E';
    }
    DegLon = (int)tmp;
    MinLon = (tmp - fixed(DegLon)) * 60 * 1000;

    /*
     * We use the waypoint index here as name to get around the 192 byte
     * task size limit of the FLARM devices.
     *
     * see Flarm DataPort Manual:
     * "The total data size entered through this command may not surpass
     * 192 bytes when calculated as follows: 7+(Number of Waypoints * 9) +
     * (sum of length of all task and waypoint descriptions)"
     */
    NarrowString<90> buffer;
    buffer.Format("%02d%05.0f%c,%03d%05.0f%c,%d",
                  DegLat, (double)MinLat, NoS,
                  DegLon, (double)MinLon, EoW, i + 1);

    if (!SetConfig("ADDWP", buffer, env))
      return false;

    env.SetProgressPosition(6 + i);
  }

  if (!SetConfig("ADDWP", "0000000N,00000000E,L", env))
    return false;

  env.SetProgressPosition(6 + size);

  // PFLAC,S,KEY,VALUE
  // Expect
  // PFLAC,A,blah
  // PFLAC,,COPIL:
  // PFLAC,,COMPID:
  // PFLAC,,COMPCLASS:

  // PFLAC,,NEWTASK:
  // PFLAC,,ADDWP:

  // Reset the FLARM to activate the declaration
  Restart(env);

  return true;
}
开发者ID:kwtskran,项目名称:XCSoar,代码行数:99,代码来源:Declare.cpp


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