예제 #1
0
파일: node.cpp 프로젝트: halbbob/dff
Attributes*			Node::attributes()
{
  Attributes* attr;
  std::set<AttributesHandler*>::iterator handler;
  Variant*	vptr = NULL;
  Attributes	nodeAttributes;


  attr = NULL;
  if ((attr = new std::map<std::string, Variant*>) != NULL)
    {
      if ((vptr = this->dataType()) != NULL)
        attr->insert(std::pair<std::string, Variant*>(std::string("type"), vptr));

      if (this->__fsobj != NULL)
	{
	  nodeAttributes = this->_attributes();
	  if (!nodeAttributes.empty())
	    {
	      if ((vptr = new Variant(nodeAttributes)) != NULL)
	       	attr->insert(std::pair<std::string, Variant*>(this->__fsobj->name, vptr));
	    }
	}
      for (handler = this->__attributesHandlers.begin(); handler != this->__attributesHandlers.end(); handler++)
        {
          if ((vptr = new Variant((*handler)->attributes(this))) != NULL)
      	    attr->insert(std::pair<std::string, Variant*>((*handler)->name(), vptr));
        }
    }
  return attr;
}
예제 #2
0
파일: node.cpp 프로젝트: halbbob/dff
Attributes*			Node::attributesByType(uint8_t type, attributeNameType tname)
{
  Attributes*			attr;
  Attributes*			result;
  Attributes::iterator		attrit;
  Variant*			vptr;
  
  result = NULL;
  attr = NULL;
  if ((result = new Attributes) != NULL)
    {
      if ((attr = this->attributes()) != NULL)
	{
	  for (attrit = attr->begin(); attrit != attr->end(); attrit++)
	    {
	      vptr = new Variant(attrit->second);
	      result->insert(std::pair<std::string, Variant*>(attrit->first, vptr));
	      if (tname == ABSOLUTE_ATTR_NAME)
		this->attributesByTypeFromVariant(attrit->second, type, result, attrit->first);
	      else
		this->attributesByTypeFromVariant(attrit->second, type, result);
	      delete attrit->second;
	    }
	  delete attr;
	}
    }
  return result;
}
예제 #3
0
파일: xmlparser.cpp 프로젝트: godbyk/cppdom
   // parses tag attributes
   bool Parser::parseAttributes(Attributes& attr)
   {
      while(true)
      {
         ++mTokenizer;
         Token token1 = *mTokenizer;

         if (token1.isLiteral())
         {
            mTokenizer.putBack();
            return false;
         }

         // guru: get value name here
         std::string name = token1.getGeneric();

         ++mTokenizer;
         if (*mTokenizer != '=')
         {
            throw CPPDOM_ERROR(xml_attr_equal_expected, "");
         }

         ++mTokenizer;
         Token token2 = *mTokenizer;

         if (token2.isLiteral())
         {
            throw CPPDOM_ERROR(xml_attr_value_expected, "");
         }

         // remove "" from attribute value
         std::string value(token2.getGeneric());
         value.erase(0, 1);
         value.erase(value.length()-1, 1);

         // Clean up any escaping in value
         if(textContainsXmlEscaping(value))
         {  value = removeXmlEscaping(value, false); }

         // insert attribute into the map
         // guru: we got the name already
         Attributes::value_type attrpair(name, value);
         attr.insert(attrpair);
      }
      return true;
   }
예제 #4
0
void Settings::save() {
	Attributes attr;
	attr.insert(std::pair<std::string,std::string>("username",username));
	attr.insert(std::pair<std::string,std::string>("chat_font",chat_font));
	attr.insert(std::pair<std::string,std::string>("menu_font",menu_font));
	attr.insert(std::pair<std::string,std::string>("server_address",serverAddress));
	attr.insert(std::make_pair("fpslimit",Tools::toString(fpsLimit)));
	
	attr.insert(std::pair<std::string,std::string>("Player_Red",Tools::toString((int)playerColor.r)));
	attr.insert(std::pair<std::string,std::string>("Player_Green",Tools::toString((int)playerColor.g)));
	attr.insert(std::pair<std::string,std::string>("Player_Blue",Tools::toString((int)playerColor.b)));

	std::fstream file;
	file.open("Settings.ini",std::ios_base::out);

	file << Tools::packAttributes(attr);

	file.close();
}