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


C++ NarrowString类代码示例

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


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

示例1: unsigned

bool
LX16xxConfigWidget::SaveFixedEnumSetting(LX1600::Setting key, unsigned idx,
                                         LX1600::SettingsMap &settings,
                                         unsigned factor)
{
  const std::string old_value = device.GetLX16xxSetting(key);
  unsigned value = unsigned(ParseDouble(old_value.c_str()) * factor);
  if (!SaveValue(idx, value))
    return false;

  NarrowString<32> buffer;
  buffer.UnsafeFormat("%.2f", (double)value / factor);
  settings[key] = std::string(buffer.c_str(), buffer.end());
  return true;
}
开发者ID:arogithub,项目名称:XCSoar-TE,代码行数:15,代码来源:LX16xxConfigWidget.cpp

示例2: 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

示例3: expected_answer

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

示例4: WriteEventAttributes

static void
WriteEventAttributes(TextWriter &writer,
                     const BrokenDateTime &time, const GeoPoint &location)
{
  JSON::ObjectWriter object(writer);

  if (time.IsPlausible()) {
    NarrowString<64> buffer;
    FormatISO8601(buffer.buffer(), time);
    object.WriteElement("time", JSON::WriteString, buffer);
  }

  if (location.IsValid())
    JSON::WriteGeoPointAttributes(object, location);
}
开发者ID:MindMil,项目名称:XCSoar,代码行数:15,代码来源:AnalyseFlight.cpp

示例5: main

int main(int argc, char **argv)
{
  NarrowString<1024> usage;
  usage = "DRIVER\n\n"
          "Where DRIVER is one of:";
  {
    const DeviceRegister *driver;
    for (unsigned i = 0; (driver = GetDriverByIndex(i)) != nullptr; ++i) {
      WideToUTF8Converter driver_name(driver->name);
      usage.AppendFormat("\n\t%s", (const char *)driver_name);
    }
  }

  Args args(argc, argv, usage);
  tstring driver_name = args.ExpectNextT();
  args.ExpectEnd();

  driver = FindDriverByName(driver_name.c_str());
  if (driver == nullptr) {
    _ftprintf(stderr, _T("No such driver: %s\n"), driver_name.c_str());
    return 1;
  }

  DeviceConfig config;
  config.Clear();

  NullPort port;
  Device *device = driver->CreateOnPort != nullptr
    ? driver->CreateOnPort(config, port)
    : nullptr;

  NMEAParser parser;

  NMEAInfo data;
  data.Reset();

  char buffer[1024];
  while (fgets(buffer, sizeof(buffer), stdin) != nullptr) {
    StripRight(buffer);

    if (device == nullptr || !device->ParseNMEA(buffer, data))
      parser.ParseLine(buffer, data);
  }

  Dump(data);

  return EXIT_SUCCESS;
}
开发者ID:Advi42,项目名称:XCSoar,代码行数:48,代码来源:RunDeviceDriver.cpp

示例6: ASSERT

 /**
  * Constructs a secure random number generator (RNG) implementing the named
  * random number algorithm.
  */
 SecureRandomBase::SecureRandomBase(const NarrowString& algorithm, const byte*, size_t)
     : m_catastrophic(false), m_algorithm(algorithm)
 {
     ASSERT( !algorithm.empty() );
     //ASSERT(seed);
     //ASSERT(size); 
 }
开发者ID:dreadlock,项目名称:owasp-esapi-cplusplus,代码行数:11,代码来源:SecureRandomImpl.cpp

示例7: isAllowedCipherMode

  /**
   * Return true if specified cipher mode may be used for encryption and
   *   decryption operations via {@link org.owasp.esapi.Encryptor}.
   * @param cipherMode The specified cipher mode to be used for the encryption
   *                   or decryption operation.
   * @return true if the specified cipher mode is in the comma-separated list
   *         of cipher modes supporting both confidentiality and authenticity;
   *         otherwise false.
   * @see #isCombinedCipherMode(String)
   * @see org.owasp.esapi.SecurityConfiguration#getCombinedCipherModes()
   * @see org.owasp.esapi.SecurityConfiguration#getAdditionalAllowedCipherModes()
   */
  bool CryptoHelper::isAllowedCipherMode(const NarrowString& cipherMode)
  {
    ESAPI_ASSERT2( !cipherMode.empty(), "cipherMode is not valid" );
    if(cipherMode.empty())
      throw IllegalArgumentException("Cipher mode is not valid");

    if ( isCombinedCipherMode(cipherMode) ) { 
      return true; 
    } 

    DummyConfiguration config;
    const StringList& extraModes = config.getAdditionalAllowedCipherModes();
        
    StringList::const_iterator it = std::find(extraModes.begin(), extraModes.end(), cipherMode);
    return it != extraModes.end(); 
  }
开发者ID:dreadlock,项目名称:owasp-esapi-cplusplus,代码行数:28,代码来源:CryptoHelper.cpp

