Example #1
0
XMLFile::Tag::Tag(const Flux::string n, Flux::string conts)
{
  Name = n;
  Content = conts;
  for (unsigned i = 0; i < conts.size(); i++)
  {
    char c = conts.at(i);
    if (c == '<' && conts.at(i+1) != '/' && conts.at(i+1) != ' ')
    {
      bool SelfContained = false;
      std::string tag = "";
      std::string contents = "";
      for (unsigned j = 1;conts.at(i+j) != '>' && conts.at(i+j) != ' '; j++)
      {
	tag += conts.at(i+j);
      }
      for (unsigned o = 1; conts.at(i+o) != '>'; o++)
      {
	if ((conts.at(i+o) == '/' || conts.at(i+o) == '?') && conts.at(i+o+1) == '>')
	{
	  SelfContained = true;
	  break;
	}
      }
      if (!SelfContained)
      {
	for (unsigned k = conts.find('>',i)+1; k < conts.find("</"+tag,i); k++)
	{
	  contents += conts.at(k);
	}
      }
      Tag t(tag,contents);
      for (unsigned l = 1; conts.at(i+l) != '>'; l++)
      {
	char cc = conts.at(i+l);
	if (cc == '=' && conts.at(i+l+1) == '"')
	{
	  std::string attribName = "";
	  std::string attribVal = "";
	  for (int m = -1; conts.at(i+l+m) != ' '; m--)
	  {
	    attribName.insert(0,1,conts.at(i+l+m));
	  }
	  for (unsigned nn = 2; conts.at(i+l+nn) != '"'; nn++)
	  {
	    attribVal += conts.at(i+l+nn);
	  }
	  Tag::Attribute att(attribVal);
	  t.Attributes[attribName] = att;
	}
      }
      Tags[tag] = t;
      i += contents.size();
    }
  }
}
Example #2
0
/** Construct the object, sets everything to 0
 */
sockaddrs::sockaddrs(const Flux::string &address)
{
	this->clear();
	if (!address.empty())
		this->pton(address.find(':') != Flux::string::npos ? AF_INET6 : AF_INET, address);
}