htmlMeta
Meta information class
[Previous] [Main] [Next]


Description
htmlMeta encapsultes the <META> tag. It is commonly used to add meta information describing page content to pages, such as summaries, copyright notices, and keywords.  
 
Meta information is often used by search engines to identify and index documents. A special type of meta information, called HTTP response headers, can be used to create pages that automatically display other pages after a delay. Such self-running presentations are easily created using the Refresh() method of this class.  
 
Meta information belongs within the <HEAD></HEAD> tags of a document. htmlPage objects implicitly contain an htmlHead object, so it's not normally necessary to explicitly create htmlHead objects. The htmlPage::Head() method offers a convenient interface for adding htmlMeta objects directly to any htmlPage object.  
 
Declaration
#include <dcmicro/htmlpp/meta.h>  
 
Hierarchy
htmlmeta.gif  
 
See Also
htmlPage, htmlHead  
Tutorial : Advanced Topics : Self-running Presentations  
Tutorial : Advanced Topics : Redirecting Browsers to Another Page  
 
Related Constants/Definitions
#define SET_HTTP_EQUIV TRUE  
 
Constructors
htmlMeta()  
Constructs an empty object.  
 
htmlMeta(const String& name,  
   const String& content,  
   Boolean set_http_equiv = FALSE )  
Constructs a meta information object, suing the specified name and content values. If set_http_equiv is TRUE, the object's name and content values will be output as an HTTP response header.  
 
htmlMeta( const htmlText& rhs )  
Copy constructor.  
 
Destructor
virtual ~htmlMeta()  
Destroys the object.  
 
Member Methods
NamehtmlMeta& Name( const String& name,  
   Boolean set_http_equiv = FALSE )  
Sets the meta information name to name, then returns a reference to the object. If set_http_equiv is TRUE, the object's name and content will be output as an HTTP response header.  
 
NameString Name() const  
Returns the name, or an empty string if not set.  
 
ContenthtmlMeta& Content( const String& content )  
Sets the meta content to content, then returns a reference to the object.  
 
ContentString Content() const  
Returns the content, or an empty string if not set.  
 
DescriptionhtmlMeta& Description( const String& text )  
Sets the meta information name to "description", and the content to text, then returns a reference to the object.  
 
DescriptionString Description() const  
If the meta information name is "description", the content is returned as a string. Otherwise an empty string is returned.  
 
KeywordshtmlMeta& Keywords( const String& text )  
Sets the meta information name to "keywords", and the content to text, then returns a reference to the object.  
 
KeywordsString Keywords() const  
If the meta information name is "keywords", the content is returned as a string. Otherwise an empty string is returned.  
 
CopyrighthtmlMeta& Copyright( const String& text )  
Sets the meta information name to "copyright", and the content to text, then returns a reference to the object.  
 
CopyrightString Copyright() const  
If the meta information name is "copyright", the content is returned as a string. Otherwise an empty string is returned.  
 
RefreshhtmlMeta& Refresh( int seconds, const String& url )  
Sets the meta information name to a "refresh" HTTP-EQUIV response header, which will cause the browser to automatically display document url after seconds delay. A reference to the object is returned. This feature is supported by Netscape 1.1 and compatible browsers, and is useful for creating self-running presentations.  
 
RefreshString Refresh( int& seconds ) const  
If the meta object name is set to "refresh" using the HTTP-EQUIV option, the content is parsed, seconds is set to the refresh time, and the url to be displayed is returned as a string. Otherwise, an empty string is returned and seconds is not modified.  
 
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" ) ;  
 
   //  Create a general meta tag  
   htmlMeta  m1( "resource-type""document" ) ;  
 
   //  Create a meta tag using HTTP-EQUIV  
   //  client-pull directive to cause automatic  
   //  loading of the specified URL in  
   //  five seconds.  
   htmlMeta  m2( "refresh",   
                 "5; http://www.dcmicro.com",   
                 SET_HTTP_EQUIV ) ;  
 
   //  The following meta tag is equivalent to the one  
   //  above, but a little easier to use. Note: Only one  
   //  'refresh' statement is actually needed.  
   htmlMeta  m3 ;  
   m3.Refresh( 5, "http://www.dcmicro.com" ) ;  
 
   htmlMeta  m4 ;  
   m4.Keywords( "keywords separated by spaces" ) ;  
 
   htmlMeta  m5 ;  
   m5.Description( "You can place descriptive "  
          "text about your document here. Search "  
          "engines can use it to identify and "  
          "index your page." ) ;  
 
   //  Meta information must be placed in  
   //  in the page Head object.  
   page.Head() << m1 << m2 << m3 << m4 << m5 ;  
 
   //  Retrieve the auto-refresh information   
   //  set in the m3 object.  
   int     reload_timeout ;  
   String  url = m3.Refresh( reload_timeout ) ;  
   page << "The document at "  
        << url  
        << " will automatically display in "  
        << reload_timeout << " seconds." ;  
 
   server << page ;  
   return 0 ;  
}  
 
Program Output
 
Content-Type: text/html  
<HTML>  
<HEAD>  
<TITLE>html++ example application</TITLE>  
<META name="resource-type" content="document">  
<META HTTP-EQUIV="refresh" content="5; URL=http://www.dcmicro.com">  
<META HTTP-EQUIV="refresh" content="5; URL=http://www.dcmicro.com">  
<META name="keywords" content="keywords separated by spaces">  
<META name="description" content="You can place descriptive text about your document here. Search engines can use it to identify and index your page.">  
</HEAD>  
<BODY>  
The document at http://www.dcmicro.com will automatically display in 5 seconds.  
</BODY>  
</HTML>  
 
meta.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.