本文整理汇总了C++中value::to_string方法的典型用法代码示例。如果您正苦于以下问题:C++ value::to_string方法的具体用法?C++ value::to_string怎么用?C++ value::to_string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类value
的用法示例。
在下文中一共展示了value::to_string方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: property_op
void namespaces::property_op(
property_mode mode, value const &id, value &data)
{
local_root_scope scope;
string name_ = id.to_string();
xmlChar const *name = (xmlChar const*) name_.c_str();
xmlChar *txt = 0;
if (mode != property_get && mode != property_delete) {
data = data.to_string();
txt = xmlStrdup((xmlChar const *) data.get_string().c_str());
}
switch (mode) {
case property_add:
if (xmlHashAddEntry(table, name, txt) != 0)
throw exception("Could not add entry to namespace hash table");
break;
case property_delete:
if (xmlHashRemoveEntry(table, name, xmlHashDeallocator(xmlFree)) != 0)
throw exception("Could not remove entry from namespace hash table");
break;
case property_set:
if (xmlHashUpdateEntry(table, name, txt, xmlHashDeallocator(xmlFree))!=0)
throw exception("Could not update entry in namespace hash table");
break;
case property_get:
break;
}
}
示例2: read_line
string stream::read_line(value sep_) {
local_root_scope scope;
if (sep_.is_undefined_or_null())
sep_ = string("\n");
string sep = sep_.to_string();
if (sep.length() != 1)
throw exception("Line separators with size other than 1 are not supported");
int sepc = sep.data()[0];
if (sepc >= 128)
throw exception("Non-ASCII line separators are not supported");
std::string line;
for (;;) {
int ch = streambuf_->sbumpc();
if (ch == std::char_traits<char>::eof())
break;
line += ch;
if (ch == sepc)
break;
}
return line;
}
示例3: apply
value regex_match_node::apply(value const& v) const
{
auto const& pattern = impl_.get()->pattern_;
#if defined(BOOST_REGEX_HAS_ICU)
return boost::u32regex_match(v.to_unicode(),pattern);
#else
return boost::regex_match(v.to_string(),pattern);
#endif
}
示例4: delete_property
void object::delete_property(value const &id) {
if (is_null())
throw exception("Could not delete property (object is null)");
local_root_scope scope;
string name = id.to_string();
jsval dummy;
if (!JS_DeleteUCProperty2(Impl::current_context(), get(),
(jschar*)name.data(), name.length(), &dummy))
throw exception("Could not delete property");
}
示例5: set_property
value object::set_property(value const &id, value const &v_) {
if (is_null())
throw exception("Could not set property (object is null)");
local_root_scope scope;
value v = v_;
string name = id.to_string();
if (!JS_SetUCProperty(Impl::current_context(), get(),
(jschar*)name.data(), name.length(),
Impl::get_jsvalp(v)))
throw exception("Could not set property");
return v;
}
示例6: has_property
bool object::has_property(value const &id) const {
if (is_null())
throw exception("Could not check property (object is null)");
local_root_scope scope;
string name = id.to_string();
JSBool foundp;
if (!JS_HasUCProperty(Impl::current_context(), get_const(),
(jschar*)name.data(), name.length(),
&foundp))
throw exception("Could not check property");
return foundp;
}
示例7: get_property
value object::get_property(value const &id) const {
if (is_null())
throw exception("Could not get property (object is null)");
value result;
local_root_scope scope;
string name = id.to_string();
if (!JS_GetUCProperty(Impl::current_context(), get_const(),
(jschar*)name.data(), name.length(),
Impl::get_jsvalp(result)))
throw exception("Could not get property");
return result;
}
示例8: has_own_property
bool object::has_own_property(value const &id) const {
if (is_null())
throw exception("Could not check property (object is null)");
JSBool has;
string name = id.to_string();
if (!JS_AlreadyHasOwnPropertyById(Impl::current_context(), get_const(),
Impl::get_jsid(id), &has))
{
throw exception("Unable to check for own property");
}
return has;
}
示例9: property_resolve
bool binary::property_resolve(value const &id, unsigned /*flags*/) {
if (!id.is_int())
return false;
int uid = id.get_int();
if (uid < 0)
return false;
if (size_t(uid) >= v_data.size())
return false;
value v = element(v_data[uid]);
define_property(id.to_string(), v, permanent_shared_property);
return true;
}
示例10: has_own_property
bool object::has_own_property(value const &id) const {
if (is_null())
throw exception("Could not check property (object is null)");
JSBool has;
#if JS_VERSION >= 180
string name = id.to_string();
if (!JS_AlreadyHasOwnUCProperty(Impl::current_context(), get_const(),
(jschar*)name.data(), name.length(), &has))
#else
JSObject *obj = get_const();
jsval argv[] = { Impl::get_jsval(id) };
jsval vp;
JSBool ret = js_HasOwnPropertyHelper(Impl::current_context(), obj,
obj->map->ops->lookupProperty, 1, argv,
&vp);
has = JSVAL_TO_BOOLEAN(vp);
if (!ret)
#endif
{
throw exception("Unable to check for own property");
}
return has;
}
示例11: perform
string_t perform(value const &v) {
return v.to_string().to_utf16_string();
}