本文整理汇总了C++中boost::any::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ any::empty方法的具体用法?C++ any::empty怎么用?C++ any::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::any
的用法示例。
在下文中一共展示了any::empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: xparse
void xparse(boost::any& value_store,
const std::vector<std::string>& new_tokens) const
{
if(gPastLastOption)
{
throw(LLCLPLastOption("Don't parse no more!"));
}
// Error checks. Needed?
if (!value_store.empty() && !is_composing())
{
throw(LLCLPError("Non composing value with multiple occurences."));
}
if (new_tokens.size() < min_tokens() || new_tokens.size() > max_tokens())
{
throw(LLCLPError("Illegal number of tokens specified."));
}
if(value_store.empty())
{
value_store = boost::any(LLCommandLineParser::token_vector_t());
}
LLCommandLineParser::token_vector_t* tv =
boost::any_cast<LLCommandLineParser::token_vector_t>(&value_store);
for(unsigned i = 0; i < new_tokens.size() && i < mMaxTokens; ++i)
{
tv->push_back(new_tokens[i]);
}
if(mLastOption)
{
gPastLastOption = true;
}
}
示例2:
void
DBusIPCAPI_v1::CallbackWithStatusArg1_Helper(
int status, const boost::any& value, DBusMessage *message
)
{
DBusMessage *reply = dbus_message_new_method_return(message);
DBusMessageIter iter;
dbus_message_iter_init_append(reply, &iter);
if (!status && value.empty()) {
status = kWPANTUNDStatus_PropertyEmpty;
}
dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &status);
if (value.empty()) {
append_any_to_dbus_iter(&iter, std::string("<empty>"));
} else {
append_any_to_dbus_iter(&iter, value);
}
dbus_connection_send(mConnection, reply, NULL);
dbus_message_unref(message);
dbus_message_unref(reply);
}
示例3: validate
void validate(boost::any &v, std::vector<std::string> const &tokens, FallbackMap*, int)
{
if(v.empty())
{
v = boost::any(FallbackMap());
}
FallbackMap *map = boost::any_cast<FallbackMap>(&v);
std::map<std::string,std::string>::iterator mapIt;
for(std::vector<std::string>::const_iterator it=tokens.begin(); it != tokens.end(); ++it)
{
int sep = it->find(",");
if(sep < 1 || sep == (int)it->length()-1)
#if (BOOST_VERSION < 104200)
throw boost::program_options::validation_error("invalid value");
#else
throw boost::program_options::validation_error(boost::program_options::validation_error::invalid_option_value);
#endif
std::string key(it->substr(0,sep));
std::string value(it->substr(sep+1));
if((mapIt = map->mMap.find(key)) == map->mMap.end())
{
map->mMap.insert(std::make_pair (key,value));
}
}
}
示例4: check_first_occurrence
BOOST_PROGRAM_OPTIONS_DECL
void check_first_occurrence(const boost::any& value)
{
if (!value.empty())
boost::throw_exception(
multiple_occurrences());
}
示例5: set
void ItemAttribute::set(boost::any a)
{
clear();
if(a.empty())
return;
if(a.type() == typeid(std::string))
{
type = STRING;
new(data) std::string(boost::any_cast<std::string>(a));
}
else if(a.type() == typeid(int32_t))
{
type = INTEGER;
*reinterpret_cast<int32_t*>(&data) = boost::any_cast<int32_t>(a);
}
else if(a.type() == typeid(float))
{
type = FLOAT;
*reinterpret_cast<float*>(&data) = boost::any_cast<float>(a);
}
else if(a.type() == typeid(bool))
{
type = BOOLEAN;
*reinterpret_cast<bool*>(&data) = boost::any_cast<bool>(a);
}
}
示例6: validate
void validate(boost::any& v,
const std::vector<std::basic_string<charT> >& s,
std::vector<T>*,
int)
{
if (v.empty()) {
v = boost::any(std::vector<T>());
}
std::vector<T>* tv = boost::any_cast< std::vector<T> >(&v);
assert(NULL != tv);
for (unsigned i = 0; i < s.size(); ++i)
{
try {
/* We call validate so that if user provided
a validator for class T, we use it even
when parsing vector<T>. */
boost::any a;
std::vector<std::basic_string<charT> > cv;
cv.push_back(s[i]);
validate(a, cv, (T*)0, 0);
tv->push_back(boost::any_cast<T>(a));
}
catch(const bad_lexical_cast& /*e*/) {
boost::throw_exception(invalid_option_value(s[i]));
}
}
}
示例7: exchange_field
bool octtree_piece_rendata::exchange_field(const data_index_t &i,boost::any &v)
{
disc_rendata_ptr_t drd = disc_rds[i[1]];
switch(i[0])
{
case 0:
return s_exchange_data_ro(drd->cellid.to_string(),v);
case 1:
return s_exchange_data_ro((int)drd->index,v);
case 2:
case 3:
{
bool need_update = false;
bool is_read = v.empty();
need_update = s_exchange_data_rw(drd->show[i[0]%2],v);
if(need_update && is_read == false )
m_bNeedUpdateDiscRens = true;
return need_update;
}
case 4:
case 5:
return s_exchange_data_rw(drd->color[i[0]%2],v);
case 6:
case 7:
return s_exchange_action(random_color_assigner(drd,i[0]%2),v);
};
throw std::logic_error("invalid index");
}
示例8: setConfigurationSetting
void WTextEdit::setConfigurationSetting(const std::string& name,
const boost::any& value)
{
if (!value.empty())
configurationSettings_[name] = value;
else
configurationSettings_.erase(name);
}
示例9: parse
/// Every appearance of the option simply increments the value
//
/// There should never be any tokens.
virtual void parse(boost::any& value_store,
const std::vector<std::string>& new_tokens,
bool /*utf8*/) const
{
assert(new_tokens.empty());
if (value_store.empty()) value_store = T();
boost::any_cast<T&>(value_store) += _interval;
}
示例10: xparse
void xparse(boost::any& v, std::vector<std::basic_string<charT> > const&) const
{
// if this is the first occurrence of the option, initialize it to the origin
if (v.empty()) {
v = boost::any(origin_);
}
++boost::any_cast<T&>(v);
}
示例11: parse
/**
* @brief Parse options
*
* Every appearance of the option simply increments the value
* There should never be any tokens.
*/
virtual void
parse(boost::any& value_store,
const std::vector<std::string>& new_tokens,
bool utf8) const final
{
if (value_store.empty())
value_store = T();
boost::any_cast<T&>(value_store) += m_interval;
}
示例12:
bool ColumnBaseTyped<Type>::multiply(const boost::any& new_value){
if(new_value.empty()) return false;
if(typeid(Type)==new_value.type()){
Type value = boost::any_cast<Type>(new_value);
for(unsigned int i=0;i<this->size();i++){
this->operator[](i)*=value;
}
return true;
}
return false;
}
示例13: SetOption
void NetTransportServer::SetOption(boost::any const& opt)
{
::network::OptionsUser net_opt;
if (opt.empty()) {
net_opt.max_pack_size_ = 64 * 1024;
return ;
}
net_opt = boost::any_cast<::network::OptionsUser const&>(opt);
s_.SetSndTimeout(net_opt.sndtimeo_);
s_.SetMaxPackSize(net_opt.max_pack_size_);
}
示例14:
void
untyped_value::xparse(boost::any& value_store,
const std::vector<std::string>& new_tokens) const
{
if (!value_store.empty())
boost::throw_exception(
multiple_occurrences());
if (new_tokens.size() > 1)
boost::throw_exception(multiple_values());
value_store = new_tokens.empty() ? std::string("") : new_tokens.front();
}
示例15:
boost::python::object any_extract<boost::python::object>(boost::any const& self) {
if(self.empty()) return boost::python::object(); // None
if(is_any_int(self)) {
return boost::python::object(boost::any_cast<int>(self));
}
if(is_any_float(self)) {
return boost::python::object(boost::any_cast<double>(self));
}
//if(self.type() == typeid(json)) {
// return boost::python::object(*boost::any_cast<json>(self));
//}
QM_FAIL("boost::any unknown value type");
}