void beginElement( void * userdata, const XML_Char * nam, const XML_Char ** atts){
		AttributeList::const_iterator iter;
		XML * xml = (XML *)userdata;
		string tname (nam);
		AttributeList attributes (atts);
		GalaxyNames elem = (GalaxyNames) element_map.lookup(tname);
		GalaxyNames attr;
		string name;
		string value;
		switch (elem) {
		case GALAXY:
			break;
		case SYSTEMS:
                  break;
                case PLANETS:
			xml->stak.push_back ("<planets>");
			xml->g->addSection (xml->stak);
			break;
		case SECTOR:
		case SYSTEM:

                case PLANET:
			for (iter = attributes.begin(); iter!=attributes.end();++iter) {
				attr = (GalaxyNames)attribute_map.lookup((*iter).name);
				switch (attr) {
				case NAME:
					name = (*iter).value;
					break;
				default:
					break;
				}
			}
			xml->stak.push_back (name);
			xml->g->addSection (xml->stak);

			break;
		case VAR:
			for (iter = attributes.begin(); iter!=attributes.end();++iter) {
				attr = (GalaxyNames)attribute_map.lookup((*iter).name);
				switch(attr) {
				case NAME:
					name = (*iter).value;
					break;
				case VALUE:
					value = (*iter).value;
					break;
				default:break;
				}
			}
			xml->g->setVariable(xml->stak,name,value);
			break;
		default:break;
		}

		
	}
Esempio n. 2
0
TextEncoding HTMLMetaCharsetParser::encodingFromMetaAttributes(const AttributeList& attributes)
{
    bool gotPragma = false;
    Mode mode = None;
    String charset;

    for (AttributeList::const_iterator iter = attributes.begin(); iter != attributes.end(); ++iter) {
        const AtomicString& attributeName = iter->first;
        const String& attributeValue = iter->second;

        if (attributeName == http_equivAttr) {
            if (equalIgnoringCase(attributeValue, "content-type"))
                gotPragma = true;
        } else if (charset.isEmpty()) {
            if (attributeName == charsetAttr) {
                charset = attributeValue;
                mode = Charset;
            } else if (attributeName == contentAttr) {
                charset = extractCharset(attributeValue);
                if (charset.length())
                    mode = Pragma;
            }
        }
    }

    if (mode == Charset || (mode == Pragma && gotPragma))
        return TextEncoding(stripLeadingAndTrailingHTMLSpaces(charset));

    return TextEncoding();
}
void Connection::bind_parameters( sqlite3_stmt *ppStmt,
                                  const AttributeList &parameters ) {
  int i = 0;
  for( AttributeList::const_iterator it = parameters.begin();
       it != parameters.end();
       ++it ) {
    switch( it->which() ) {
    case integer: {
      int value = boost::get< int >( *it );
      sqlite3_bind_int( ppStmt, i + 1, value );
      break;
    }
    case text: {
      string value = boost::get< std::string >( *it );
      sqlite3_bind_text( ppStmt, i + 1, value.c_str(), value.size(), 0 );
      break;
    }
    case floating_point: {
      double value = boost::get< double >( *it );
      sqlite3_bind_double( ppStmt, i + 1, value );
      break;
    }
    case date: {
      Date value = boost::get< Date >( *it );
      string s   = value.to_string();
      sqlite3_bind_text( ppStmt, i + 1, s.c_str(), s.size(), 0 );
      break;
    }
    default: {
      throw ActiveRecordException( "Type not implemented", __FILE__, __LINE__ );
    }
    }
    ++i;
  }
}
/**
 Analiza los elementos de inicio del xml y los asigna a sus correspondientes 
 atributos.
 @param &name, const Glib::ustring del atributo de inicio del xml.
 @param &attributes, const AttributeList (array) con los atributos del xml.
 */
void XmlInstalador::on_start_element(const Glib::ustring& name, const AttributeList& attributes)
{	
	nodeName = name;

	//Atributos
	for(xmlpp::SaxParser::AttributeList::const_iterator iter = attributes.begin(); iter != attributes.end(); ++iter)
	{
		try
		{
			if("nombre" == iter->name)
			{
				nombre = iter->value;
			}
			if("ruta" == iter->name)
			{
				ruta = iter->value;
			}
		}
		catch(const Glib::ConvertError& ex)
		{
			//cerr<<"XmlParse atributos Excepcion obteniendo el nombre o valor"<<ex.what()<<endl;
			cerr<<"XmlParse attributes Exception obtaining name or value"<<ex.what()<<endl;
		}
	}
}
Esempio n. 5
0
void rise::parser::on_start_element(const Glib::ustring &_name,
                    		    const AttributeList &_attributes)
{
    Glib::ustring prefix, name = _name;
    auto pos = _name.find(':');
    if(pos != Glib::ustring::npos)
    {
	prefix = _name.substr(0, pos);
	name = _name.substr(pos + 1);
    }

    auto *el = doc.get_root_node();
    if(!el) el = doc.create_root_node();
    else el = context.top()->add_child(name, prefix);
    context.push(el);

    for(auto itr = _attributes.begin(); itr != _attributes.end(); ++itr)
    {
	Glib::ustring name = itr->name;
	Glib::ustring value = itr->value;
	auto pos = name.find(':');
	if(pos == Glib::ustring::npos)
	{
	    if(name == "xmlns") el->set_namespace_declaration(value);
	    else el->set_attribute(name, value);
	}
	else
	{
	    Glib::ustring prefix = name.substr(0, pos);
	    Glib::ustring suffix = name.substr(pos + 1);
	    if(prefix == "xmlns") el->set_namespace_declaration(value, suffix);
	    else el->set_attribute(suffix, value, prefix);
	}
    }
}
Esempio n. 6
0
void
AttributedNode::addAttributes( const AttributeList& attrs )
{
    for( AttributeList::const_iterator i = attrs.begin(); i != attrs.end(); i++ )
    {
        this->setAttribute( *i );
    }
}
Esempio n. 7
0
string Renderer::generateAttributes(const AttributeList& attributes)
{
	string str;
	AttributeList::const_iterator itr;
	for(itr = attributes.begin();itr!=attributes.end();itr++)
	{
		str += (" " + itr->first + "=\"" + itr->second + "\" ");
	}
	return str;
}
Esempio n. 8
0
string View::generateAttributes(AttributeList attributes)
{
	string str;
	AttributeList::iterator itr;
	for(itr = attributes.begin();itr!=attributes.end();itr++)
	{
		str += (" " + itr->first + "=\"" + itr->second + "\" ");
	}
	return str;
}
Esempio n. 9
0
 virtual void on_start_element(const Glib::ustring & name, 
     const AttributeList & properties) {
   path.push_back(getId(name));
   vector<uint> rpath;
   rpath.insert(rpath.end(),path.rbegin(),path.rend());
   trie.insertPath(rpath,fake_id++);
   rpath.insert(rpath.begin(),0);
   for(AttributeList::const_iterator iter=properties.begin(); iter!=properties.end(); ++iter) {
     rpath[0] = getId(iter->name);
     trie.insertPath(rpath,fake_id++);
   }
 }
