1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of Qt Creator. 7 ** 8 ** Commercial License Usage 9 ** Licensees holding valid commercial Qt licenses may use this file in 10 ** accordance with the commercial license agreement provided with the 11 ** Software or, alternatively, in accordance with the terms contained in 12 ** a written agreement between you and The Qt Company. For licensing terms 13 ** and conditions see https://www.qt.io/terms-conditions. For further 14 ** information use the contact form at https://www.qt.io/contact-us. 15 ** 16 ** GNU General Public License Usage 17 ** Alternatively, this file may be used under the terms of the GNU 18 ** General Public License version 3 as published by the Free Software 19 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT 20 ** included in the packaging of this file. Please review the following 21 ** information to ensure the GNU General Public License requirements will 22 ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 23 ** 24 ****************************************************************************/ 25 26 #pragma once 27 28 namespace Python { 29 namespace Internal { 30 31 enum Format { 32 Format_Number = 0, 33 Format_String, 34 Format_Keyword, 35 Format_Type, 36 Format_ClassField, 37 Format_MagicAttr, // magic class attribute/method, like __name__, __init__ 38 Format_Operator, 39 Format_Comment, 40 Format_Doxygen, 41 Format_Identifier, 42 Format_Whitespace, 43 Format_ImportedModule, 44 Format_LParen, 45 Format_RParen, 46 47 Format_FormatsAmount 48 }; 49 50 class FormatToken 51 { 52 public: 53 FormatToken() = default; 54 FormatToken(Format format,int position,int length)55 FormatToken(Format format, int position, int length) 56 : m_format(format), m_position(position), m_length(length) 57 {} 58 isEndOfBlock()59 bool isEndOfBlock() { return m_position == -1; } 60 format()61 Format format() const { return m_format; } begin()62 int begin() const { return m_position; } end()63 int end() const { return m_position + m_length; } length()64 int length() const { return m_length; } 65 66 private: 67 Format m_format = Format_FormatsAmount; 68 int m_position = -1; 69 int m_length = -1; 70 }; 71 72 } // namespace Internal 73 } // namespace Python 74