void cElementManager::handleClosingTag (const string &name)
{
  string n = lcase (name);
  if (!elementDefined (n))
  {
    results->addToList (results->createError ("Received unknown closing tag </" + n + ">!"));
    return;
  }
  if (emptyElement (n))
  {
    results->addToList (results->createError ("Received closing tag for tag " + n +
        ", which doesn't need a closing tag!"));
    return;
  }
  if (internalElement (n))
  {
    //if the name is an alias for another tag, change the name
    if (aliases.count (n))
      n = aliases[n];
    state->gotClosingTag (n);
  }
  else
  {
    //send closing flag, if needed
    if (!elements[n]->flag.empty())
      state->gotFlag (false, elements[n]->flag);
    
    //expand the closing tag...
    list<string>::iterator cit;
    for (cit = elements[n]->closingseq.begin(); cit != elements[n]->closingseq.end(); ++cit)
      handleClosingTag (*cit);
  }
}
示例#2
0
文件: ntlc.c 项目: TestKitMaster/Lib
long* sub(long* ele1, long* ele2, long index)
{
	int i=0;
	long *ele3=emptyElement(index);
	for(i=0;i<getDeg(index);i++)
		{
			ele3[i]=mod(ele1[i]-ele2[i]+getQ(index),index);
		}
	return ele3;
}
示例#3
0
文件: ntlc.c 项目: TestKitMaster/Lib
long* mult(long* ele1, long* ele2, long index)
{
	int i,m,pow;
	long *ele3=emptyElement(index);
		for(i=0;i<getDeg(index);i++)						//current power of ele 1
		{
			for(m=0;m<getDeg(index);m++)					//current power of ele 2
			{	pow=modDeg(i+m,index);							//calculate the new power of the product
				ele3[pow]=mod(ele3[pow]+ele1[i]*ele2[m],index);
			}
		}
	return ele3;
}
void cElementManager::gotNewLine ()
{
  if ((lastLineTag < 20) || (lastLineTag > 99))
  {
    lastLineTag = 0;
    return;
  }
  if (lineTags.count (lastLineTag) == 0)
  {
    lastLineTag = 0;
    return;
  }
  string tag = lineTags[lastLineTag];
  lastLineTag = 0;
  if (emptyElement (tag))
    //no closing tag needed
    return;
  //okay, send out the appropriate closing tag
  handleClosingTag (tag);
}
示例#5
0
void XMLWriter::dataElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname,
                             const XMLString& data,
	                         const XMLString& attr1, const XMLString& value1,
							 const XMLString& attr2, const XMLString& value2,
							 const XMLString& attr3, const XMLString& value3)
{
	AttributesImpl attributes;
	if (!attr1.empty()) attributes.addAttribute(XMLString(), XMLString(), attr1, CDATA, value1);
	if (!attr2.empty()) attributes.addAttribute(XMLString(), XMLString(), attr2, CDATA, value2);
	if (!attr3.empty()) attributes.addAttribute(XMLString(), XMLString(), attr3, CDATA, value3);
	if (data.empty())
	{
		emptyElement(namespaceURI, localName, qname, attributes);
	}
	else
	{
		startElement(namespaceURI, localName, qname, attributes);
		characters(data);
		endElement(namespaceURI, localName, qname);
	}
}
示例#6
0
void XMLWriter::emptyElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname)
{
	const AttributesImpl attributes;
	emptyElement(namespaceURI, localName, qname, attributes);
}
void cElementManager::addElement (const string &name, list<sElementPart *> contents,
    list<string> attlist, map<string, string> attdefault, bool open, bool empty,
    int tag, string flag)
{
  //sanity checks
  if (elementDefined (name))
  {
    results->addToList (results->createError ("Multiple definition of element " + name + "!"));
    return;
  }

  sElement *e = new sElement;
  e->open = open;
  e->empty = empty;
  if ((tag >= 20) && (tag <= 99))
  {
    e->tag = tag;
    if (lineTags.count (tag))
      results->addToList (results->createError ("Element " + name +
          " uses an already assigned line tag!"));
    lineTags[tag] = name;
  }
  else
    e->tag = 0;
  e->flag = flag;

  //assign element contents, generating the list of closing tags
  e->element.clear();
  list<sElementPart *>::iterator it;
  for (it = contents.begin(); it != contents.end(); ++it)
  {
    sElementPart *ep = *it;
    if (ep->istag)
    {
      string tag = lcase (firstword (ep->text));
      if (elementDefined (tag))
      {
        if (open && !(openElement (tag)))
        {
          delete ep;
          results->addToList (results->createError ("Definition of open " + name +
              " tag contains secure tag " + tag + "!"));
        }
        else if (empty && !(emptyElement (tag)))
        {
          delete ep;
          results->addToList (results->createError ("Definition of empty " + name +
              " tag contains non-empty tag " + tag + "!"));
        }
        else
        {
          e->element.push_back (ep);
          if (!emptyElement(tag)) e->closingseq.push_front (tag);
        }
      }
      else
      {
        //element doesn't exist yet - we must believe that it's correct
        e->element.push_back (ep);
        if (!empty) e->closingseq.push_front (tag);
        results->addToList (results->createWarning ("Definition of element " + name +
            " contains undefined element " + tag + "!"));
      }
    }
    else
      e->element.push_back (ep);
  }

  //assign the element definition
  elements[name] = e;

  //set attribute list
  setAttList (name, attlist, attdefault);
}