Ejemplo n.º 1
0
void Parser::parseCompositor( ParserContext *context,
  const QDomElement &element, ComplexType &ct )
{
  QName name = element.tagName();
  bool isChoice = name.localName() == "choice";
  bool isSequence = name.localName() == "sequence";

  Compositor compositor;
  if ( isChoice ) compositor.setType( Compositor::Choice );
  else if ( isSequence ) compositor.setType( Compositor::Sequence );

  if ( isChoice || isSequence ) {
    Element::List newElements;

    QDomElement childElement = element.firstChildElement();

    while ( !childElement.isNull() ) {
      QName csName = childElement.tagName();
      if ( csName.localName() == "element" ) {
        Element newElement;
        if ( isChoice ) {
          newElement = parseElement( context, childElement,
            ct.nameSpace(), element );
        } else {
          if ( isSequence ) {
            // occurence attributes can be either in the
            // parent (sequence) to on the current element
            if ( childElement.hasAttribute("minOccurs") ||
                 childElement.hasAttribute("maxOccurs")) {
              newElement = parseElement( context, childElement,
                ct.nameSpace(), childElement );
            } else {
              newElement = parseElement( context, childElement,
                ct.nameSpace(), element );
            }
          } else {
            newElement = parseElement( context, childElement,
              ct.nameSpace(), childElement );
          }
        }
        newElements.append( newElement );
        compositor.addChild( csName );
      } else if ( csName.localName() == "any" ) {
        addAny( context, childElement, ct );
      } else if ( isChoice ) {
        parseCompositor( context, childElement, ct );
      } else if ( isSequence ) {
        parseCompositor( context, childElement, ct );
      }

      childElement = childElement.nextSiblingElement();
    }

    foreach( Element e, newElements ) {
      e.setCompositor( compositor );
      ct.addElement( e );
    }
Ejemplo n.º 2
0
void Parser::parseCompositor( ParserContext *context,
  const QDomElement &element, ComplexType &ct )
{
  const QName name( element.tagName() );
  bool isChoice = name.localName() == QLatin1String("choice");
  bool isSequence = name.localName() == QLatin1String("sequence");

  Compositor compositor;
  if ( isChoice ) compositor.setType( Compositor::Choice );
  else if ( isSequence ) compositor.setType( Compositor::Sequence );
  compositor.setMaxOccurs( readMaxOccurs( element ) );

  if ( isChoice || isSequence ) {
    Element::List newElements;
    QDomElement childElement = element.firstChildElement();

    while ( !childElement.isNull() ) {
      NSManager namespaceManager( context, childElement );
      const QName csName( childElement.tagName() );
      if ( csName.localName() == QLatin1String("element") ) {
        Element newElement;
        if ( isChoice ) {
          newElement = parseElement( context, childElement,
            ct.nameSpace(), element );
        } else {
          newElement = parseElement( context, childElement,
            ct.nameSpace(), childElement );
        }
        newElements.append( newElement );
        compositor.addChild( csName );
      } else if ( csName.localName() == QLatin1String("any") ) {
        addAny( context, childElement, ct );
      } else if ( isChoice ) {
        parseCompositor( context, childElement, ct );
      } else if ( isSequence ) {
        parseCompositor( context, childElement, ct );
      }

      childElement = childElement.nextSiblingElement();
    }

    foreach( Element e, newElements ) {
      e.setCompositor( compositor );
      ct.addElement( e );
    }
Ejemplo n.º 3
0
CParkingProtocolPrivate::CParkingProtocolPrivate(QObject *parent) :
    CAbstractProtocol(parent)
{
    if (!QMetaType::isRegistered(QMetaType::type("ParkingData")))
        qRegisterMetaType<ParkingData>("ParkingData");

    anyFlag = false;

    thread = new QThread();
    this->moveToThread(thread);


    QByteArray pass = QByteArray::fromHex("0123456789abcdef0123456789");

    for(int i = 0; i < 13; i++) {
        _password[i] = (unsigned char)pass.at(i);
    }

    connect(this, SIGNAL(parkingAdd(ParkingData)), SLOT(addParking(ParkingData)));
    connect(this, SIGNAL(anyAdd(AnyData)), SLOT(addAny(AnyData)));

    thread->start();
}