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 9973 of file context.cpp.

Constructor & Destructor Documentation

HtmlSpaceless::HtmlSpaceless ( )
inline

Definition at line 9976 of file context.cpp.

9976 { reset(); }
void reset()
Definition: context.cpp:9977

Member Function Documentation

QCString HtmlSpaceless::remove ( const QCString input)
inlinevirtual

Returns the input after removing redundant whitespace

Implements TemplateSpacelessIntf.

Definition at line 9983 of file context.cpp.

9984  {
9985  QGString result;
9986  const char *p = s.data();
9987  char c;
9988  while ((c=*p++))
9989  {
9990  switch(c)
9991  {
9992  case '<': // start of a tag
9994  result+=c;
9995  break;
9996  case '>': // end of a tag
9997  if (!m_insideString) m_insideTag=FALSE,m_removeSpaces=TRUE;
9998  result+=c;
9999  break;
10000  case '\\': // escaped character in a string
10001  result+=c;
10002  if (m_insideString && *p) result+=*p++;
10003  break;
10004  case '"': case '\'':
10005  if (m_insideTag)
10006  {
10007  if (m_insideString==c) // end of string
10008  {
10009  m_insideString='\0';
10010  }
10011  else if (m_insideString=='\0') // start of string
10012  {
10013  m_insideString=c;
10014  }
10015  }
10016  result+=c;
10017  break;
10018  case ' ': case '\t': case '\n': // whitespace
10019  if (!m_insideTag) // outside tags strip consecutive whitespace
10020  {
10021  m_removeSpaces=TRUE;
10022  }
10023  else
10024  {
10025  result+=' ';
10026  }
10027  break;
10028  default:
10029  //if (m_removeSpaces) result+=' ';
10030  result+=c;
10031  m_removeSpaces=FALSE;
10032  break;
10033  }
10034  }
10035  result+='\0';
10036  //printf("HtmlSpaceless::remove({%s})={%s} m_insideTag=%d m_insideString=%c (%d) removeSpaces=%d\n",s.data(),result.data(),
10037  // m_insideTag,m_insideString,m_insideString,m_removeSpaces);
10038  return result.data();
10039  }
char * data() const
Definition: qgstring.h:42
static QCString result
const bool FALSE
Definition: qglobal.h:370
char m_insideString
Definition: context.cpp:10042
p
Definition: test.py:223
const char * data() const
Definition: qcstring.h:207
bool m_removeSpaces
Definition: context.cpp:10043
static QCString * s
Definition: config.cpp:1042
const bool TRUE
Definition: qglobal.h:371
void HtmlSpaceless::reset ( )
inlinevirtual

Reset filter state

Implements TemplateSpacelessIntf.

Definition at line 9977 of file context.cpp.

9978  {
9979  m_insideTag = FALSE;
9980  m_insideString = '\0';
9981  m_removeSpaces = TRUE;
9982  }
const bool FALSE
Definition: qglobal.h:370
char m_insideString
Definition: context.cpp:10042
bool m_removeSpaces
Definition: context.cpp:10043
const bool TRUE
Definition: qglobal.h:371

Member Data Documentation

char HtmlSpaceless::m_insideString
private

Definition at line 10042 of file context.cpp.

bool HtmlSpaceless::m_insideTag
private

Definition at line 10041 of file context.cpp.

bool HtmlSpaceless::m_removeSpaces
private

Definition at line 10043 of file context.cpp.


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