示例8: ASSERT

 /**
  * Constructs a secure random number generator (RNG) implementing the named
  * random number algorithm if specified
  */
 SecureRandom::SecureRandom(const NarrowString& algorithm)   
     : m_lock(new Mutex),
       m_impl(SecureRandomBase::createInstance(AlgorithmName::normalizeAlgorithm(algorithm), nullptr, 0))    
 {
     ASSERT( !algorithm.empty() );
     ASSERT(m_lock.get() != nullptr);
     ASSERT(m_impl.get() != nullptr);
 }
开发者ID:dreadlock,项目名称:owasp-esapi-cplusplus,代码行数:12,代码来源:SecureRandom.cpp

示例9: getFirstToken

	bool getFirstToken (const NarrowString & str, size_t pos, size_t & endpos, NarrowString & token, const char * sepChars)
	{
		const size_t first_nonspace = str.find_first_not_of ( sepChars, pos );

		if (first_nonspace != std::string::npos)
		{
			const size_t first_space    = str.find_first_of   (sepChars, first_nonspace );
			if (first_space != std::string::npos)
				token = str.substr (first_nonspace, first_space - first_nonspace);
			else
				token = str.substr (first_nonspace);

			endpos = first_space;
			return true;
		}
		else
			return false;
	}
开发者ID:Mesagoppinmypants,项目名称:NGELinux,代码行数:18,代码来源:UnicodeUtils.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: expected_answer

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:

bool
FLARMConfigWidget::Save(bool &_changed)
{
  PopupOperationEnvironment env;
  bool changed = false;
  NarrowString<32> buffer;

  if (SaveValue(Baud, baud)) {
    buffer.UnsafeFormat("%u", baud);
    device.SendSetting("BAUD", buffer, env);
    changed = true;
  }

  if (SaveValue(Priv, priv)) {
    buffer.UnsafeFormat("%u", priv);
    device.SendSetting("PRIV", buffer, env);
    changed = true;
  }

  if (SaveValue(Thre, thre)) {
    buffer.UnsafeFormat("%u", thre);
    device.SendSetting("THRE", buffer, env);
    changed = true;
  }

  if (SaveValue(Range, range)) {
    buffer.UnsafeFormat("%u", range);
    device.SendSetting("RANGE", buffer, env);
    changed = true;
  }

  if (SaveValue(Acft, acft)) {
    buffer.UnsafeFormat("%u", acft);
    device.SendSetting("ACFT", buffer, env);
    changed = true;
  }

  if (SaveValue(LogInt, log_int)) {
    buffer.UnsafeFormat("%u", log_int);
    device.SendSetting("LOGINT", buffer, env);
    changed = true;
  }

  if (SaveValue(NoTrack, notrack)) {
    buffer.UnsafeFormat("%u", notrack);
    device.SendSetting("NOTRACK", buffer, env);
    changed = true;
  }

  _changed |= changed;
  return true;
}
开发者ID:CnZoom,项目名称:XcSoarPull,代码行数:52,代码来源:ConfigWidget.cpp

示例13: generateSecretKey

  /**
   * Generate a random secret key appropriate to the specified cipher algorithm
   * and key size.
   * @param alg        The cipher algorithm or cipher transformation. (If the latter is
   *                   passed, the cipher algorithm is determined from it.) Cannot be empty.
   * @param keyBits    The key size, in bits.
   * @return           A random {@code SecretKey} is returned.
   */
  SecretKey CryptoHelper::generateSecretKey(const NarrowString& alg, unsigned int keyBits)
  {
    ASSERT( !alg.empty() );
    ASSERT( keyBits >= 56 );
    ASSERT( (keyBits % 8) == 0 );

    KeyGenerator kgen(KeyGenerator::getInstance(alg));
    kgen.init(keyBits);

    return kgen.generateKey();
  }
开发者ID:dreadlock,项目名称:owasp-esapi-cplusplus,代码行数:19,代码来源:CryptoHelper.cpp

示例14:

bool
V7ConfigWidget::Save(bool &_changed, bool &require_restart)
{
  PopupOperationEnvironment env;
  bool changed = false;
  NarrowString<32> buffer;

  if (SaveValue(BRGPS, brgps)) {
    buffer.UnsafeFormat("%u", brgps);
    device.SendV7Setting("BRGPS", buffer, env);
    changed = true;
  }

  if (SaveValue(BRPDA, brpda)) {
    buffer.UnsafeFormat("%u", brpda);
    device.SendV7Setting("BRPDA", buffer, env);
    changed = true;
  }

  _changed |= changed;
  return true;
}
开发者ID:damianob,项目名称:xcsoar,代码行数:22,代码来源:V7ConfigWidget.cpp

示例15: m_normal

  AlgorithmName::AlgorithmName(const NarrowString& algorithm, bool cipherOnly)
    : m_normal(normalizeAlgorithm(algorithm))
  {
    ASSERT( !algorithm.empty() );

    // We'd prefer to throw in the ctor, but its a limitation, not a feature!
    // Actually, we need to narmalize first (in case of throw), so maybe it is a feature.
    NarrowString cipher;
    getCipher(cipher);

    if(cipherOnly && m_normal != cipher)
      throw NoSuchAlgorithmException(m_normal + " not available");
  }
开发者ID:dreadlock,项目名称:owasp-esapi-cplusplus,代码行数:13,代码来源:AlgorithmName.cpp


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