本文整理汇总了C++中NarrowString::UnsafeFormat方法的典型用法代码示例。如果您正苦于以下问题:C++ NarrowString::UnsafeFormat方法的具体用法?C++ NarrowString::UnsafeFormat怎么用?C++ NarrowString::UnsafeFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NarrowString
的用法示例。
在下文中一共展示了NarrowString::UnsafeFormat方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Set
bool
TCPClientPort::Connect(const char *host, unsigned port)
{
NarrowString<32> service;
service.UnsafeFormat("%u", port);
StaticSocketAddress address;
if (!address.Lookup(host, service, AF_INET))
return false;
SocketDescriptor s;
if (!s.CreateTCP())
return false;
#ifdef HAVE_POSIX
s.SetNonBlocking();
#endif
if (s.Connect(address)) {
Set(std::move(s));
return true;
}
#ifdef HAVE_POSIX
if (errno == EINPROGRESS) {
connecting = std::move(s);
io_thread->LockAdd(connecting.ToFileDescriptor(), Poll::WRITE, *this);
StateChanged();
return true;
}
#endif
return false;
}
示例2: Set
void
Profile::SetGeoPoint(const char *key, const GeoPoint &value)
{
NarrowString<128> buffer;
buffer.UnsafeFormat("%f %f",
(double)value.longitude.Degrees(),
(double)value.latitude.Degrees());
Set(key, buffer);
}
示例3:
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;
}
示例4: strtoul
bool
NanoConfigWidget::SaveSetting(const char *name, unsigned idx,
OperationEnvironment &env)
{
const std::string old_value = device.GetNanoSetting(name);
unsigned value = strtoul(old_value.c_str(), NULL, 10);
if (!SaveValue(idx, value))
return false;
NarrowString<32> buffer;
buffer.UnsafeFormat("%u", value);
return device.SendNanoSetting(name, buffer, env);
}
示例5:
bool
TCPClientPort::Connect(const char *host, unsigned port)
{
NarrowString<32> service;
service.UnsafeFormat("%u", port);
resolver.async_resolve({host, service.c_str()},
std::bind(&TCPClientPort::OnResolved, this,
std::placeholders::_1,
std::placeholders::_2));
return true;
}
示例6: ParseUnsigned
bool
LX16xxConfigWidget::SaveUnsignedSetting(LX1600::Setting key, unsigned idx,
LX1600::SettingsMap &settings)
{
const std::string old_value = device.GetLX16xxSetting(key);
unsigned value = ParseUnsigned(old_value.c_str());
if (!SaveValue(idx, value))
return false;
NarrowString<32> buffer;
buffer.UnsafeFormat("%u", value);
settings[key] = std::string(buffer.c_str(), buffer.end());
return true;
}
示例7:
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;
}
示例8: 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;
}