summaryrefslogtreecommitdiffstats
path: root/tools/qdoc3/text.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/qdoc3/text.cpp')
-rw-r--r--tools/qdoc3/text.cpp138
1 files changed, 72 insertions, 66 deletions
diff --git a/tools/qdoc3/text.cpp b/tools/qdoc3/text.cpp
index dba3a1d..e9a97fe 100644
--- a/tools/qdoc3/text.cpp
+++ b/tools/qdoc3/text.cpp
@@ -60,10 +60,10 @@ Text::Text(const QString &str)
operator<<(str);
}
-Text::Text( const Text& text )
+Text::Text(const Text& text)
: first(0), last(0)
{
- operator=( text );
+ operator=(text);
}
Text::~Text()
@@ -71,41 +71,41 @@ Text::~Text()
clear();
}
-Text& Text::operator=( const Text& text )
+Text& Text::operator=(const Text& text)
{
- if ( this != &text ) {
+ if (this != &text) {
clear();
- operator<<( text );
+ operator<<(text);
}
return *this;
}
-Text& Text::operator<<( Atom::Type atomType )
+Text& Text::operator<<(Atom::Type atomType)
{
- return operator<<( Atom(atomType) );
+ return operator<<(Atom(atomType));
}
-Text& Text::operator<<( const QString& string )
+Text& Text::operator<<(const QString& string)
{
- return operator<<( Atom(Atom::String, string) );
+ return operator<<(Atom(Atom::String, string));
}
-Text& Text::operator<<( const Atom& atom )
+Text& Text::operator<<(const Atom& atom)
{
- if ( first == 0 ) {
- first = new Atom( atom.type(), atom.string() );
+ if (first == 0) {
+ first = new Atom(atom.type(), atom.string());
last = first;
} else {
- last = new Atom( last, atom.type(), atom.string() );
+ last = new Atom(last, atom.type(), atom.string());
}
return *this;
}
-Text& Text::operator<<( const Text& text )
+Text& Text::operator<<(const Text& text)
{
- const Atom *atom = text.firstAtom();
- while ( atom != 0 ) {
- operator<<( *atom );
+ const Atom* atom = text.firstAtom();
+ while (atom != 0) {
+ operator<<(*atom);
atom = atom->next();
}
return *this;
@@ -113,10 +113,10 @@ Text& Text::operator<<( const Text& text )
void Text::stripFirstAtom()
{
- if ( first != 0 ) {
- if ( first == last )
+ if (first != 0) {
+ if (first == last)
last = 0;
- Atom *oldFirst = first;
+ Atom* oldFirst = first;
first = first->next();
delete oldFirst;
}
@@ -124,16 +124,16 @@ void Text::stripFirstAtom()
void Text::stripLastAtom()
{
- if ( last != 0 ) {
- Atom *oldLast = last;
- if ( first == last ) {
+ if (last != 0) {
+ Atom* oldLast = last;
+ if (first == last) {
first = 0;
last = 0;
} else {
last = first;
- while ( last->next() != oldLast )
+ while (last->next() != oldLast)
last = last->next();
- last->setNext( 0 );
+ last->setNext(0);
}
delete oldLast;
}
@@ -142,59 +142,65 @@ void Text::stripLastAtom()
QString Text::toString() const
{
QString str;
- const Atom *atom = firstAtom();
- while ( atom != 0 ) {
- if ( atom->type() == Atom::String || atom->type() == Atom::AutoLink )
+ const Atom* atom = firstAtom();
+ while (atom != 0) {
+ if (atom->type() == Atom::String ||
+ atom->type() == Atom::AutoLink ||
+ atom->type() == Atom::GuidLink)
str += atom->string();
atom = atom->next();
}
return str;
}
-Text Text::subText( Atom::Type left, Atom::Type right, const Atom *from ) const
+Text Text::subText(Atom::Type left, Atom::Type right, const Atom* from, bool inclusive) const
{
- const Atom *begin = from ? from : firstAtom();
- const Atom *end;
+ const Atom* begin = from ? from : firstAtom();
+ const Atom* end;
- while ( begin != 0 && begin->type() != left )
- begin = begin->next();
- if ( begin != 0 )
+ while (begin != 0 && begin->type() != left)
begin = begin->next();
+ if (begin != 0) {
+ if (!inclusive)
+ begin = begin->next();
+ }
end = begin;
- while ( end != 0 && end->type() != right )
+ while (end != 0 && end->type() != right)
end = end->next();
- if ( end == 0 )
+ if (end == 0)
begin = 0;
- return subText( begin, end );
+ else if (inclusive)
+ end = end->next();
+ return subText(begin, end);
}
-Text Text::sectionHeading(const Atom *sectionLeft)
+Text Text::sectionHeading(const Atom* sectionLeft)
{
- if ( sectionLeft != 0 ) {
- const Atom *begin = sectionLeft;
- while ( begin != 0 && begin->type() != Atom::SectionHeadingLeft )
+ if (sectionLeft != 0) {
+ const Atom* begin = sectionLeft;
+ while (begin != 0 && begin->type() != Atom::SectionHeadingLeft)
begin = begin->next();
- if ( begin != 0 )
+ if (begin != 0)
begin = begin->next();
- const Atom *end = begin;
- while ( end != 0 && end->type() != Atom::SectionHeadingRight )
+ const Atom* end = begin;
+ while (end != 0 && end->type() != Atom::SectionHeadingRight)
end = end->next();
- if ( end != 0 )
- return subText( begin, end );
+ if (end != 0)
+ return subText(begin, end);
}
return Text();
}
-const Atom *Text::sectionHeadingAtom(const Atom *sectionLeft)
+const Atom* Text::sectionHeadingAtom(const Atom* sectionLeft)
{
- if ( sectionLeft != 0 ) {
- const Atom *begin = sectionLeft;
- while ( begin != 0 && begin->type() != Atom::SectionHeadingLeft )
+ if (sectionLeft != 0) {
+ const Atom* begin = sectionLeft;
+ while (begin != 0 && begin->type() != Atom::SectionHeadingLeft)
begin = begin->next();
- if ( begin != 0 )
+ if (begin != 0)
begin = begin->next();
return begin;
@@ -204,25 +210,25 @@ const Atom *Text::sectionHeadingAtom(const Atom *sectionLeft)
void Text::dump() const
{
- const Atom *atom = firstAtom();
- while ( atom != 0 ) {
+ const Atom* atom = firstAtom();
+ while (atom != 0) {
QString str = atom->string();
- str.replace( "\\", "\\\\" );
- str.replace( "\"", "\\\"" );
- str.replace( "\n", "\\n" );
- str.replace( QRegExp("[^\x20-\x7e]"), "?" );
- if ( !str.isEmpty() )
+ str.replace("\\", "\\\\");
+ str.replace("\"", "\\\"");
+ str.replace("\n", "\\n");
+ str.replace(QRegExp("[^\x20-\x7e]"), "?");
+ if (!str.isEmpty())
str = " \"" + str + "\"";
- fprintf(stderr, " %-15s%s\n", atom->typeString().toLatin1().data(), str.toLatin1().data() );
+ fprintf(stderr, " %-15s%s\n", atom->typeString().toLatin1().data(), str.toLatin1().data());
atom = atom->next();
}
}
-Text Text::subText( const Atom *begin, const Atom *end )
+Text Text::subText(const Atom* begin, const Atom* end)
{
Text text;
- if ( begin != 0 ) {
- while ( begin != end ) {
+ if (begin != 0) {
+ while (begin != end) {
text << *begin;
begin = begin->next();
}
@@ -232,8 +238,8 @@ Text Text::subText( const Atom *begin, const Atom *end )
void Text::clear()
{
- while ( first != 0 ) {
- Atom *atom = first;
+ while (first != 0) {
+ Atom* atom = first;
first = first->next();
delete atom;
}
@@ -248,8 +254,8 @@ int Text::compare(const Text &text1, const Text &text2)
if (text2.isEmpty())
return 1;
- const Atom *atom1 = text1.firstAtom();
- const Atom *atom2 = text2.firstAtom();
+ const Atom* atom1 = text1.firstAtom();
+ const Atom* atom2 = text2.firstAtom();
for (;;) {
if (atom1->type() != atom2->type())