本文整理汇总了C++中DataFieldEnum::SetAsString方法的典型用法代码示例。如果您正苦于以下问题:C++ DataFieldEnum::SetAsString方法的具体用法?C++ DataFieldEnum::SetAsString怎么用?C++ DataFieldEnum::SetAsString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataFieldEnum
的用法示例。
在下文中一共展示了DataFieldEnum::SetAsString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
static void
SetPort(DataFieldEnum &df, const DeviceConfig &config)
{
switch (config.port_type) {
case DeviceConfig::PortType::DISABLED:
case DeviceConfig::PortType::AUTO:
case DeviceConfig::PortType::INTERNAL:
case DeviceConfig::PortType::TCP_LISTENER:
break;
case DeviceConfig::PortType::SERIAL:
if (!df.Exists(config.path))
AddPort(df, config.port_type, config.path);
df.SetAsString(config.path);
return;
case DeviceConfig::PortType::RFCOMM:
if (!df.Exists(config.bluetooth_mac))
AddPort(df, DeviceConfig::PortType::RFCOMM, config.bluetooth_mac);
df.SetAsString(config.bluetooth_mac);
return;
case DeviceConfig::PortType::IOIOUART:
StaticString<16> buffer;
buffer.UnsafeFormat(_T("%d"), config.ioio_uart_id);
df.SetAsString(buffer);
return;
}
for (unsigned i = 0; port_types[i].label != NULL; i++) {
if (port_types[i].type == config.port_type) {
df.SetAsString(gettext(port_types[i].label));
break;
}
}
}
示例2: defined
static void
FillSerialPorts(DataFieldEnum &df, const DeviceConfig &config)
{
#if defined(HAVE_POSIX)
DetectSerialPorts(df);
#elif defined(WIN32)
#ifdef _WIN32_WCE
if (!DetectSerialPorts(df))
#endif
FillDefaultSerialPorts(df);
#endif
if (config.port_type == DeviceConfig::PortType::SERIAL) {
if (!df.Exists(config.path))
AddPort(df, config.port_type, config.path);
df.SetAsString(config.path);
}
}
示例3: AddPort
static void
FillAndroidBluetoothPorts(DataFieldEnum &df, const DeviceConfig &config)
{
#ifdef ANDROID
JNIEnv *env = Java::GetEnv();
jobjectArray bonded = BluetoothHelper::list(env);
if (bonded == NULL)
return;
jsize n = env->GetArrayLength(bonded) / 2;
for (jsize i = 0; i < n; ++i) {
jstring address = (jstring)env->GetObjectArrayElement(bonded, i * 2);
if (address == NULL)
continue;
const char *address2 = env->GetStringUTFChars(address, NULL);
if (address2 == NULL)
continue;
jstring name = (jstring)env->GetObjectArrayElement(bonded, i * 2 + 1);
const char *name2 = name != NULL
? env->GetStringUTFChars(name, NULL)
: NULL;
AddPort(df, DeviceConfig::PortType::RFCOMM, address2, name2);
env->ReleaseStringUTFChars(address, address2);
if (name2 != NULL)
env->ReleaseStringUTFChars(name, name2);
}
env->DeleteLocalRef(bonded);
if (config.port_type == DeviceConfig::PortType::RFCOMM &&
!config.bluetooth_mac.empty()) {
if (!df.Exists(config.bluetooth_mac))
AddPort(df, DeviceConfig::PortType::RFCOMM, config.bluetooth_mac);
df.SetAsString(config.bluetooth_mac);
}
#endif
}
示例4: switch
static void
SetupDeviceFields(const DeviceConfig &config,
WndProperty *port_field, WndProperty *speed_field,
WndProperty *driver_field, WndButton *setup_button)
{
#ifndef ANDROID
static const TCHAR *const COMMPort[] = {
_T("COM1"), _T("COM2"), _T("COM3"), _T("COM4"),
_T("COM5"), _T("COM6"), _T("COM7"), _T("COM8"),
_T("COM9"), _T("COM10"), _T("COM0"),
NULL
};
static const TCHAR *const tSpeed[] = {
_T("1200"), _T("2400"), _T("4800"), _T("9600"),
_T("19200"), _T("38400"), _T("57600"), _T("115200"),
NULL
};
#endif
if (port_field != NULL) {
DataFieldEnum *dfe = (DataFieldEnum *)port_field->GetDataField();
for (unsigned i = 0; port_types[i].label != NULL; i++) {
dfe->addEnumText(gettext(port_types[i].label));
if (port_types[i].type == config.port_type)
dfe->Set(i);
}
#ifdef ANDROID
JNIEnv *env = Java::GetEnv();
jobjectArray bonded = BluetoothHelper::list(env);
if (bonded != NULL) {
jsize n = env->GetArrayLength(bonded) / 2;
for (jsize i = 0; i < n; ++i) {
jstring address = (jstring)env->GetObjectArrayElement(bonded, i * 2);
if (address == NULL)
continue;
const char *address2 = env->GetStringUTFChars(address, NULL);
if (address2 == NULL)
continue;
jstring name = (jstring)env->GetObjectArrayElement(bonded, i * 2 + 1);
const char *name2 = name != NULL
? env->GetStringUTFChars(name, NULL)
: NULL;
dfe->addEnumText(address2, name2);
env->ReleaseStringUTFChars(address, address2);
if (name2 != NULL)
env->ReleaseStringUTFChars(name, name2);
}
env->DeleteLocalRef(bonded);
if (config.port_type == DeviceConfig::RFCOMM &&
!config.bluetooth_mac.empty()) {
if (!dfe->Exists(config.bluetooth_mac))
dfe->addEnumText(config.bluetooth_mac);
dfe->SetAsString(config.bluetooth_mac);
}
}
#else
dfe->addEnumTexts(COMMPort);
switch (config.port_type) {
case DeviceConfig::SERIAL:
dfe->Set(config.port_index + num_port_types);
break;
case DeviceConfig::DISABLED:
case DeviceConfig::RFCOMM:
case DeviceConfig::AUTO:
case DeviceConfig::INTERNAL:
case DeviceConfig::TCP_LISTENER:
break;
}
#endif
port_field->RefreshDisplay();
}
if (speed_field != NULL) {
#ifdef ANDROID
speed_field->hide();
#else
DataFieldEnum *dfe = (DataFieldEnum *)speed_field->GetDataField();
dfe->addEnumTexts(tSpeed);
dfe->Set(config.speed_index);
speed_field->RefreshDisplay();
#endif
}
if (driver_field) {
DataFieldEnum *dfe = (DataFieldEnum *)driver_field->GetDataField();
const TCHAR *DeviceName;
//.........这里部分代码省略.........