本文整理汇总了C++中Datum::isDictionary方法的典型用法代码示例。如果您正苦于以下问题:C++ Datum::isDictionary方法的具体用法?C++ Datum::isDictionary怎么用?C++ Datum::isDictionary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Datum
的用法示例。
在下文中一共展示了Datum::isDictionary方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkCodec
void VariableRegistryTestFixture::checkCodec(const Datum &generated_codec, int number_of_entries) const {
CPPUNIT_ASSERT( generated_codec.isDictionary() );
auto &dict = generated_codec.getDict();
CPPUNIT_ASSERT( dict.size() == number_of_entries );
for (auto &item : dict) {
auto &key = item.first;
auto &value = item.second;
CPPUNIT_ASSERT( key.isInteger() );
CPPUNIT_ASSERT( value.isDictionary() );
}
}
示例2: pluginName
static shared_ptr<mw::Component> createRealtimeComponent(const shared_ptr<ComponentRegistry> &componentRegistry,
const Datum &realtimeComponentsValue,
const std::string &componentType,
const std::string &defaultPluginName)
{
std::string pluginName(defaultPluginName);
if (realtimeComponentsValue.isDictionary()) {
Datum componentValue = realtimeComponentsValue.getElement(componentType);
if (componentValue.isString()) {
pluginName = componentValue.getString();
}
}
mprintf(M_SYSTEM_MESSAGE_DOMAIN, " %s:\t%s", componentType.c_str(), pluginName.c_str());
return componentRegistry->createNewObject(pluginName, map<string, string>());
}
示例3: updateFromCodecDatum
void VariableRegistry::updateFromCodecDatum(const Datum &codec) {
mprintf(M_SYSTEM_MESSAGE_DOMAIN,
"Received new codec, updating variable registry.");
if(!codec.isDictionary()) {
merror(M_SYSTEM_MESSAGE_DOMAIN,
"Invalid codec received. Registry is unchanged.");
return;
}
boost::mutex::scoped_lock s_lock(lock);
master_variable_list.clear();
// add the placeholders
//addPlaceholders();
//////////////////////////////////////////////////////////////////
// now add what's in the codec
ScarabDatum *datum = codec.getScarabDatum();
ScarabDatum ** keys = datum->data.dict->keys;
int size = datum->data.dict->tablesize;
int maxCodecCode = -1;
// find the maximum codec value
for(int i = 0; i < size; ++i) {
if(keys[i]) {
long long code = keys[i]->data.integer;
maxCodecCode = (maxCodecCode < code) ? code : maxCodecCode;
}
}
// add each variable in order to the registry
for(int i = N_RESERVED_CODEC_CODES; i<=maxCodecCode; ++i) {
ScarabDatum *key = scarab_new_integer(i);
ScarabDatum *serializedVariable = scarab_dict_get(datum, key);
scarab_free_datum(key);
if(!serializedVariable) {
shared_ptr<EmptyVariable> empty_var(new EmptyVariable);
master_variable_list.push_back(empty_var);
continue;
} else {
if(serializedVariable->type != SCARAB_DICT) {
// these must be placeholder datums in the package
// that we should ignore.
mwarning(M_SYSTEM_MESSAGE_DOMAIN,
"Bad variable received from network stream");
shared_ptr<EmptyVariable> empty_var(new EmptyVariable);
master_variable_list.push_back(empty_var);
continue;
}
VariableProperties *props =
new VariableProperties(serializedVariable);
if(props == NULL){
mwarning(M_SYSTEM_MESSAGE_DOMAIN,
"Bad variable received from network stream");
shared_ptr<EmptyVariable> empty_var(new EmptyVariable);
master_variable_list.push_back(empty_var);
continue;
}
shared_ptr<Variable> newvar(new GlobalVariable(props));
newvar->setCodecCode(i); //necessary? .. Yup
master_variable_list.push_back(newvar);
std::string tag = newvar->getVariableName();
if(!tag.empty()){
master_variable_dictionary[tag] = newvar;
}
}
}
}