Alien-SmokeQt

 view release on metacpan or  search on metacpan

generator/parser/rpp/pp-stream.h  view on Meta::CPAN

    void seek(int offset);

    /// Start from the beginning again
    void reset();

    /// Lock/unlock the input position. If the input position is locked, it will not be moved forwards.
    void lockInputPosition(bool lock);

    /// If a macro-expansion is set, all anchors given to mark() will get that macro-expansion set.
    /// It marks the position from where the macro-expansion was started that leads to the current output @see rpp::Anchor
    void setMacroExpansion(const SimpleCursor&);
    SimpleCursor macroExpansion() const;
    
    //Checks whether the current index represents a character, and eventually compares it
    bool operator==(const char otherc) const {
      return isCharacter(*c) && *c == indexFromCharacter(otherc);
    }

    //Checks whether the current index represents a character, and eventually compares it
    bool operator!=(const char otherc) const {
      return !isCharacter(*c) || *c != indexFromCharacter(otherc);
    }
    
    inline const uint& current() const { return *c; } //krazy:exclude=inline
    inline operator const uint&() const { return *c; } //krazy:exclude=inline
    inline Stream& operator++() //krazy:exclude=inline
    {
      if (c == end)
        return *this;

      if(m_inputPositionLocked)
        ++m_inputLineStartedAt;
      else if (*c == newline) {
        ++m_inputLine;
        m_inputLineStartedAt = m_pos + 1;
      }else if(!isCharacter(*c)) {
        //We have to do some special hacking here to keep the column-number correct.
        m_inputLineStartedAt += 1-IndexedString::fromIndex(*c).length();
      }

      ++c;
      ++m_pos;

      return *this;
    }

    ///@warning Doesn't handle newlines correctly!
    Stream& operator--();

    ///Removes the last added item from the output, and returns it
    uint popLastOutput();
    
    ///Allows peeking at the items that were added to the output recently
    uint peekLastOutput(uint backOffset = 0) const;

    ///Returns the cursor that points to the current input position.
    Anchor inputPosition() const;
    ///If the input position is collapsed, the input position will be locked from now on. It will stay the same until a new one is set.
    void setInputPosition(const Anchor& position);

    ///Input-position that marks the start of the topmost currently expanding macro in the original document
    SimpleCursor originalInputPosition() const;
    void setOriginalInputPosition(const SimpleCursor& position);

    ///Used for output streams to mark stream positions with input position
    ///The macroExpansion member may have no effect if macroExpansion is set for this stream.
    void mark(const Anchor& position);

    ///Returns the anchor for the current output position.
    Anchor currentOutputAnchor() const;
    
    Stream & operator<< ( const char& c ) {
      return operator<<(indexFromCharacter(c));
    }
    Stream & operator<< ( const unsigned int& c );
    Stream & operator<< ( const Stream& input );
    Stream& appendString( const Anchor& inputPosition, const PreprocessedContents & string );
    Stream& appendString( const Anchor& inputPosition, IndexedString index );

  private:
    Q_DISABLE_COPY(Stream)

    PreprocessedContents* m_string;
    const unsigned int* c;
    const unsigned int* end;
    bool m_isNull, m_skippedToEnd, m_inputPositionLocked, m_onwsString;
    SimpleCursor m_macroExpansion;
    int m_pos;
    int m_inputLine;
    int m_inputLineStartedAt;
    LocationTable* m_locationTable;
    SimpleCursor m_originalInputPosition;
};

}

#endif



( run in 0.485 second using v1.01-cache-2.11-cpan-5b529ec07f3 )