Пример #1
0
    //-------------------------------------------------------------------------
    ParserPos &ParserPos::operator+=(size_t inDistance)
    {
      ParserPtr parser(getParser());

      if (NULL == mPos)
        return *this;

      while (0 != inDistance)
      {
        if (isEOF())
          return *this;

        switch (*mPos)
        {
          case '\r':
          {
            // does not advance row, just resets column
            if ('\n' != (*(mPos+1)))
            {
              // this is MAC EOL \r therefor we can do the same thing as \n
              ++mRow;
              mColumn = 1;
              break;
            }
            // this is DOS EOL \r\n - ingore the \r in the position
            break;
          }
          case '\n':
          {
            // advances row, resets column to zero
            ++mRow;
            mColumn = 1;
            break;
          }
          case '\t':
          {
            ZS_THROW_BAD_STATE_IF(!parser)
            ZS_THROW_BAD_STATE_IF(0 == mColumn)

            ULONG tabSize = parser->getTabSize();
            // if tab size were set to 3
            // 1..2..3 would go to position 4
            // 4..5..6 would go to position 7

            mColumn = ((((mColumn-1)/tabSize)+1)*tabSize)+1;
            break;
          }
          default:
          {
            ++mColumn;
            break;
          }
        }
        ++mPos;
        --inDistance;
      }

      return *this;
    }
 //-------------------------------------------------------------------------
 MessageQueueThreadUsingCurrentGUIMessageQueueForWindows::~MessageQueueThreadUsingCurrentGUIMessageQueueForWindows()
 {
   if (NULL != mHWND)
   {
     ZS_THROW_BAD_STATE_IF(0 == ::DestroyWindow(mHWND))
     mHWND = NULL;
   }
 }
Пример #3
0
    //-------------------------------------------------------------------------
    void SocketSet::delegateGone(SocketPtr socket)
    {
      ZS_THROW_BAD_STATE_IF(mPollingSocketsWithDelegateGoneCount >= mPollingCount) // can never grow larger than the polling count

      mPollingSocketsWithDelegateGone[mPollingSocketsWithDelegateGoneCount] = socket;
      ++mPollingSocketsWithDelegateGoneCount;

      ZS_LOG_TRACE(log("delegate gone") + ZS_PARAM("handle", socket->getSocket()) + ZS_PARAM("gone count", mPollingSocketsWithDelegateGoneCount))
    }
Пример #4
0
      XML::ParserPos Document::popPos()
      {
        ZS_THROW_BAD_STATE_IF(mParserStack.size() < 1)

        XML::ParserPos temp;
        temp = mParserStack.back();
        mParserStack.pop_back();
        return temp;
      }
    //-------------------------------------------------------------------------
    void MessageQueueThreadUsingCurrentGUIMessageQueueForWindows::waitForShutdown()
    {
      AutoLock lock(mLock);

      if (NULL != mHWND)
      {
        ZS_THROW_BAD_STATE_IF(0 == ::DestroyWindow(mHWND))
        mHWND = NULL;
      }

      mIsShutdown = true;
    }
Пример #6
0
    //-------------------------------------------------------------------------
    void SocketSet::firedEvent(
                               SocketPtr socket,
                               event_type event
                               )
    {
      ZS_THROW_BAD_STATE_IF(mPollingFiredEventCount >= mPollingCount) // can never grow larger than the polling count

      mPollingFiredEvents[mPollingFiredEventCount].first = socket;
      mPollingFiredEvents[mPollingFiredEventCount].second = event;
      ++mPollingFiredEventCount;

      ZS_LOG_INSANE(log("fire event") + ZS_PARAM("handle", socket->getSocket()) + ZS_PARAM("event", friendly(event)) + ZS_PARAM("fired count", mPollingFiredEventCount))
    }
Пример #7
0
    //-------------------------------------------------------------------------
    ParserPos &ParserPos::operator-=(size_t inDistance)
    {
      ParserPtr parser(getParser());

      if (NULL == mPos)
      {
        ParserPos temp(*this);
        temp.setSOF();
        temp += strlen(temp.mPos);
        (*this) = temp;
      }

      while (0 != inDistance)
      {
        if (isSOF())
          return *this;

        // assuming column and row should be accurate at this point, but could become inaccurate
        // if we run into a special character

        --mPos;
        --inDistance;

        switch (*mPos)
        {
          case '\r':
          case '\n':
          case '\t':
          {
            if ('\n' == *mPos)
            {
              ZS_THROW_BAD_STATE_IF(mRow < 2)   // how did the count become inaccurate
              --mRow;
            }
            if ('\r' == *mPos)
            {
              if ('\n' != (*(mPos+1)))
              {
                // this is a MAC EOL
                ZS_THROW_BAD_STATE_IF(mRow < 2)   // how did the count become inaccurate
                --mRow;
              }
            }

            ZS_THROW_BAD_STATE_IF(!parser)
            ZS_THROW_BAD_STATE_IF(NULL == parser->mSOF)

            // these characters cause the column to get messed up, simplest method is to
            // recalculate the column position from the start of the line
            mColumn = internal::calculateColumnFromSOL(mPos, parser->mSOF, parser->mTabSize);
            break;
          }
          default:
          {
            ZS_THROW_BAD_STATE_IF(mColumn < 2)   // how did the count become inaccurate

            --mColumn;
            break;
          }
        }
      }

      return *this;
    }