[2] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
[651] | 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
---|
[561] | 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
---|
[2] | 6 | **
|
---|
| 7 | ** This file is part of the tools applications of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 14 | ** a written agreement between you and Nokia.
|
---|
| 15 | **
|
---|
| 16 | ** GNU Lesser General Public License Usage
|
---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
| 20 | ** packaging of this file. Please review the following information to
|
---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
| 23 | **
|
---|
[561] | 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
[2] | 27 | **
|
---|
| 28 | ** GNU General Public License Usage
|
---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
| 32 | ** packaging of this file. Please review the following information to
|
---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
| 35 | **
|
---|
[561] | 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at [email protected].
|
---|
[2] | 38 | ** $QT_END_LICENSE$
|
---|
| 39 | **
|
---|
| 40 | ****************************************************************************/
|
---|
| 41 |
|
---|
| 42 | #include <qregexp.h>
|
---|
| 43 | #include "atom.h"
|
---|
| 44 | #include "location.h"
|
---|
| 45 | #include <stdio.h>
|
---|
| 46 |
|
---|
| 47 | QT_BEGIN_NAMESPACE
|
---|
| 48 |
|
---|
| 49 | QString Atom::BOLD_ ("bold");
|
---|
| 50 | QString Atom::INDEX_ ("index");
|
---|
| 51 | QString Atom::ITALIC_ ("italic");
|
---|
| 52 | QString Atom::LINK_ ("link");
|
---|
| 53 | QString Atom::PARAMETER_ ("parameter");
|
---|
| 54 | QString Atom::SUBSCRIPT_ ("subscript");
|
---|
| 55 | QString Atom::SUPERSCRIPT_ ("superscript");
|
---|
| 56 | QString Atom::TELETYPE_ ("teletype");
|
---|
| 57 | QString Atom::UNDERLINE_ ("underline");
|
---|
| 58 |
|
---|
| 59 | QString Atom::BULLET_ ("bullet");
|
---|
| 60 | QString Atom::TAG_ ("tag");
|
---|
| 61 | QString Atom::VALUE_ ("value");
|
---|
| 62 | QString Atom::LOWERALPHA_ ("loweralpha");
|
---|
| 63 | QString Atom::LOWERROMAN_ ("lowerroman");
|
---|
| 64 | QString Atom::NUMERIC_ ("numeric");
|
---|
| 65 | QString Atom::UPPERALPHA_ ("upperalpha");
|
---|
| 66 | QString Atom::UPPERROMAN_ ("upperroman");
|
---|
| 67 |
|
---|
| 68 | /*! \class Atom
|
---|
| 69 | \brief The Atom class is the fundamental unit for representing
|
---|
| 70 | documents internally.
|
---|
| 71 |
|
---|
| 72 | Atoms have a \i type and are completed by a \i string whose
|
---|
| 73 | meaning depends on the \i type. For example, the string
|
---|
| 74 | \quotation
|
---|
| 75 | \i italic text looks nicer than \bold bold text
|
---|
| 76 | \endquotation
|
---|
| 77 | is represented by the following atoms:
|
---|
| 78 | \quotation
|
---|
| 79 | (FormattingLeft, ATOM_FORMATTING_ITALIC)
|
---|
| 80 | (String, "italic")
|
---|
| 81 | (FormattingRight, ATOM_FORMATTING_ITALIC)
|
---|
| 82 | (String, " text is more attractive than ")
|
---|
| 83 | (FormattingLeft, ATOM_FORMATTING_BOLD)
|
---|
| 84 | (String, "bold")
|
---|
| 85 | (FormattingRight, ATOM_FORMATTING_BOLD)
|
---|
| 86 | (String, " text")
|
---|
| 87 | \endquotation
|
---|
| 88 |
|
---|
| 89 | \also Text
|
---|
| 90 | */
|
---|
| 91 |
|
---|
| 92 | /*! \enum Atom::Type
|
---|
| 93 |
|
---|
| 94 | \value AbstractLeft
|
---|
| 95 | \value AbstractRight
|
---|
[561] | 96 | \value AnnotatedList
|
---|
[2] | 97 | \value AutoLink
|
---|
| 98 | \value BaseName
|
---|
| 99 | \value BriefLeft
|
---|
| 100 | \value BriefRight
|
---|
| 101 | \value C
|
---|
| 102 | \value CaptionLeft
|
---|
| 103 | \value CaptionRight
|
---|
| 104 | \value Code
|
---|
| 105 | \value CodeBad
|
---|
| 106 | \value CodeNew
|
---|
| 107 | \value CodeOld
|
---|
| 108 | \value CodeQuoteArgument
|
---|
| 109 | \value CodeQuoteCommand
|
---|
| 110 | \value EndQmlText
|
---|
| 111 | \value FormatElse
|
---|
| 112 | \value FormatEndif
|
---|
| 113 | \value FormatIf
|
---|
| 114 | \value FootnoteLeft
|
---|
| 115 | \value FootnoteRight
|
---|
| 116 | \value FormattingLeft
|
---|
| 117 | \value FormattingRight
|
---|
| 118 | \value GeneratedList
|
---|
| 119 | \value Image
|
---|
| 120 | \value ImageText
|
---|
| 121 | \value InlineImage
|
---|
| 122 | \value LineBreak
|
---|
| 123 | \value Link
|
---|
| 124 | \value LinkNode
|
---|
| 125 | \value ListLeft
|
---|
| 126 | \value ListItemNumber
|
---|
| 127 | \value ListTagLeft
|
---|
| 128 | \value ListTagRight
|
---|
| 129 | \value ListItemLeft
|
---|
| 130 | \value ListItemRight
|
---|
| 131 | \value ListRight
|
---|
| 132 | \value Nop
|
---|
| 133 | \value ParaLeft
|
---|
| 134 | \value ParaRight
|
---|
| 135 | \value Qml
|
---|
| 136 | \value QmlText
|
---|
| 137 | \value QuotationLeft
|
---|
| 138 | \value QuotationRight
|
---|
| 139 | \value RawString
|
---|
| 140 | \value SectionLeft
|
---|
| 141 | \value SectionRight
|
---|
| 142 | \value SectionHeadingLeft
|
---|
| 143 | \value SectionHeadingRight
|
---|
| 144 | \value SidebarLeft
|
---|
| 145 | \value SidebarRight
|
---|
[561] | 146 | \value SinceList
|
---|
[2] | 147 | \value String
|
---|
| 148 | \value TableLeft
|
---|
| 149 | \value TableRight
|
---|
| 150 | \value TableHeaderLeft
|
---|
| 151 | \value TableHeaderRight
|
---|
| 152 | \value TableRowLeft
|
---|
| 153 | \value TableRowRight
|
---|
| 154 | \value TableItemLeft
|
---|
| 155 | \value TableItemRight
|
---|
| 156 | \value TableOfContents
|
---|
| 157 | \value Target
|
---|
| 158 | \value UnhandledFormat
|
---|
| 159 | \value UnknownCommand
|
---|
| 160 | */
|
---|
| 161 |
|
---|
| 162 | static const struct {
|
---|
| 163 | const char *english;
|
---|
| 164 | int no;
|
---|
| 165 | } atms[] = {
|
---|
| 166 | { "AbstractLeft", Atom::AbstractLeft },
|
---|
| 167 | { "AbstractRight", Atom::AbstractRight },
|
---|
[561] | 168 | { "AnnotatedList", Atom::AnnotatedList },
|
---|
[2] | 169 | { "AutoLink", Atom::AutoLink },
|
---|
| 170 | { "BaseName", Atom::BaseName },
|
---|
| 171 | { "BriefLeft", Atom::BriefLeft },
|
---|
| 172 | { "BriefRight", Atom::BriefRight },
|
---|
| 173 | { "C", Atom::C },
|
---|
| 174 | { "CaptionLeft", Atom::CaptionLeft },
|
---|
| 175 | { "CaptionRight", Atom::CaptionRight },
|
---|
| 176 | { "Code", Atom::Code },
|
---|
| 177 | { "CodeBad", Atom::CodeBad },
|
---|
| 178 | { "CodeNew", Atom::CodeNew },
|
---|
| 179 | { "CodeOld", Atom::CodeOld },
|
---|
| 180 | { "CodeQuoteArgument", Atom::CodeQuoteArgument },
|
---|
| 181 | { "CodeQuoteCommand", Atom::CodeQuoteCommand },
|
---|
| 182 | #ifdef QDOC_QML
|
---|
| 183 | { "EndQmlText", Atom::EndQmlText },
|
---|
| 184 | #endif
|
---|
| 185 | { "FootnoteLeft", Atom::FootnoteLeft },
|
---|
| 186 | { "FootnoteRight", Atom::FootnoteRight },
|
---|
| 187 | { "FormatElse", Atom::FormatElse },
|
---|
| 188 | { "FormatEndif", Atom::FormatEndif },
|
---|
| 189 | { "FormatIf", Atom::FormatIf },
|
---|
| 190 | { "FormattingLeft", Atom::FormattingLeft },
|
---|
| 191 | { "FormattingRight", Atom::FormattingRight },
|
---|
| 192 | { "GeneratedList", Atom::GeneratedList },
|
---|
| 193 | { "Image", Atom::Image },
|
---|
| 194 | { "ImageText", Atom::ImageText },
|
---|
| 195 | { "InlineImage", Atom::InlineImage },
|
---|
| 196 | { "LegaleseLeft", Atom::LegaleseLeft },
|
---|
| 197 | { "LegaleseRight", Atom::LegaleseRight },
|
---|
| 198 | { "LineBreak", Atom::LineBreak },
|
---|
| 199 | { "Link", Atom::Link },
|
---|
| 200 | { "LinkNode", Atom::LinkNode },
|
---|
| 201 | { "ListLeft", Atom::ListLeft },
|
---|
| 202 | { "ListItemNumber", Atom::ListItemNumber },
|
---|
| 203 | { "ListTagLeft", Atom::ListTagLeft },
|
---|
| 204 | { "ListTagRight", Atom::ListTagRight },
|
---|
| 205 | { "ListItemLeft", Atom::ListItemLeft },
|
---|
| 206 | { "ListItemRight", Atom::ListItemRight },
|
---|
| 207 | { "ListRight", Atom::ListRight },
|
---|
| 208 | { "Nop", Atom::Nop },
|
---|
| 209 | { "ParaLeft", Atom::ParaLeft },
|
---|
| 210 | { "ParaRight", Atom::ParaRight },
|
---|
| 211 | #ifdef QDOC_QML
|
---|
| 212 | { "Qml", Atom::Qml},
|
---|
| 213 | { "QmlText", Atom::QmlText },
|
---|
| 214 | #endif
|
---|
| 215 | { "QuotationLeft", Atom::QuotationLeft },
|
---|
| 216 | { "QuotationRight", Atom::QuotationRight },
|
---|
| 217 | { "RawString", Atom::RawString },
|
---|
| 218 | { "SectionLeft", Atom::SectionLeft },
|
---|
| 219 | { "SectionRight", Atom::SectionRight },
|
---|
| 220 | { "SectionHeadingLeft", Atom::SectionHeadingLeft },
|
---|
| 221 | { "SectionHeadingRight", Atom::SectionHeadingRight },
|
---|
| 222 | { "SidebarLeft", Atom::SidebarLeft },
|
---|
| 223 | { "SidebarRight", Atom::SidebarRight },
|
---|
[561] | 224 | { "SinceList", Atom::SinceList },
|
---|
[2] | 225 | { "SnippetCommand", Atom::SnippetCommand },
|
---|
| 226 | { "SnippetIdentifier", Atom::SnippetIdentifier },
|
---|
| 227 | { "SnippetLocation", Atom::SnippetLocation },
|
---|
| 228 | { "String", Atom::String },
|
---|
| 229 | { "TableLeft", Atom::TableLeft },
|
---|
| 230 | { "TableRight", Atom::TableRight },
|
---|
| 231 | { "TableHeaderLeft", Atom::TableHeaderLeft },
|
---|
| 232 | { "TableHeaderRight", Atom::TableHeaderRight },
|
---|
| 233 | { "TableRowLeft", Atom::TableRowLeft },
|
---|
| 234 | { "TableRowRight", Atom::TableRowRight },
|
---|
| 235 | { "TableItemLeft", Atom::TableItemLeft },
|
---|
| 236 | { "TableItemRight", Atom::TableItemRight },
|
---|
| 237 | { "TableOfContents", Atom::TableOfContents },
|
---|
| 238 | { "Target", Atom::Target },
|
---|
| 239 | { "UnhandledFormat", Atom::UnhandledFormat },
|
---|
| 240 | { "UnknownCommand", Atom::UnknownCommand },
|
---|
| 241 | { 0, 0 }
|
---|
| 242 | };
|
---|
| 243 |
|
---|
| 244 | /*! \fn Atom::Atom( Type type, const QString& string )
|
---|
| 245 |
|
---|
| 246 | Constructs an atom (\a type, \a string) outside of any atom list.
|
---|
| 247 | */
|
---|
| 248 |
|
---|
| 249 | /*! \fn Atom( Atom *prev, Type type, const QString& string )
|
---|
| 250 |
|
---|
| 251 | Constructs an atom (\a type, \a string) that follows \a prev in \a
|
---|
| 252 | prev's atom list.
|
---|
| 253 | */
|
---|
| 254 |
|
---|
| 255 | /*! \fn void Atom::appendChar( QChar ch )
|
---|
| 256 |
|
---|
| 257 | Appends \a ch to the string parameter of this atom.
|
---|
| 258 |
|
---|
| 259 | \also string()
|
---|
| 260 | */
|
---|
| 261 |
|
---|
| 262 | /*! \fn void Atom::appendString( const QString& string )
|
---|
| 263 |
|
---|
| 264 | Appends \a string to the string parameter of this atom.
|
---|
| 265 |
|
---|
| 266 | \also string()
|
---|
| 267 | */
|
---|
| 268 |
|
---|
| 269 | /*! \fn void Atom::chopString()
|
---|
| 270 |
|
---|
| 271 | \also string()
|
---|
| 272 | */
|
---|
| |
---|