My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
HtmlSpaceless Class Reference
Inheritance diagram for HtmlSpaceless:
TemplateSpacelessIntf

Public Member Functions

 HtmlSpaceless ()
 
void reset ()
 
QCString remove (const QCString &s)
 

Private Attributes

bool m_insideTag
 
char m_insideString
 
bool m_removeSpaces
 

Detailed Description

Definition at line 9988 of file context.cpp.

Constructor & Destructor Documentation

HtmlSpaceless::HtmlSpaceless ( )
inline

Definition at line 9991 of file context.cpp.

References reset().

{ reset(); }

Member Function Documentation

QCString HtmlSpaceless::remove ( const QCString &  input)
inlinevirtual

Returns the input after removing redundant whitespace

Implements TemplateSpacelessIntf.

Definition at line 9998 of file context.cpp.

References m_insideString, m_insideTag, and m_removeSpaces.

{
QGString result;
const char *p = s.data();
char c;
while ((c=*p++))
{
switch(c)
{
case '<': // start of a tag
result+=c;
break;
case '>': // end of a tag
if (!m_insideString) m_insideTag=FALSE,m_removeSpaces=TRUE;
result+=c;
break;
case '\\': // escaped character in a string
result+=c;
if (m_insideString && *p) result+=*p++;
break;
case '"': case '\'':
{
if (m_insideString==c) // end of string
{
}
else if (m_insideString=='\0') // start of string
{
}
}
result+=c;
break;
case ' ': case '\t': case '\n': // whitespace
if (!m_insideTag) // outside tags strip consecutive whitespace
{
m_removeSpaces=TRUE;
}
else
{
result+=' ';
}
break;
default:
//if (m_removeSpaces) result+=' ';
result+=c;
m_removeSpaces=FALSE;
break;
}
}
result+='\0';
//printf("HtmlSpaceless::remove({%s})={%s} m_insideTag=%d m_insideString=%c (%d) removeSpaces=%d\n",s.data(),result.data(),
// m_insideTag,m_insideString,m_insideString,m_removeSpaces);
return result.data();
}
void HtmlSpaceless::reset ( )
inlinevirtual

Reset filter state

Implements TemplateSpacelessIntf.

Definition at line 9992 of file context.cpp.

References m_insideString, m_insideTag, and m_removeSpaces.

Referenced by HtmlSpaceless().

{
m_insideTag = FALSE;
}

Member Data Documentation

char HtmlSpaceless::m_insideString
private

Definition at line 10057 of file context.cpp.

Referenced by remove(), and reset().

bool HtmlSpaceless::m_insideTag
private

Definition at line 10056 of file context.cpp.

Referenced by remove(), and reset().

bool HtmlSpaceless::m_removeSpaces
private

Definition at line 10058 of file context.cpp.

Referenced by remove(), and reset().


The documentation for this class was generated from the following file: