htmlLiteral
Literal text class
[Previous] [Main] [Next]


Description
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.  
 
Declaration
#include <dcmicro/htmlpp/literal.h>  
 
Hierarchy
htmlliteral.gif  
 
See Also
htmlText, htmlNoBreak  
 
Related Constants/Definitions
None.  
 
Constructors
htmlLiteral()  
Constructs an empty object.  
 
htmlLiteral( const String& text )  
Constructs an object, inserting the string text into it.  
 
htmlLiteral( const htmlText& rhs )  
Copy constructor.  
 
Destructors
virtual ~htmlLiteral()  
Destroys the object.  
 
Member Methods
=   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.  
 
Print   void Print( ostream& os ) const  
Outputs the object to os.  
 
ClonehtmlObject FAR * Clone() const  
Returns a base-class pointer to a deep copy of the object.  
 
Example Use
 
#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 ;  
}  
 
Example Output
 
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>  
 &lt;  &gt;  &amp;  &quot;  <BR>  
 &amp;lt;  &amp;gt;  &amp;amp;  &amp;quot;  <BR>  
</BLOCKQUOTE>  
</BODY>  
</HTML>  
 
 
literal.gif  



©1998 DC Micro Development. All rights reserved.
No portion of this document may be c opied or reproduced without expressed written consent.
html++ is a trademark of DC Micro Development.