void 
TL_Xml2Array::on_start_element(const string& name_,
	const AttributeList& attributes_)
{
	_startElement=true;
	TL_AssocArray &newKey = (*_table)(name_);

	xmlpp::SaxParser::AttributeList::const_iterator iter;
	for(iter = attributes_.begin(); iter != attributes_.end(); ++iter)
	{
		newKey.attr[iter->name] = iter->value;
	}
	_table = &newKey;
}
Esempio n. 11
0
static String AttrList2String(const AttributeList& attr_list)
{
    String result;
    AttributeList::const_iterator it = attr_list.begin();
    for (; it != attr_list.end(); ++it) {
        std::stringstream ss;
        ss << (int)it->get_type() << ':';
        ss << it->get_start() << ':';
        ss << it->get_length() << ':';
        ss << it->get_value() << ';';
        result += ss.str();
    }
    return result;
}
Esempio n. 12
0
/**
 Lee el xml y asigna los valores a los atributos
 @param name nombre del atributo
 @param attributes lista de atributos del xml
 */
void XmlCache::on_start_element(const Glib::ustring& name, const AttributeList& attributes)
{	
	string aux = "";
	
	//Atributos
	for(xmlpp::SaxParser::AttributeList::const_iterator iter = attributes.begin(); iter != attributes.end(); ++iter)
	{
		try
		{
			if(iter->name == "nombre_imagen")
			{
				cacheI->push_back(iter->value);
			}
		}
		catch(const Glib::ConvertError& ex)
		{
			//cerr<<"XmlParse atributos Excepcion obteniendo el nombre o valor"<<ex.what()<<endl;
			cerr<<"XmlParse attributes, Exception while obtaining name or value"<<ex.what()<<endl;
		}
	}
}
void AIScript::beginElement( const string &name, const AttributeList &attributes )
{
    using namespace AiXml;
    xml->itts = false;
    Unit *tmp;
#ifdef AIDBG
    VSFileSystem::vs_fprintf( stderr, "0" );
#endif
    Names elem = (Names) element_map.lookup( name );
#ifdef AIDBG
    VSFileSystem::vs_fprintf( stderr, "1%x ", &elem );
#endif
    AttributeList::const_iterator iter;
    switch (elem)
    {
    case DEFAULT:
        xml->unitlevel += 2;         //pretend it's at a reasonable level
        break;
    case UNKNOWN:
        xml->unitlevel++;
        return;
    case SCRIPT:
        xml->unitlevel++;
        break;
    case LINEAR:
        xml->lin = 1;
    case ANGULAR:
    case VECTOR:
        xml->unitlevel++;
        xml->vectors.push( QVector( 0, 0, 0 ) );
        for (iter = attributes.begin(); iter != attributes.end(); iter++) {
            switch ( attribute_map.lookup( (*iter).name ) )
            {
            case X:
                topv().i = parse_float( (*iter).value );
                break;
            case Y:
                topv().j = parse_float( (*iter).value );
                break;
            case Z:
                topv().k = parse_float( (*iter).value );
                break;
            case DUPLIC:
#ifdef AIDBG
                VSFileSystem::vs_fprintf( stderr, "1%x ", &elem );
#endif
                xml->vectors.pop();                 //get rid of dummy vector pushed on above
                xml->vectors.push( xml->vectors.top() );
                break;
            case THREATPOS:
                if ( ( tmp = this->parent->Threat() ) ) {
                    topv() = ( tmp->Position() );
                } else {
                    if ( ( tmp = this->parent->Target() ) )
                        topv() = ( tmp->Position() );
                    else
                        topv() = (xml->defaultvec);
                }
                break;
            case TARGETPOS:
                if ( ( tmp = this->parent->Target() ) )
                    topv() = ( tmp->Position() );
                else
                    topv() = (xml->defaultvec);
                break;

            case YOURPOS:
                topv() = ( this->parent->Position() );
                break;

            case THREATV:
                if ( ( tmp = this->parent->Threat() ) ) {
                    topv() = ( tmp->GetVelocity() );
                } else {
                    if ( ( tmp = this->parent->Target() ) )
                        topv() = ( tmp->GetVelocity() );
                    else
                        topv() = (xml->defaultvec);
                }
                break;
            case TARGETV:
                if ( ( tmp = this->parent->Target() ) )
                    topv() = ( tmp->GetVelocity() );
                else
                    topv() = (xml->defaultvec);
                break;

            case YOURV:
                topv() = ( this->parent->GetVelocity() );
                break;
            }
        }
        break;
    case MOVETO:
        xml->unitlevel++;
        xml->acc = 2;
        xml->afterburn = true;
        for (iter = attributes.begin(); iter != attributes.end(); iter++) {
            switch ( attribute_map.lookup( (*iter).name ) )
            {
            case AFTERBURN:
                xml->afterburn = parse_bool( (*iter).value );
            case ACCURACY:
                xml->acc = parse_int( (*iter).value );
                break;
            }
        }
        break;
    case FACETARGET:
#ifdef AIDBG
        VSFileSystem::vs_fprintf( stderr, "ft" );
#endif
        xml->unitlevel++;
        xml->acc  = 3;
        xml->itts = false;
        xml->afterburn = true;
        xml->terminate = true;
        for (iter = attributes.begin(); iter != attributes.end(); iter++) {
            switch ( attribute_map.lookup( (*iter).name ) )
            {
            case TERMINATE:
                xml->terminate = parse_bool( (*iter).value );
                break;
            case ACCURACY:
                xml->acc  = parse_int( (*iter).value );
                break;
            case ITTTS:
                xml->itts = parse_bool( (*iter).value );
                break;
            }
        }
#ifdef AIDBG
        VSFileSystem::vs_fprintf( stderr, "eft" );
#endif

        break;

    case CHANGEHEAD:
        xml->unitlevel++;
        xml->acc = 2;
        xml->afterburn = true;
        xml->terminate = true;
        for (iter = attributes.begin(); iter != attributes.end(); iter++) {
            switch ( attribute_map.lookup( (*iter).name ) )
            {
            case TERMINATE:
                xml->terminate = parse_bool( (*iter).value );
                break;
            case ACCURACY:
                xml->acc = parse_int( (*iter).value );
                break;
            }
        }
        break;
    case YOURPOS:
        xml->unitlevel++;
        xml->vectors.push( this->parent->Position() );

        break;
    case THREATWORLD:
        xml->unitlevel++;
        break;
    case TARGETWORLD:
        xml->unitlevel++;
        break;
    case THREATLOCAL:
        xml->unitlevel++;
        break;
    case TARGETLOCAL:
        xml->unitlevel++;
        break;
    case YOURLOCAL:
        xml->unitlevel++;
        break;
    case YOURWORLD:
        xml->unitlevel++;
        break;

    case NORMALIZE:
    case SCALE:
    case CROSS:
    case DOT:
    case MULTF:
    case ADDF:
    case FROMF:
    case TOF:
    case ADD:
    case SUB:
    case NEG:
        xml->unitlevel++;
        break;

    case FFLOAT:
        xml->unitlevel++;
        xml->floats.push( 0 );
        for (iter = attributes.begin(); iter != attributes.end(); iter++) {
            switch ( attribute_map.lookup( (*iter).name ) )
            {
            case VALUE:
                topf() = parse_float( (*iter).value );
                break;
            case SIMATOM:
                topf() = SIMULATION_ATOM;
            case DUPLIC:
                xml->floats.pop();                 //get rid of dummy vector pushed on above
                xml->floats.push( xml->floats.top() );
                break;
            }
        }
        break;
    case MATCHLIN:
    case MATCHANG:
    case MATCHVEL:
#ifdef AIDBG
        VSFileSystem::vs_fprintf( stderr, "mlv" );
#endif

        xml->unitlevel++;
        xml->acc = 0;
        xml->afterburn = false;
        xml->terminate = true;
        for (iter = attributes.begin(); iter != attributes.end(); iter++) {
            switch ( attribute_map.lookup( (*iter).name ) )
            {
            case AFTERBURN:
                xml->afterburn = parse_bool( (*iter).value );
                break;
            case TERMINATE:
                xml->terminate = parse_bool( (*iter).value );
                break;
            case LOCAL:
                xml->acc = parse_bool( (*iter).value );
                break;
            }
        }
#ifdef AIDBG
        VSFileSystem::vs_fprintf( stderr, "emlv " );
#endif

        break;
    case CLOAKFOR:
        xml->unitlevel++;
        xml->executefor.push_back( 0 );
        xml->terminate = true;
        for (iter = attributes.begin(); iter != attributes.end(); iter++) {
            switch ( attribute_map.lookup( (*iter).name ) )
            {
            case TERMINATE:
                xml->terminate = parse_bool( (*iter).value );
                break;
            case TIME:
                xml->executefor.back() = parse_float( (*iter).value );
                break;
            }
        }
        break;
    case EXECUTEFOR:
        xml->unitlevel++;
        xml->executefor.push_back( 0 );
        for (iter = attributes.begin(); iter != attributes.end(); iter++) {
            switch ( attribute_map.lookup( (*iter).name ) )
            {
            case TIME:
                xml->executefor.back() = parse_float( (*iter).value );
                break;
            }
        }
        break;

    default:

        break;
    }
}
retval_t ScimBridgeAgentClientListenerImpl::set_preedit_attributes (scim_bridge_imcontext_id_t imcontext_id, const AttributeList &attributes)
{
    scim_bridge_pdebugln (6, "set_preedit_attributes ()");

    ScimBridgeMessage *message = scim_bridge_alloc_message (SCIM_BRIDGE_MESSAGE_SET_PREEDIT_ATTRIBUTES, attributes.size () * 4 + 1);

    char *imcontext_id_str;
    scim_bridge_string_from_uint (&imcontext_id_str, imcontext_id);
    scim_bridge_message_set_argument (message, 0, imcontext_id_str);
    free (imcontext_id_str);

    int arg_index = 1;
    for (AttributeList::const_iterator i = attributes.begin (); i != attributes.end (); ++i) {
        const Attribute &attribute = *i;

        char *begin_str;
        char *end_str;
        scim_bridge_string_from_uint (&begin_str, attribute.get_start ());
        scim_bridge_string_from_uint (&end_str, attribute.get_end ());

        const char *type_str;
        const char *value_str;

        if (attribute.get_type () == SCIM_ATTR_DECORATE) {
            type_str = SCIM_BRIDGE_MESSAGE_DECORATE;
            switch (attribute.get_value ()) {
                case SCIM_ATTR_DECORATE_UNDERLINE:
                    value_str = SCIM_BRIDGE_MESSAGE_UNDERLINE;
                    break;
                case SCIM_ATTR_DECORATE_REVERSE:
                    value_str = SCIM_BRIDGE_MESSAGE_REVERSE;
                    break;
                case SCIM_ATTR_DECORATE_HIGHLIGHT:
                    value_str = SCIM_BRIDGE_MESSAGE_HIGHLIGHT;
                    break;
                default:
                    type_str = SCIM_BRIDGE_MESSAGE_NONE;
                    value_str = SCIM_BRIDGE_MESSAGE_NONE;
            }
        } else if (attribute.get_type () == SCIM_ATTR_FOREGROUND || attribute.get_type () == SCIM_ATTR_BACKGROUND) {
            if (attribute.get_type () == SCIM_ATTR_FOREGROUND) {
                type_str = SCIM_BRIDGE_MESSAGE_FOREGROUND;
            } else {
                type_str = SCIM_BRIDGE_MESSAGE_BACKGROUND;
            }
            char *tmp_str = static_cast<char*> (alloca (sizeof (char) * (strlen (SCIM_BRIDGE_MESSAGE_COLOR) + 7)));
            value_str = tmp_str;
            strcpy (tmp_str, SCIM_BRIDGE_MESSAGE_COLOR);
            char *color_str = tmp_str + sizeof (char) * strlen (SCIM_BRIDGE_MESSAGE_COLOR);
            color_str[6] = '\0';
            const char chars[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
            for (unsigned int k = 0; k < 6; ++k) {
                const unsigned int digit_index = (attribute.get_value () >> (k * 4)) % 0x10;
                color_str[5 - k] = chars[digit_index];
            }
        } else {
            type_str = SCIM_BRIDGE_MESSAGE_NONE;
            value_str = SCIM_BRIDGE_MESSAGE_NONE;
        }

        scim_bridge_message_set_argument (message, arg_index + 0, begin_str);
        scim_bridge_message_set_argument (message, arg_index + 1, end_str);
        scim_bridge_message_set_argument (message, arg_index + 2, type_str);
        scim_bridge_message_set_argument (message, arg_index + 3, value_str);

        free (begin_str);
        free (end_str);

        arg_index += 4;
    }
void GameCockpit::beginElement(const string &name, const AttributeList &attributes) {
  static bool cockpit_smooth=XMLSupport::parse_bool(vs_config->getVariable("graphics","cockpit_smooth_texture","false"));
  static bool panel_smooth=XMLSupport::parse_bool(vs_config->getVariable("graphics","panel_smooth_texture","true"));
  static bool crosshair_smooth=XMLSupport::parse_bool(vs_config->getVariable("graphics","crosshair_smooth_texture","true"));
  AttributeList::const_iterator iter;
  Gauge::DIRECTION tmpdir=Gauge::GAUGE_UP;
  VSSprite ** newsprite=NULL;
  VDU **newvdu=NULL;
  VSSprite * adjsprite=NULL;
  std::string gaugename ("shieldstat.spr");
  std::string myfont ("9x12.font");
  Names elem = (Names)element_map.lookup(name);
  Names attr;
  unsigned int mymodes=0;
  float xsize=-1,ysize=-1,xcent=FLT_MAX,ycent=FLT_MAX;
  float leftx=-10;  float rightx=-10;
  float topy=-10; float boty = -10;
  short rows=13;
  short cols=15;
  int default_mode=VDU::TARGET;
  VSSprite * oldpit=NULL;
  bool replaced[4]={false,false,false,false};
  int counter=0;
  switch (elem) {
  case COCKPIT:
    for(iter = attributes.begin(); iter!=attributes.end(); iter++) { 
      attr = (Names)attribute_map.lookup((*iter).name);
      switch (attr) {
      case MYFONT:
	myfont = (*iter).value;
	break;
      case RED:
	textcol.r = XMLSupport::parse_float ((*iter).value);
	break;
      case GREEN:
	textcol.g = XMLSupport::parse_float ((*iter).value);
	break;
      case BLUE:
	textcol.b = XMLSupport::parse_float ((*iter).value);
	break;
      case ALPH:
        textcol.a=XMLSupport::parse_float ((*iter).value);
        break;
      case VIEWOFFSET:
		  viewport_offset = XMLSupport::parse_float ((*iter).value);
	break;
      case COCKPITOFFSET:
		  cockpit_offset = XMLSupport::parse_float ((*iter).value);
	break;
      case XFILE:
        {
          std::string tmp=getRes((*iter).value);
          oldpit=Pit[0];
          Pit[0]= new VSSprite (tmp.c_str(),cockpit_smooth?BILINEAR:NEAREST);
          if (!Pit[0]->LoadSuccess()){
            delete Pit[0];
            Pit[0]= new VSSprite ((*iter).value.c_str(),cockpit_smooth?BILINEAR:NEAREST);
          }
          replaced[0]=true;
          if (oldpit) {

            delete oldpit;
          }
        }
	break;
      case SOUNDFILE:
	SetSoundFile((*iter).value);
	break;
      case MESH:
		  mesh = Mesh::LoadMeshes ((*iter).value.c_str(),Vector(1,1,1),0,NULL);
	break;
      case FRONT:
      case BACK:
      case LEFT:
      case RIGHT:
        {
          std::string tmp=getRes((*iter).value);
          oldpit=Pit[attr-FRONT];
          Pit[attr-FRONT] = new VSSprite (tmp.c_str(),cockpit_smooth?BILINEAR:NEAREST);
          if (!Pit[attr-FRONT]->LoadSuccess()) {
            delete Pit[attr-FRONT];
            Pit[attr-FRONT] = new VSSprite ((*iter).value.c_str(),cockpit_smooth?BILINEAR:NEAREST);
          }
          replaced[attr-FRONT]=true;
          if (oldpit){

            delete oldpit;
          }
        }
	break;
	  default:
		  break;
      } 
    }
    text = new TextPlane ();
    for (counter=0;counter<4;++counter) {
      if (!replaced[counter]) {
        delete Pit[counter];
        Pit[counter]=false;
      }
    }
    break;
  case UnitImages::SHIELD4:
  case UnitImages::SHIELD5:
  case UnitImages::SHIELD6:
  case UnitImages::SHIELD7:
    shield8=true;
    goto pastarmor8;
  case UnitImages::ARMOR4:
  case UnitImages::ARMOR5:
  case UnitImages::ARMOR6:
  case UnitImages::ARMOR7:
    armor8=true;
  pastarmor8:
  case UnitImages::JUMP:
  case UnitImages::MISSILELOCK:
  case UnitImages::ECM:
  case UnitImages::ARMORF:
  case UnitImages::ARMORR:
  case UnitImages::ARMORL:
  case UnitImages::ARMORB:
  case UnitImages::FUEL:
  case UnitImages::SHIELDF:
  case UnitImages::SHIELDL:
  case UnitImages::SHIELDR:
  case UnitImages::SHIELDB:
  case UnitImages::TARGETSHIELDF:
  case UnitImages::TARGETSHIELDB:
  case UnitImages::TARGETSHIELDR:
  case UnitImages::TARGETSHIELDL:
  case UnitImages::ENERGY:
  case UnitImages::WARPENERGY:
  case UnitImages::EJECT:
  case UnitImages::LOCK:
  case UnitImages::HULL:
  case UnitImages::KPS:
  case UnitImages::SETKPS:
  case UnitImages::AUTOPILOT:
  case UnitImages::COLLISION:
  case UnitImages::COCKPIT_FPS:
  case UnitImages::WARPFIELDSTRENGTH:
  case UnitImages::MASSEFFECT:
  case UnitImages::AUTOPILOT_MODAL:
  case UnitImages::SPEC_MODAL:
  case UnitImages::FLIGHTCOMPUTER_MODAL:
  case UnitImages::TURRETCONTROL_MODAL:
  case UnitImages::ECM_MODAL:
  case UnitImages::CLOAK_MODAL:
  case UnitImages::TRAVELMODE_MODAL:
  case UnitImages::RECIEVINGFIRE_MODAL:
  case UnitImages::RECEIVINGMISSILES_MODAL:
  case UnitImages::RECEIVINGMISSILELOCK_MODAL:
  case UnitImages::RECEIVINGTARGETLOCK_MODAL:
  case UnitImages::COLLISIONWARNING_MODAL:
  case UnitImages::CANJUMP_MODAL:
  case UnitImages::CANDOCK_MODAL:
    for(iter = attributes.begin(); iter!=attributes.end(); iter++) { 
      switch (attribute_map.lookup((*iter).name)) {
      case XFILE:
	gaugename = (*iter).value;
	break;
      case NETWORK:
        if ((Network!=NULL)!=XMLSupport::parse_bool((*iter).value)) {
          return; // Don't show if not in multiplayer (or single if false)
        }
        break;
      case TOPY:
	topy = XMLSupport::parse_float ((*iter).value);
	break;
      case BOTY:
	boty = XMLSupport::parse_float ((*iter).value);
	break;
      case LEFT:
	leftx = XMLSupport::parse_float ((*iter).value);
	break;
      case RIGHT:
	rightx = XMLSupport::parse_float ((*iter).value);
	break;
      case XSIZE:
	xsize = XMLSupport::parse_float ((*iter).value);
	break;
      case YSIZE:
	ysize = XMLSupport::parse_float ((*iter).value);
	break;
      case XCENT:
	xcent = XMLSupport::parse_float ((*iter).value);
	break;
      case YCENT:
	ycent = XMLSupport::parse_float ((*iter).value);
	break;
      case G_UP:
	tmpdir = Gauge::GAUGE_UP;
	break;
      case G_DOWN:
	tmpdir = Gauge::GAUGE_DOWN;
	break;
      case G_LEFT:
	tmpdir = Gauge::GAUGE_LEFT;
	break;
      case G_RIGHT:
	tmpdir = Gauge::GAUGE_RIGHT;
    break;
      case G_TIME:
    tmpdir = Gauge::GAUGE_TIME;
	break;
      }
    };
    gauges[elem] = new Gauge (gaugename.c_str(), tmpdir);
    if (xsize!=-1) {
      gauges[elem]->SetSize (xsize,ysize);
    }
    if (xcent!=FLT_MAX) {
      gauges[elem]->SetPosition (xcent,ycent);
    }
    if (leftx!=-10&&rightx!=-10&&topy!=-10&&boty!=-10) {
      gauges[elem]->SetPosition (.5*(leftx+rightx),.5*(topy+boty));
      gauges[elem]->SetSize (fabs(leftx-rightx),fabs(topy-boty));
    }
    break;
  case CROSSHAIRS:
  case PANEL: 
    if (elem==CROSSHAIRS) {
        if (Panel.size()==0)
            Panel.push_back(NULL);
        if (Panel.front()) {
            delete Panel.front();
            Panel.front() = NULL;
        }
        newsprite = &Panel.front();
    } else {
        if (Panel.size()==0) /* Create NULL crosshairs */
            Panel.push_back(NULL);
        Panel.push_back(NULL);
        newsprite = &Panel.back();
    }
    goto loadsprite;
  case RADAR: newsprite = &Radar[0];goto loadsprite;
  case REARRADAR: newsprite = &Radar[1];goto loadsprite;
  case LVDU: vdu.push_back(NULL);newvdu = &vdu.back();mymodes=VDU::MANIFEST|VDU::WEAPON|VDU::DAMAGE|VDU::OBJECTIVES|VDU::SHIELD;default_mode=VDU::OBJECTIVES;
#ifdef NETCOMM_WEBCAM
		mymodes = mymodes | VDU::WEBCAM;
#endif
  	if( Network!=NULL)
		mymodes = mymodes | VDU::NETWORK;
	goto loadsprite;
  case RVDU: vdu.push_back(NULL);newvdu = &vdu.back();mymodes=VDU::TARGETMANIFEST|VDU::NAV|VDU::TARGET;default_mode=VDU::TARGET;
  goto loadsprite;
  case AVDU:vdu.push_back(NULL);newvdu = &vdu.back();mymodes=VDU::MSG;
    for(iter = attributes.begin(); iter!=attributes.end(); iter++) { 
      switch (attribute_map.lookup((*iter).name)) {
      case VDUTYPE:
        {
          mymodes=parse_vdu_type ((*iter).value.c_str());
          std::string firstmode=(*iter).value.substr(0,(*iter).value.find(" "));
          default_mode=parse_vdu_type(firstmode.c_str());
        }
        break;
      default:
	break;
      }
    }
    goto loadsprite;
  loadsprite:
    for(iter = attributes.begin(); iter!=attributes.end(); iter++) { 
      switch (attribute_map.lookup((*iter).name)) {
      case NETWORK:
        if ((Network!=NULL)!=XMLSupport::parse_bool((*iter).value)) {
          return; // Don't show if not in multiplayer (or single if false)
        }
        break;
      case XFILE:
	if (newsprite) {
          std::string tmp=getRes((*iter).value);
          bool bil=elem==PANEL?panel_smooth:crosshair_smooth;
          (*newsprite) = new VSSprite (tmp.c_str(),bil?BILINEAR:NEAREST);
          if (!(*newsprite)->LoadSuccess()) {
            delete (*newsprite);
            (*newsprite) = new VSSprite ((*iter).value.c_str(),bil?BILINEAR:NEAREST);
          }
	  adjsprite = *newsprite;
	} else if (newvdu) {
          VDU * tmp=new VDU ((*iter).value.c_str(),text,mymodes,rows,cols,&StartArmor[0],&maxhull);         
	  (*newvdu) =  tmp;
	  adjsprite = *newvdu;
          if (tmp->getMode()!=default_mode)
            for (int i=0;i<32;++i) {
              tmp->SwitchMode(NULL);
              if (tmp->getMode()==default_mode)
                break;
            }
	}
	break;
      case TOPY:
	topy = XMLSupport::parse_float ((*iter).value);
	break;
      case BOTY:
	boty = XMLSupport::parse_float ((*iter).value);
	break;
      case LEFT:
	leftx = XMLSupport::parse_float ((*iter).value);
	break;
      case RIGHT:
	rightx = XMLSupport::parse_float ((*iter).value);
	break;
      case XSIZE:
	xsize = XMLSupport::parse_float ((*iter).value);
	break;
      case YSIZE:
	ysize = XMLSupport::parse_float ((*iter).value);
	break;
      case XCENT:
	xcent = XMLSupport::parse_float ((*iter).value);
	break;
      case YCENT:
	ycent = XMLSupport::parse_float ((*iter).value);
	break;
      case ROWS:
	rows =  XMLSupport::parse_int ((*iter).value);
	break;
      case COLS:
	cols = XMLSupport::parse_int ((*iter).value);
	break;
	break;

      }
    }
    if (adjsprite) {
      if (xsize!=-1) {
	adjsprite->SetSize (xsize,ysize);
      }
      if (xcent!=FLT_MAX) {
	adjsprite->SetPosition (xcent,ycent);
      }
      if (leftx!=-10&&rightx!=-10&&topy!=-10&&boty!=-10) {
	adjsprite->SetPosition (.5*(leftx+rightx),.5*(topy+boty));
	adjsprite->SetSize (fabs(leftx-rightx),fabs(topy-boty));
      }
    } else {
      if (newsprite==&Panel.back()) {
	Panel.erase (Panel.end()-1);//don't want null panels
      }
    }
    break;
  default:
	  break;
  }
  
}
Esempio n. 16
0
/**
 Lee el xml y asigna los valores a los atributos
 @param name nombre del atributo
 @param attributes lista de atributos del xml
 */
void XmlPreferencias::on_start_element(const Glib::ustring& name, const AttributeList& attributes)
{	
	string aux = "";

	nodeName = name;
	
	if(name == "clase")
	{
		//Atributos
		for(xmlpp::SaxParser::AttributeList::const_iterator iter = attributes.begin(); iter != attributes.end(); ++iter)
		{
			try
			{
				if(iter->name == "etiqueta")
				{
					clCell->setEtiquetaClasificacion(iter->value);
				}
				if(iter->name == "nombre")
				{
					clCell->setNombreClasificacion(iter->value);
				}
				if(iter->name == "descripcion")
				{
					clCell->setDescripcionClasificacion(iter->value);
				}
				if(iter->name == "enUso")
				{
					if(iter->value == "true")
					{
						clCell->setEnUso(true);
					}
					else
					{
						clCell->setEnUso(false);
					}
				}
				if(iter->name == "linea")
				{
					aux = iter->value;
					clCell->setLinea(atoi(aux.data()));
				}
			}
			catch(const Glib::ConvertError& ex)
			{
				//cerr<<"XmlParse atributos Excepcion obteniendo el nombre o valor"<<ex.what()<<endl;
				cerr<<"XmlParse attributes, Exception while obtaining name or value"<<ex.what()<<endl;
			}
		}
	}
	else if(name == "estado")
	{
		//Atributos
		for(xmlpp::SaxParser::AttributeList::const_iterator iter = attributes.begin(); iter != attributes.end(); ++iter)
		{
			try
			{
				if(iter->name == "etiqueta")
				{
					estCell->setEtiquetaClasificacion(iter->value);
				}
				if(iter->name == "nombre")
				{
					estCell->setNombreClasificacion(iter->value);
				}
				if(iter->name == "descripcion")
				{
					estCell->setDescripcionClasificacion(iter->value);
				}
				if(iter->name == "enUso")
				{
					if(iter->value == "true")
					{
						estCell->setEnUso(true);
					}
					else
					{
						estCell->setEnUso(false);
					}
				}
				if(iter->name == "rojo")
				{
					aux = iter->value;
					col->set_red(atoi(aux.data()));
				}
				if(iter->name == "verde")
				{
					aux = iter->value;
					col->set_green(atoi(aux.data()));
				}
				if(iter->name == "azul")
				{
					aux = iter->value;
					col->set_blue(atoi(aux.data()));
				}
			}
			catch(const Glib::ConvertError& ex)
			{
				//cerr<<"XmlParse atributos Excepcion obteniendo el nombre o valor"<<ex.what()<<endl;
				cerr<<"XmlParse attributes, Exception while obtaining name or value"<<ex.what()<<endl;
			}
		}
	}
	else if(name == "rejilla")
	{
		//Atributos
		for(xmlpp::SaxParser::AttributeList::const_iterator iter = attributes.begin(); iter != attributes.end(); ++iter)
		{
			try
			{
				if(iter->name == "id")
				{
					aux = iter->value;
					rejPers->setID(atoi(aux.data()));
				}
				if(iter->name == "numero_Filas")
				{
					aux = iter->value;
					rejPers->setNumFilas(atoi(aux.data()));
				}
				if(iter->name == "numero_Columnas")
				{
					aux = iter->value;
					rejPers->setNumColumnas(atoi(aux.data()));
				}
				if(iter->name == "numero_Puntos")
				{
					aux = iter->value;
					rejPers->setNumPuntos(atoi(aux.data()));
				}
				if(iter->name == "separacion_puntos")
				{
					aux = iter->value;
					rejPers->setSeparaPuntos(atoi(aux.data()));
				}
			}
			catch(const Glib::ConvertError& ex)
			{
				//cerr<<"XmlParse atributos Excepcion obteniendo el nombre o valor"<<ex.what()<<endl;
				cerr<<"XmlParse attributes, Exception while obtaining name or value"<<ex.what()<<endl;
			}
		}
	}
	else if(name == "pref")
	{
		//Atributos
		for(xmlpp::SaxParser::AttributeList::const_iterator iter = attributes.begin(); iter != attributes.end(); ++iter)
		{
			try
			{
				if(iter->name == "rojo")
				{
					aux = iter->value;
					col->set_red(atoi(aux.data()));
				}
				if(iter->name == "verde")
				{
					aux = iter->value;
					col->set_green(atoi(aux.data()));
				}
				if(iter->name == "azul")
				{
					aux = iter->value;
					col->set_blue(atoi(aux.data()));
				}
				if(iter->name == "linea")
				{
					aux = iter->value;
					opcPref->setGrosLinea(atof(aux.data()));
				}
				if(iter->name == "puntos")
				{
					aux = iter->value;
					opcPref->setGrosLinea(atof(aux.data()));
				}
				if(iter->name == "imagenes")
				{
					opcPref->setArchivImag(iter->value);
				}
				if(iter->name == "celulas")
				{
					opcPref->setArchivCel(iter->value);
				}
				if(iter->name == "csv")
				{
					opcPref->setArchivCSV(iter->value);
				}
			}
			catch(const Glib::ConvertError& ex)
			{
				//cerr<<"XmlParse atributos Excepcion obteniendo el nombre o valor"<<ex.what()<<endl;
				cerr<<"XmlParse attributes, Exception while obtaining name or value"<<ex.what()<<endl;
			}
		}
	}
	else
	{
		//Atributos
		for(xmlpp::SaxParser::AttributeList::const_iterator iter = attributes.begin(); iter != attributes.end(); ++iter)
		{
			try
			{
				if(iter->name == "linea")
				{
					aux = iter->value;
					opcPref->setGrosLinea(atof(aux.data()));
				}
				if(iter->name == "puntos")
				{
					aux = iter->value;
					opcPref->setGrosLinea(atof(aux.data()));
				}
				if(iter->name == "imagenes")
				{
					opcPref->setArchivImag(iter->value);
				}
				if(iter->name == "celulas")
				{
					opcPref->setArchivCel(iter->value);
				}
				if(iter->name == "csv")
				{
					opcPref->setArchivCSV(iter->value);
				}
				if(iter->name == "rejilla_completa")
				{
					aux = iter->value;
					opcPref->setGrosRej(atof(aux.data()));
				}
				if(iter->name == "borde_rejilla_completa")
				{
					aux = iter->value;
					opcPref->setGrosBordeRej(atof(aux.data()));
				}
				if(iter->name == "puntos_rejilla_completa")
				{
					aux = iter->value;
					opcPref->setSeparPuntos(atof(aux.data()));
				}
				if(iter->name == "loginBD")
				{
					opcPref->setLoginBD(iter->value);
				}
				if(iter->name == "passwordBD")
				{
					opcPref->setPassBD(iter->value);
				}
				if(iter->name == "urlBD")
				{
					opcPref->setDirecBD(iter->value);
				}
				if(iter->name == "nombreBD")
				{
					opcPref->setDataBaseBD(iter->value);
				}
				if(iter->name == "loginSFTP")
				{
					opcPref->setLoginSFTP(iter->value);
				}
				if(iter->name == "passwordSFTP")
				{
					opcPref->setPassSFTP(iter->value);
				}
				if(iter->name == "urlSFTP")
				{
					opcPref->setDirecSFTP(iter->value);
				}
				if(iter->name == "pathSFTP")
				{
					opcPref->setPathSFTP(iter->value);
				}
				if(iter->name == "tamanho")
				{
					aux = iter->value;
					opcPref->setTamCache(atoi(aux.data()));
				}
			}
			catch(const Glib::ConvertError& ex)
			{
				//cerr<<"XmlParse atributos Excepcion obteniendo el nombre o valor"<<ex.what()<<endl;
				cerr<<"XmlParse attributes, Exception while obtaining name or value"<<ex.what()<<endl;
			}
		}
	}
}
void FSM::beginElement( const string &name, const AttributeList attributes )
{
    using namespace CommXML;
    AttributeList::const_iterator iter;
    Names  elem  = (Names) element_map.lookup( name );
    string nam;
    string filename;
    float  val = 0.0f;  //FIXME "= 0.0f" added by chuck_starchaser without knowing what value to use
    unsigned char sexe = 0; //FIXME "= 0" added by chuck_starchaser without knowing what value to use
    switch (elem)
    {
    case SOUND:
        val = 1.0f;
        for (iter = attributes.begin(); iter != attributes.end(); iter++) {
            switch ( attribute_map.lookup( (*iter).name ) )
            {
            case SEXE:
                sexe  = XMLSupport::parse_int( (*iter).value );
                break;
            case FILENAME:
                filename = (*iter).value;
                break;
            case GAIN:
                val = XMLSupport::parse_float( (*iter).value );
                break;
            }
        }
        if (!filename.empty())
            nodes.back().AddSound( filename, sexe, val ); //FIXME sexe was used uninitialized until I added = 0 --chuck_starchaser
        break;
    case UNKNOWN:
        unitlevel++;
        return;

    case NODE:
        {
            unitlevel++;
            vector< string > messages;
            for (iter = attributes.begin(); iter != attributes.end(); iter++) {
                if (strtoupper( (*iter).name ) == "RELATIONSHIP") {
                    val = parse_float( (*iter).value );
                } else {
                    string tmp = strtoupper( (*iter).name );
                    unsigned int num = 0;
                    if (1 == sscanf( tmp.c_str(), "TEXT%d", &num ) || tmp == "TEXT") {
                        while ( !( num < messages.size() ) )
                            messages.push_back( string() );
                        nam = (*iter).value;
                        {
                            for (string::iterator i = nam.begin(); i != nam.end(); i++)
                                if (*i == '\\')
                                    *i = '\n';
                        }
                        messages[num] = nam;
                    }
                }
            }
            nodes.push_back( Node( messages, val ) ); //FIXME val was used uninitialized until I added = 0 --chuck_starchaser
            break;
        }
    case EDGE:
        unitlevel++;
        for (iter = attributes.begin(); iter != attributes.end(); iter++)
            if ( ( attribute_map.lookup( (*iter).name ) ) == INDEX )
                nodes.back().edges.push_back( parse_int( (*iter).value ) );
        break;
    default:
        break;
    }
}
Esempio n. 18
0
ofxCssBlock ofxCss::parseAttributeList(ofxCssBlock* block, AttributeList list) {
	for ( AttributeList::const_iterator iter = list.begin(); iter != list.end(); ++iter ) {
		cout << iter->first << ": " << iter->second << endl;
		parseAttribute(block, iter->first, iter->second);
	}
}