本文整理汇总了C++中any::desc方法的典型用法代码示例。如果您正苦于以下问题:C++ any::desc方法的具体用法?C++ any::desc怎么用?C++ any::desc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类any
的用法示例。
在下文中一共展示了any::desc方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cast
//CAST
any bitset_descriptor::cast (const any& value) const
{
if (value.desc() != this)
{
any destination;
std::string svalue;
return this->stoa(value.desc()->atos(value), destination);
}
return any(value);
}
示例2: set
// RAW VALUE SERIALIZATION
void bitset_descriptor::set(void* ptr, const any& value) const
{
boost::dynamic_bitset<>* destination = (boost::dynamic_bitset<>*) ptr;
if (value.desc() != this)
{
any a = destination;
std::string svalue = std::move(value.desc()->atos(value));
this->stoa(svalue, a);
*destination = *anycast<boost::dynamic_bitset<>*>(a);
}
else
{
*destination = *anycast<boost::dynamic_bitset<>*>(value);
}
}
示例3: atos
// TO/FROM STRING SERIALIZATION
std::string any_descriptor::atos(const any& value) const
{
const descriptor* cd = value.desc();
if (!cd)
{
throw LAURENA_NULL_POINTER_EXCEPTION("unknow class descriptor");
}
return cd->atos(value);
}
示例4: impl
static void impl(CONTAINER* c, const descriptor* element_descriptor, any& element)
{
if ( element.desc()->has(descriptor::Flags::ATOMIC))
{
element = element_descriptor->cast(element);
c->push_back(anycast<ELEMENT>(element));
}
else
{
ELEMENT* e = anycast<ELEMENT*>(element);
c->push_back(*e);
}
}
示例5: serializeObject
void oarchive_json::serializeObject(const any& value)
{
const descriptor* cd = value.desc();
if ( !cd)
{
throw new LAURENA_NULL_POINTER_EXCEPTION("any& value do have nullptr descriptor.");
}
word32 backup = this->_nb_fields;
this->_nb_fields = 0;
std::string opening = "{";
std::string ending = "}" ;
if (cd->hasFeature(Feature::CONTAINER))
{
opening = "[" ;
ending = "]" ;
}
// opening
if (this->_compact)
this->_data << opening ;
else
{
this->_data << this->_tab << opening << std::endl;
this->_tab.increase();
}
if (cd->has(descriptor::Flags::FIELDS))
this->serializeFields(*cd,value);
if (cd->hasFeature(Feature::CONTAINER))
this->serializeElements(*cd,value);
if (this->_compact)
this->_data << ending ;
else
{
this->_data << std::endl << this->_tab.decrease() << ending ;
}
this->_nb_fields = backup;
}
示例6: readObject
void iarchive_xml::readObject(const std::string& tag, any& object)
{
token t;
std::string keyword;
const descriptor* d = object.desc();
// READ ATTRIBUTES
this->readAttributes(object);
// End of section
t = std::move(this->read_token(XML::TOKEN_INFERIOR_SLASH, XML::TOKEN_SUPERIOR));
while(true)
{
std::string content = this->_tokenizer.readUntil("<",true);
if (*this->_tokenizer._ptr == '/')
{
// Check that incoming keyword is same than the last one
this->read_token(XML::TOKEN_SLASH);
t = std::move(this->read_token( XML::TOKEN_KEYWORD));
std::string keyword = anycast<std::string>(t);
if (keyword == tag)
{
this->read_token(XML::TOKEN_SUPERIOR);
//object.desc()->stoa(content, object);
return;
}
else
this->error_tag_not_expected(tag, keyword);
}
else
{
// check content is tabs
if (!const_charsets<>::TABS.validate(content))
{
throw LAURENA_FAILED_PARSING_EXCEPTION("Syntax error",this->_tokenizer._ptr);
}
// read keyword
t=std::move(this->read_token(XML::TOKEN_KEYWORD));
std::string keyword = anycast<std::string>(t);
// Identification of keyword
if (d->has(descriptor::Flags::FIELDS))
{
const field* f = d->findField(keyword);
if (f)
{
this->readField(*f, keyword, object);
continue;
}
}
std::ostringstream ss;
ss << keyword << " : unknow child for class " << d->name();
throw LAURENA_FAILED_PARSING_EXCEPTION(ss.str().c_str(),this->_tokenizer._ptr);
}
}
}