void mlUnitInfo::fetch( const std::string & name ) { pugi::xml_document doc; doc.load_file( ("ini/units/" + name + ".xml").c_str() ); auto root = doc.root().first_child(); while( root.attribute( "template" ) ) { pugi::xml_document doc; doc.load_file( root.attribute( "template" ).as_string() ); root.remove_attribute( "template" ); auto temp = doc.root().first_child(); for( auto attr = temp.first_attribute(); attr; attr = attr.next_attribute() ) { auto attrRoot = root.attribute( attr.name() ); if( !attrRoot ) attrRoot = root.append_attribute( attr.name() ); attrRoot.set_value( attr.value() ); } } Info info; info.layer = strToUnitLayer( root.attribute( "unitlayer" ).as_string() ); info.type = strToUnitType( root.attribute( "unittype" ).as_string() ); info.radius = root.attribute( "radius" ).as_float(); _info.insert( std::pair<std::string, Info>( name, info ) ); }
void config::clear_diff_track(const config& diff) { remove_attribute(diff_track_attribute); for (const config &i : diff.child_range("delete_child")) { const size_t index = lexical_cast<size_t>(i["index"].str()); for (const any_child &item : i.all_children_range()) { remove_child(item.key, index); } } for (const config &i : diff.child_range("change_child")) { const size_t index = lexical_cast<size_t>(i["index"].str()); for (const any_child &item : i.all_children_range()) { if (item.key.empty()) { continue; } const child_map::iterator itor = children.find(item.key); if(itor == children.end() || index >= itor->second.size()) { throw error("error in diff: could not find element '" + item.key + "'"); } itor->second[index]->clear_diff_track(item.cfg); } } for (const any_child &value : all_children_range()) { const_cast<config *>(&value.cfg)->remove_attribute(diff_track_attribute); } }
ControlDock_MapTab::ControlDock_MapTab(SCHNApps* s) : schnapps_(s), selected_map_(nullptr), updating_ui_(false) { setupUi(this); // connect UI signals connect(list_maps, SIGNAL(itemSelectionChanged()), this, SLOT(selected_map_changed())); connect(button_duplicate, SIGNAL(clicked()), this, SLOT(duplicate_current_map_clicked())); connect(button_remove, SIGNAL(clicked()), this, SLOT(remove_current_map_clicked())); connect(check_drawBB, SIGNAL(toggled(bool)), this, SLOT(show_bb_changed(bool))); connect(combo_bbVertexAttribute, SIGNAL(currentIndexChanged(int)), this, SLOT(bb_vertex_attribute_changed(int))); connect(list_vertexAttributes, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(vertex_attribute_check_state_changed(QListWidgetItem*))); connect(list_dartSelectors, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(cells_set_check_state_changed(QListWidgetItem*))); connect(button_dartAddSelector, SIGNAL(clicked()), this, SLOT(add_cells_set())); connect(button_dartRemoveSelector, SIGNAL(clicked()), this, SLOT(remove_cells_set())); connect(button_dartRemoveAttribute, SIGNAL(clicked()), this, SLOT(remove_attribute())); connect(list_vertexSelectors, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(cells_set_check_state_changed(QListWidgetItem*))); connect(button_vertexAddSelector, SIGNAL(clicked()), this, SLOT(add_cells_set())); connect(button_vertexRemoveSelector, SIGNAL(clicked()), this, SLOT(remove_cells_set())); connect(button_vertexRemoveAttribute, SIGNAL(clicked()), this, SLOT(remove_attribute())); connect(list_edgeSelectors, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(cells_set_check_state_changed(QListWidgetItem*))); connect(button_edgeAddSelector, SIGNAL(clicked()), this, SLOT(add_cells_set())); connect(button_edgeRemoveSelector, SIGNAL(clicked()), this, SLOT(remove_cells_set())); connect(button_edgeRemoveAttribute, SIGNAL(clicked()), this, SLOT(remove_attribute())); connect(list_faceSelectors, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(cells_set_check_state_changed(QListWidgetItem*))); connect(button_faceAddSelector, SIGNAL(clicked()), this, SLOT(add_cells_set())); connect(button_faceRemoveSelector, SIGNAL(clicked()), this, SLOT(remove_cells_set())); connect(button_faceRemoveAttribute, SIGNAL(clicked()), this, SLOT(remove_attribute())); connect(list_volumeSelectors, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(cells_set_check_state_changed(QListWidgetItem*))); connect(button_volumeAddSelector, SIGNAL(clicked()), this, SLOT(add_cells_set())); connect(button_volumeRemoveSelector, SIGNAL(clicked()), this, SLOT(remove_cells_set())); connect(button_volumeRemoveAttribute, SIGNAL(clicked()), this, SLOT(remove_attribute())); // connect SCHNApps signals connect(schnapps_, SIGNAL(map_added(MapHandlerGen*)), this, SLOT(map_added(MapHandlerGen*))); connect(schnapps_, SIGNAL(map_removed(MapHandlerGen*)), this, SLOT(map_removed(MapHandlerGen*))); }
BOOL remove_attribute(const CHAR* name) { I32 index = get_attribute_index(name); if (index != -1) { return remove_attribute(index); } return FALSE; }
//-------------------------------------------------------- void BaseDevice::remove_dynShortAttr_dynamic_attribute(string attname) { remove_attribute(attname, true); map<string,Tango::DevShort>::iterator ite; if ((ite=dynShortAttr_data.find(attname))!=dynShortAttr_data.end()) { /*----- PROTECTED REGION ID(BaseDevice::remove_dynShortAttr_dynamic_attribute) ENABLED START -----*/ /*----- PROTECTED REGION END -----*/ // BaseDevice::remove_dynShortAttr_dynamic_attribute dynShortAttr_data.erase(ite); } }
//update_enum_attribute void Ocio_test::update_enum_attribute(std::string attribute_name, std::vector<std::string>& value_list, MObject& node) { //remove attribute remove_attribute(node, attribute_name); //create_enum_attribute create_enum_attribute(attribute_name, value_list, node); };
//-------------------------------------------------------- void BaseDevice::remove_dynShortArrayAttr_dynamic_attribute(string attname, bool free_it) { remove_attribute(attname, true); map<string,Tango::DevShort *>::iterator ite; if ((ite=dynShortArrayAttr_data.find(attname))!=dynShortArrayAttr_data.end()) { /*----- PROTECTED REGION ID(BaseDevice::remove_dynShortArrayAttr_dynamic_attribute) ENABLED START -----*/ /*----- PROTECTED REGION END -----*/ // BaseDevice::remove_dynShortArrayAttr_dynamic_attribute if (free_it) delete[] ite->second; dynShortArrayAttr_data.erase(ite); } }
//rebuild_enum void Ocio_test::rebuild_input_colorspace(int& change_list_index, MDataBlock& data) { //config OCIO::ConstConfigRcPtr config; config = OCIO_functionality::get_config_from_env(); //config_colorspaces std::vector<std::string> config_colorspaces = OCIO_functionality::get_colorspace_names(config); if (!config_colorspaces.size()) { //tmp MGlobal::displayInfo("Config colorspaces empty. Returning None"); return; }; //node MObject node = thisMObject(); //value_list std::string attribute_name("input_colorspace"); //update_enum_attribute //remove attribute remove_attribute(node, attribute_name); //create_enum_attribute create_enum_attribute(attribute_name, config_colorspaces, node); //Set last change index data.outputValue(a_last_change_index).setInt(change_list_index); //format boost::format change_index_msg("Last change index set to: %s"); change_index_msg % change_list_index; MGlobal::displayInfo(change_index_msg.str().c_str()); };
void XAttrManager::change_attribute_name(std::string old_attr_name, std::string new_attr_name) { std::string attribute_value = get_attribute_value(old_attr_name); add_attribute(new_attr_name, attribute_value); remove_attribute(old_attr_name); }
int main( int ac, char* av[]) { int c; if (ac == 1) error_exit(ATTRACH_ERR_USAGE); while (1) { int option_index = 0; static struct option long_options[] = { {"verbose", 0, 0, 'v'}, {"attribute", 1, 0, 'a'}, {"version", 0, 0, 'V'}, {"help", 0, 0, 'h'}, {0, 0, 0, 0} }; c = getopt_long (ac, av, "va:Vh", long_options, &option_index); if (c == -1) break; switch (c) { case 'V': show_version(); exit(0); break; case 'a': strcpy(attribute_name, optarg); break; case 'h': show_usage(); exit(0); break; case 'v': verbose_flag = ATTRACH_VERBOSE_ON; break; default: /* invalid switch, so failing */ error_exit(ATTRACH_ERR_SWITCH); } } if (!strcmp(av[optind], "attach")){ if (ac - optind != 3) error_exit(ATTRACH_ERR_USAGE); if (attach_file(av[optind+1], av[optind+2])) { printf("made it\n"); error_exit(ATTRACH_ERR_ATTACH); } } else if (!strcmp(av[optind], "get")) { if (ac - optind != 3) error_exit(ATTRACH_ERR_USAGE); if (retrieve_file(av[optind+1], av[optind+2])) { error_exit(ATTRACH_ERR_RETRIEVE); } } else if (!strcmp(av[optind], "remove")) { if (ac - optind != 2) error_exit(ATTRACH_ERR_USAGE); if (remove_attribute(av[optind+1])) { error_exit(ATTRACH_ERR_REMOVE); } } else { show_usage(); exit(1); } return 0; }