os_page


An HTML page.

An os_page is an HTML page with content that is rendered in a browser window. An os_page is composed of an os_head that contains meta-information elements and an os_body that contains elements to be rendered.

For convenience, many member functions like title() and background() simply pass through to the underlying os_head or os_body . The head and body can be accessed directly through the head() and body() member functions. The find, remove, and replace member functions first search the head and then the body for elements matching a specified key.

Elements are inserted into the page body through either the add() member functions or operator<< .

To generate HTML from an os_page as the output from a Common Gateway Interface (CGI) program, set the os_page output type to cgi , either in the constructor or through the output() member function. This setting adds the MIME content tag " Content-Type: text/html " to the beginning of the output stream. The output type is non_cgi by default.

Declaration

#include <ospace/web/page.h>
class os_page : public os_element

Enums

enum os_page::output_type
  {
  non_cgi,  // Adds no MIME content tag to the beginning of the page output.
  cgi       // Adds an HTML MIME content tag to the beginning of the page output
  };

Interface

Constructor
os_page( output_type output )
Constructs a page with output type output (default non_cgi ).
Constructor
os_page( const string& title , output_type output )
Constructs a page with title title and output type output (default non_cgi ).
Constructor
os_page( const string& title , const string& background , output_type output )
Constructs a page with title title , body background image URL background , and output type output (default non_cgi ).
Constructor
os_page( const os_page& rhs )
Constructs a page that is a copy of rhs .
Destructor
/* virtual */ ~os_page()
Destroys the page.
<<
os_page& operator<<( const os_element& element )
Inserts a copy of element into the body and returns a reference to the page.
<<
os_page& operator<<( const string& text )
Inserts an os_text element created from text into the body, and returns a reference to the page.
=
os_page& operator=( const os_page& rhs )
Replaces the page contents with a copy of rhs and returns a reference to the page.
add
os_element* add( const string& text )
Adds, to the body, an os_text element created from text , and returns a pointer to the new element.
add
os_element* add( const os_element& element )
Adds a copy of element to the body and returns a pointer to the new element.
background
os_page& background( const string& background )
Sets the body background image URL to background and returns a reference to the page.
background
string background() const
Returns the body background image URL, or the empty string if not set.
body
os_body& body()
Returns a reference to the page body component.
clone
/* virtual */ os_element* clone() const
Returns a base class pointer to a heap-based deep copy of the page.
find_all
/* virtual */ vector<os_element*> find_all( const string& key , os_element::search_depth depth )
Returns a list of pointers to the elements with key key found on a depth (default os_element::shallow ) search. Returns an empty list if no matching elements are found.
find_first
/* virtual */ os_element* find_first( const string& key , os_element::search_depth depth )
Returns a pointer to the first element with key key found on a depth (default os_element::shallow ) search. Returns 0 if no matching element is found.
head
os_head& head()
Returns a reference to the page head component.
output
int output() const
Returns the output type.
output
os_page& output( output_type output )
Sets the output type to output and returns a reference to the page.
print
/* virtual */ void print( ostream& os ) const
Prints the page to os .
remove_all
/* virtual */ int remove_all( const string& key , os_element::search_depth depth )
Removes all elements with key key found on depth (default os_element::shallow ) search, and returns the total number of elements removed. Returns 0 if no matching elements are found.
remove_first
/* virtual */ bool remove_first( const string& key , os_element::search_depth depth )
Removes the first element with key key found on depth (default os_element::shallow ) search, and returns true . Returns false if no matching element is found.
replace_all
/* virtual */ int replace_all( const string& key , const os_element& replacement , os_element::search_depth depth )
Replaces, with replacement , all elements with key key found on depth (default os_element::shallow ) search, and returns the total number of elements replaced. Returns 0 if no matching elements are found.
replace_first
/* virtual */ bool replace_first( const string& key , const os_element& replacement , os_element::search_depth depth )
Replaces, with replacement , the first element with key key found on depth (default os_element::shallow ) search, and returns true . Returns false if no matching element is found.
title
string title() const
Returns the title, or the empty string if not set.
title
os_page& title( const string& title )
Sets the title to title and returns a reference to the page.

Copyright©1994-2026 Recursion Software LLC
All Rights Reserved