本文整理汇总了C++中str::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ str::empty方法的具体用法?C++ str::empty怎么用?C++ str::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类str
的用法示例。
在下文中一共展示了str::empty方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create_iterator
WriteIterator xml_writer::create_iterator(const str& name, schema* type)
{
if (name.empty())
return WriteIterator( new xml_write_iterator(node_, type, types_) );
TiXmlElement* node = new TiXmlElement(name.c_str());
node_->LinkEndChild( node );
return WriteIterator( new xml_write_iterator(node, type, types_) );
}
示例2: eq_
void Parser::eq_(str& s, EvalAtomType atomType)
{
if (mInternalQ == NULL)
return;
if (s.empty())
return;
EvalAtom* atom = new EvalAtom(s, atomType);
mInternalQ->push_back(atom);
}
示例3: install_autorun
//------------------------------------------------------------------------------
static int install_autorun(const char* clink_path, int wow64)
{
HKEY cmd_proc_key;
const char* value;
char* key_value;
int i;
// Remove any previous autorun entries so we never have more than one. We
// could just check for an exisiting entry, but by always uninstalling and
// reinstalling, we ensure clink's last in the chain, which allows it to
// play nicely with other projects that hook cmd.exe and install autoruns.
uninstall_autorun(clink_path, wow64);
cmd_proc_key = open_cmd_proc_key(g_all_users, wow64, 1);
if (cmd_proc_key == nullptr)
{
printf("ERROR: Failed to open registry key (%d)\n", GetLastError());
return 0;
}
key_value = nullptr;
get_value(cmd_proc_key, "AutoRun", &key_value);
i = key_value ? (int)strlen(key_value) : 0;
i += 2048;
str_base new_value((char*)malloc(i), i);
new_value.clear();
// Build the new autorun entry by appending clink's entry to the current one.
if (key_value != nullptr && *key_value != '\0')
new_value << key_value << "&";
new_value << "\"" << clink_path << "\\clink.bat\" inject --autorun";
if (!g_clink_args.empty())
new_value << " " << g_clink_args;
// Set it
value = get_cmd_start(new_value.c_str());
i = 1;
if (!set_value(cmd_proc_key, "AutoRun", value))
i = 0;
// Tidy up.
close_key(cmd_proc_key);
free(new_value.data());
free(key_value);
return i;
}
示例4: handle_expression
void handle_expression(const str& text, param_list* args)
{
str expr_ = text;
if (text.empty() && args)
{
variant vv = args->get("value");
if (vv.empty())
vv = args->get("v");
if (!vv.empty())
expr_ = variant_cast<str>(vv, "");
}
expressions_.push_back(expr_);
items_.push_back(ItemRenderer(new out_expr_renderer(expressions_.size() - 1)));
}
示例5: render_assignment
str js_lang::render_assignment(const str& path, const str& prop, const str& value)
{
if (path.empty())
return prop + " = " + value;
return path + "." + prop + " = " + value;
}
示例6: initialize
bool SKAudio::initialize(SoundIoBackend backend, str& device_id)
{
if(!(sio = soundio_create()))
{
logit("E: SoundIo out of memory: ");
return false;
}
if(auto err = (backend == SoundIoBackendNone)
? soundio_connect(sio)
: soundio_connect_backend(sio, backend))
{
logit("E: SoundIo can't connect to backend: " << soundio_strerror(err));
return false;
}
soundio_flush_events(sio);
auto selected_device_index = -1;
if(!device_id.empty())
{
auto device_count = soundio_output_device_count(sio);
for(decltype(device_count) i = 0; i < device_count; ++i)
{
SoundIoDevice* device = soundio_get_output_device(sio, i);
if(!std::strcmp(device->id, device_id.c_str()))
{
selected_device_index = i;
break;
}
}
}
if(selected_device_index == -1)
selected_device_index = soundio_default_output_device_index(sio);
if(selected_device_index == -1)
{
logit("E: SoundIo can't find device: ");
return false;
}
if(!(dev = soundio_get_output_device(sio, selected_device_index)))
{
logit("E: SoundIo out of memory: ");
return false;
}
device_id = dev->id;
if(dev->probe_error)
{
logit("E: Cannot probe device: " << soundio_strerror(dev->probe_error));
return false;
}
if(!(out = soundio_outstream_create(dev)))
{
logit("E: SoundIo out of memory: ");
return false;
}
return true;
}
示例7: write
void base_write_archive::write( Writer w, const str& name, variant& v)
{
schema* type = true_type(v);
void* this_ = v.get_pointer();
//3 use cases:
//- we know the type as attibuted (ints, strings, things like that)
// note the implementor is free to define its custom types
//
//- we are saving an iterable type
//
//- or we are saving an object, these seem to be reasonable assumptions.
if (attributed_type(type))
{
assert(!name.empty());
w->attribute(name, v);
}
else
{
size_t type_options = type->options();
if (type_options & TYPE_ITERATED)
{
iterable iter(v);
iterator it = iter.begin();
iterator nd = iter.end();
WriteIterator wit = w->create_iterator(name, iter.iterated_type());
for(; it != nd; ++it)
{
variant iv = *it;
Writer iw = wit->next(iv);
if (iw)
write(iw, "", iv);
}
}
else
{
Writer writer_ = name.empty()? w : w->create_node(name);
schema* otype = v.get_schema(); assert(otype);
size_t oopt = otype->options();
if (oopt & TYPE_NON_INSTANTIABLE)
{
assert(type != otype);
assert(types_);
str class_id = types_->type_name(type); assert( !class_id.empty() );
w->attribute("class", class_id);
}
//collect what we're saving
schema_collector sc;
type->visit(&sc);
schema_collector::container::iterator it = sc.begin();
schema_collector::container::iterator nd = sc.end();
for(; it != nd; it++)
{
schema_item& item = it->second;
if (item.flags & CONST)
continue;
if (item.flags & TRANSIENT)
continue;
if (item.get)
{
variant value = item.get->get(this_);
write(writer_, it->first, value);
}
}
}
}
}