//-----------------------------------------------------------------------
      void TransportStream::write(
                                  const BYTE *inBuffer,
                                  size_t bufferLengthInBytes,
                                  StreamHeaderPtr header
                                  )
      {
        ZS_THROW_INVALID_ARGUMENT_IF(!inBuffer)

        AutoRecursiveLock lock(getLock());

        if (isShutdown()) {
          ZS_LOG_WARNING(Detail, log("cannot write as already shutdown"))
          return;
        }

        if (mBlockQueue) {
          ZS_LOG_TRACE(log("write blocked thus putting buffer into block queue") + ZS_PARAM("size", bufferLengthInBytes) + ZS_PARAM("header", (bool)header))
          if (!mBlockHeader) {
            mBlockHeader = header;
          }
          if (bufferLengthInBytes > 0) {
            mBlockQueue->Put(inBuffer, bufferLengthInBytes);
          }
          return;
        }

        write(IHelper::convertToBuffer(inBuffer, bufferLengthInBytes), header);
      }
      //-----------------------------------------------------------------------
      void TransportStream::write(
                                  SecureByteBlockPtr bufferToAdopt,
                                  StreamHeaderPtr header
                                  )
      {
        ZS_THROW_INVALID_ARGUMENT_IF(!bufferToAdopt)

        AutoRecursiveLock lock(getLock());

        if (isShutdown()) {
          ZS_LOG_WARNING(Detail, log("cannot write as already shutdown"))
          return;
        }

        if (mBlockQueue) {
          ZS_LOG_TRACE(log("write blocked thus putting buffer into block queue") + ZS_PARAM("size", bufferToAdopt->SizeInBytes()) + ZS_PARAM("header", (bool)header))
          if (!mBlockHeader) {
            mBlockHeader = header;
          }
          if (bufferToAdopt->SizeInBytes() > 0) {
            mBlockQueue->Put(bufferToAdopt->BytePtr(), bufferToAdopt->SizeInBytes());
          }
          return;
        }

        Buffer buffer;
        buffer.mBuffer = bufferToAdopt;
        buffer.mHeader = header;

        ZS_LOG_TRACE(log("buffer written") + ZS_PARAM("written", bufferToAdopt->SizeInBytes()) )

        mBuffers.push_back(buffer);

        notifySubscribers(false, true);
      }
Ejemplo n.º 3
0
    void Document::parse(const char *inXMLDocument)
    {
      ZS_THROW_INVALID_ARGUMENT_IF(!inXMLDocument)

      mSOF = inXMLDocument;
      ParserPos pos(*this);

      clearStack();
      clearWarnings();

      while (*pos)
      {
        if (Parser::parseAnyExceptElement(pos, mThis.lock()))
          continue;

        // check if this is an element
        if (Parser::isLegalName(*(pos+1), true))
        {
          // this is an element
          ElementPtr element = XML::Element::create();
          adoptAsLastChild(element);
          element->parse(pos);
          continue;
        }

        Parser::skipMismatchedEndTag(pos);
      }

      clearStack();
    }