Exemple #1
0
std::string Instruction::toString() const
{
	std::stringstream stream;
	
	if(!guard()->isAlwaysTrue())
	{
		stream << guard()->toString() << " ";
	}
	
	stream << opcodeString() << " ";
	
	std::string modifier = modifierString();
	
	if(!modifier.empty())
	{
		stream << modifier << " ";
	}
	
	for(auto write : writes)
	{
		if(write != *writes.begin()) stream << ", ";
		
		stream << write->toString();
	}
	
	if(!writes.empty() && reads.size() > 1)
	{
		stream << ", ";
	}
	
	bool first = true;

	for(auto read : reads)
	{
		if(read == guard()) continue;
		
		if(!first)
		{
			 stream << ", ";
		}
		else
		{
			first = false;
		}
		
		stream << read->toString();
	}

	return stream.str();

}
Exemple #2
0
bool EQPacketOPCodeDB::save(const QString& filename)
{
  // create QFile object
  QFile file(filename);

  // open the file for write only
  if (!file.open(IO_WriteOnly))
    return false;

  // create a QTextStream object on the QFile object
  QTextStream out(&file);
  
  // set the output encoding to be UTF8
  out.setEncoding(QTextStream::UnicodeUTF8);

  // set the number output to be left justified decimal
  out.setf(QTextStream::dec | QTextStream::left);

  // print document header
  out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl
      << "<!DOCTYPE seqopcodes SYSTEM \"seqopcodes.dtd\">" << endl
      << "<seqopcodes>" << endl;

  // set initial indent
  QString indent = "    ";

  EQPacketOPCode* currentOPCode;
  EQPacketPayload* currentPayload;

  typedef std::map<long, EQPacketOPCode*> OrderedMap;
  OrderedMap orderedOPCodes;

  // iterate over all the opcodes, inserting them into the ordered map
  QIntDictIterator<EQPacketOPCode> it(m_opcodes);
  while ((currentOPCode = it.current()) != NULL)
  {
    // insert into the ordered opcode map
    orderedOPCodes.insert(OrderedMap::value_type(currentOPCode->opcode(), 
						 currentOPCode));

    // get next opcode
    ++it;
  }

  OrderedMap::iterator oit;
  QCString opcodeString(256);
  static const char* dirStrs[] = { "client", "server", "both", };
  static const char* sztStrs[] = { "none", "match", "modulus", };

  // iterate over the ordered opcode map
  for (oit = orderedOPCodes.begin(); oit != orderedOPCodes.end(); ++oit)
  {
    currentOPCode = oit->second;

    // output the current opcode
    opcodeString.sprintf("%04x", currentOPCode->opcode());
    out << indent << "<opcode id=\"" << opcodeString << "\" name=\""
	<< currentOPCode->name() << "\"";
    if (currentOPCode->implicitLen())
      out << " implicitlen=\"" << currentOPCode->implicitLen() << "\"";
    if (!currentOPCode->updated().isEmpty())
      out << " updated=\"" << currentOPCode->updated() << "\"";
    out << ">" << endl;

    // increase the indent
    indent += "    ";

    // output the comments
    QStringList comments = currentOPCode->comments();
    for (QStringList::Iterator cit = comments.begin(); 
	 cit != comments.end(); ++cit)
      out << indent << "<comment>" << *cit << "</comment>" << endl;

    QCString dirStr;
    QCString sztStr;

    // iterate over the payloads
    QPtrListIterator<EQPacketPayload> pit(*currentOPCode);
    while ((currentPayload = pit.current()) != 0)
    {
      // output the payload
      out << indent << "<payload dir=\"" << dirStrs[currentPayload->dir()-1]
	  << "\" typename=\"" << currentPayload->typeName() 
	  << "\" sizechecktype=\""
	  << sztStrs[currentPayload->sizeCheckType()]
	  << "\"/>" << endl;

      ++pit;
    }

    // decrease the indent
    indent.remove(0, 4);

    // close the opcode entity
    out << indent << "</opcode>" << endl;
  }

  // output closing entity
  out << "</seqopcodes>" << endl;

  return true;
}