|
htmlMeta
Meta information class | [Previous] [Main] [Next] |
| 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.
| |
|
| |
| #include <dcmicro/htmlpp/meta.h>
| |
|
| |
|
| |
| htmlPage, htmlHead
| |
| Tutorial : Advanced Topics : Self-running Presentations
| |
| Tutorial : Advanced Topics : Redirecting Browsers to Another Page
| |
|
| |
| #define SET_HTTP_EQUIV TRUE
| |
|
| |
| 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.
| |
|
| |
| virtual ~htmlMeta()
| |
| Destroys the object.
| |
|
| |
| Name | htmlMeta& 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.
| |
|
| |
| Name | String Name() const
| |
| Returns the name, or an empty string if not set.
| |
|
| |
| Content | htmlMeta& Content( const String& content )
| |
| Sets the meta content to content, then returns a reference to the object.
| |
|
| |
| Content | String Content() const
| |
| Returns the content, or an empty string if not set.
| |
|
| |
| Description | htmlMeta& Description( const String& text )
| |
| Sets the meta information name to "description", and the content to text, then returns a reference to the object.
| |
|
| |
| Description | String Description() const
| |
| If the meta information name is "description", the content is returned as a string. Otherwise an empty string is returned.
| |
|
| |
| Keywords | htmlMeta& Keywords( const String& text )
| |
| Sets the meta information name to "keywords", and the content to text, then returns a reference to the object.
| |
|
| |
| Keywords | String Keywords() const
| |
| If the meta information name is "keywords", the content is returned as a string. Otherwise an empty string is returned.
| |
|
| |
| Copyright | htmlMeta& Copyright( const String& text )
| |
| Sets the meta information name to "copyright", and the content to text, then returns a reference to the object.
| |
|
| |
| Copyright | String Copyright() const
| |
| If the meta information name is "copyright", the content is returned as a string. Otherwise an empty string is returned.
| |
|
| |
| Refresh | htmlMeta& 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.
| |
|
| |
| Refresh | String 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.
| |
|
| |
| 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" ) ;
| |
|
| |
| // 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 ;
| |
| }
| |
|
| |
|
| |
| 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>
| |
|
| |
| |
|
| |
|
| |
