Initial source commit
This commit is contained in:
commit
f1384c11ee
335 changed files with 52715 additions and 0 deletions
57
minorGems/formats/html/HTMLUtils.cpp
Normal file
57
minorGems/formats/html/HTMLUtils.cpp
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Modification History
|
||||
*
|
||||
* 2002-September-12 Jason Rohrer
|
||||
* Created.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "HTMLUtils.h"
|
||||
|
||||
#include "minorGems/util/stringUtils.h"
|
||||
#include "minorGems/util/SimpleVector.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
||||
char *HTMLUtils::removeAllTags( char *inString ) {
|
||||
|
||||
SimpleVector<char> *returnStringVector = new SimpleVector<char>();
|
||||
|
||||
|
||||
int stringLength = strlen( inString );
|
||||
|
||||
int i = 0;
|
||||
|
||||
while( i < stringLength ) {
|
||||
if( inString[i] == '<' ) {
|
||||
// the start of a tag
|
||||
|
||||
// skip all until (and including) close of tag
|
||||
while( i < stringLength && inString[i] != '>' ) {
|
||||
// do nothing
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
returnStringVector->push_back( inString[i] );
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
int numChars = returnStringVector->size();
|
||||
char *returnString = new char[ numChars + 1 ];
|
||||
|
||||
for( i=0; i<numChars; i++ ) {
|
||||
returnString[i] = *( returnStringVector->getElement( i ) );
|
||||
}
|
||||
|
||||
returnString[ numChars ] = '\0';
|
||||
|
||||
delete returnStringVector;
|
||||
|
||||
return returnString;
|
||||
}
|
46
minorGems/formats/html/HTMLUtils.h
Normal file
46
minorGems/formats/html/HTMLUtils.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Modification History
|
||||
*
|
||||
* 2002-September-12 Jason Rohrer
|
||||
* Created.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef HTML_UTILS_INCLUDED
|
||||
#define HTML_UTILS_INCLUDED
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Utilities for processing HTML.
|
||||
*
|
||||
* @author Jason Rohrer
|
||||
*/
|
||||
class HTMLUtils {
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Removes all HTML tags from an HTML string.
|
||||
*
|
||||
* @param the HTML data as a \0-terminated string.
|
||||
* Must be destroyed by caller if non-const.
|
||||
*
|
||||
* @return data with all HTML tags removed as a newly allocated
|
||||
* \0-terminated string.
|
||||
* Must be destroyed by caller.
|
||||
*/
|
||||
static char *removeAllTags( char *inString );
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue