void Inspector::onPopertyChange(PropertyParam &param)
    {
        std::string cppName = typeid(*(param.node)).name();
        const std::string & type = PropertyTreeMgr::instance()->cppNameToUIName(cppName);

        IBaseLoader *loader = UILoader::instance()->findLoader(type);
        if(NULL == loader)
        {
            LOG_ERROR("Failed to find UI loader for type '%s'", type.c_str());
            return;
        }

        const std::string & name = param.name;
        auto & alloc = param.allocator();

        if(loader->setProperty(param))
        {
            rapidjson::Value temp;
            clone_value(temp, param.value, alloc);
            rapidjson::Value & slot = param.properties[name.c_str()];
            if(slot.IsNull())
            {
                param.properties.AddMember(name.c_str(), alloc, temp, alloc);
            }
            else
            {
                slot = temp;
            }
        }
    }
Beispiel #2
0
void
rs_filter_param_clone(RSFilterParam *destination, const RSFilterParam *source)
{
	g_return_if_fail(RS_IS_FILTER_PARAM(destination));
	g_return_if_fail(RS_IS_FILTER_PARAM(source));

	/* Clone the properties table */
	GHashTableIter iter;
	gpointer key, value;

	g_hash_table_iter_init (&iter, source->properties);
	while (g_hash_table_iter_next (&iter, &key, &value))
		g_hash_table_insert(destination->properties, (gpointer) g_strdup(key), clone_value(value));
}
Beispiel #3
0
Hash *h_clone(Hash *self, h_clone_ft clone_key, h_clone_ft clone_value)
{
    void *key, *value;
    HashEntry *he;
    int i = self->size;
    Hash *ht_clone;

    ht_clone = h_new(self->hash_i,
                     self->eq_i,
                     self->free_key_i,
                     self->free_value_i);

    for (he = self->table; i > 0; he++) {
        if (he->key && he->key != dummy_key) {        /* active entry */
            key = clone_key ? clone_key(he->key) : he->key;
            value = clone_value ? clone_value(he->value) : he->value;
            h_set(ht_clone, key, value);
            i--;
        }
    }
    return ht_clone;
}
Beispiel #4
0
 bool clone_value(rapidjson::Value & output, const rapidjson::Value & input, rapidjson::Value::AllocatorType & allocator)
 {
     if(&output == &input)
     {
         return false;
     }
     
     if(input.IsNull())
     {
         output.SetNull();
     }
     else if(input.IsInt64())
     {
         output.SetInt(input.GetInt64());
     }
     else if(input.IsInt())
     {
         output.SetInt(input.GetInt());
     }
     else if(input.IsDouble())
     {
         output.SetDouble(input.GetDouble());
     }
     else if(input.IsBool())
     {
         output.SetBool(input.GetBool());
     }
     else if(input.IsString())
     {
         output.SetString(input.GetString(), input.GetStringLength(), allocator);
     }
     else if(input.IsArray())
     {
         rapidjson::Value temp;
         output.SetArray();
         output.Reserve(input.Size(), allocator);
         for(rapidjson::SizeType i = 0; i < input.Size(); ++i)
         {
             clone_value(temp, input[i], allocator);
             output.PushBack(temp, allocator);
         }
     }
     else if(input.IsObject())
     {
         output.SetObject();
         
         rapidjson::Value key, val;
         for(rapidjson::Value::ConstMemberIterator it = input.MemberBegin();
             it != input.MemberEnd(); ++it)
         {
             clone_value(key, it->name, allocator);
             clone_value(val, it->value, allocator);
             
             output.AddMember(key, val, allocator);
         }
     }
     else
     {
         assert(false && "shuldn't execute to here.");
         return false;
     }
     return true;
 }