|
htmlLiteral
Literal text class | [Previous] [Main] [Next] |
| htmlLiteral is designed to encapsulates literal HTML code and text, without adding any addition encoding, such as translating > to >
| |
|
| |
| By default, all strings and text are stored internally as htmlText objects, unless encapsulated using htmlLiteral.
| |
|
| |
| #include <dcmicro/htmlpp/literal.h>
| |
|
| |
|
| |
| htmlText, htmlNoBreak
| |
|
| |
| None.
| |
|
| |
| htmlLiteral()
| |
| Constructs an empty object.
| |
|
| |
| htmlLiteral( const String& text )
| |
| Constructs an object, inserting the string text into it.
| |
|
| |
| htmlLiteral( const htmlText& rhs )
| |
| Copy constructor.
| |
|
| |
| virtual ~htmlLiteral()
| |
| Destroys the object.
| |
|
| |
| = | htmlLiteral& operator= ( const htmlText& rhs )
| |
| Replaces object contents with rhs, and returns a reference to it.
| |
|
| |
| = | htmlLiteral& operator= ( const String& text )
| |
| Replaces object contents with text, and returns a reference to it.
| |
|
|
| << | htmlLiteral& operator<< (const String& text )
| |
| Appends text, then returns a reference to the object.
| |
|
| |
| (String) | operator String() const
| |
| Convert the object contents and return them as a string.
| |
|
| |
| void Print( ostream& os ) const
| ||
| Outputs the object to os.
| |
|
| |
| Clone | htmlObject FAR * Clone() const
| |
| Returns a base-class pointer to a deep copy of the object.
| |
|
|
|
| |
| #include <stdio.h>
| |
| #include <stdlib.h>
| |
| #include <dcmicro/htmlpp/htmlpp.h>
| |
|
| |
| int main( void )
| |
| {
| |
| htmlCgi server ;
| |
| htmlPage page( "html++ example application" ) ;
| |
|
| |
| // Regular text containing symbols
| |
| String symbol_text = " < > & \" " ;
| |
|
| |
| String encoded_text ;
| |
| encoded_text << htmlText( symbol_text ) ;
| |
|
| |
| page << "Demo of literal vs. encoded text"
| |
| << htmlBreak()
| |
| << htmlBreak() ;
| |
|
| |
| page << "The first two lines produce different "
| |
| "HTML code, but are interpreted "
| |
| "identically by the browser. The third "
| |
| "line shows how HTML codes can be "
| |
| "encoded for display."
| |
| << htmlBreak() ;
| |
|
| |
| htmlBlockQuote block ;
| |
| block << htmlLiteral( symbol_text )
| |
| << htmlBreak()
| |
| << htmlText( symbol_text )
| |
| << htmlBreak()
| |
| << htmlText( encoded_text )
| |
| << htmlBreak() ;
| |
|
| |
| page << block ;
| |
|
| |
| server << page ;
| |
| return 0 ;
| |
| }
| |
|
| |
|
| |
| Content-Type: text/html
| |
| <HTML>
| |
| <HEAD>
| |
| <TITLE>html++ example application</TITLE>
| |
| </HEAD>
| |
| <BODY>
| |
| Demonstration of literal vs. encoded text<BR>
| |
| <BR>
| |
| The first two lines produce different HTML code, but are interpreted identically by the browser. The third line shows how HTML codes can be encoded for display.<BR>
| |
| <BLOCKQUOTE>
| |
| < > & " <BR>
| |
| < > & " <BR>
| |
| &lt; &gt; &amp; &quot; <BR>
| |
| </BLOCKQUOTE>
| |
| </BODY>
| |
| </HTML>
| |
|
| |
|
| |
| |
