Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

dom_document.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2005 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 */
00028 
00031 
00032 #ifndef header_dom_document
00033 #define header_dom_document
00034 
00035 #if _MSC_VER > 1000
00036 #pragma once
00037 #endif
00038 
00039 #include "dom_node.h"
00040 
00041 class CL_DomDocumentType;
00042 class CL_DomImplementation;
00043 class CL_DomCDATASection;
00044 class CL_DomProcessingInstruction;
00045 class CL_DomElement;
00046 class CL_DomDocumentFragment;
00047 class CL_DomComment;
00048 class CL_DomText;
00049 class CL_DomAttr;
00050 class CL_DomEntityReference;
00051 class CL_DomNodeList;
00052 class CL_DomDocument_Generic;
00053 
00054 //: DOM Document class.
00055 //- !group=Core/XML!
00056 //- !header=core.h!
00057 //- <p>The Document interface represents the entire HTML or XML document.
00058 //- Conceptually, it is the root of the document tree, and provides the
00059 //- primary access to the document's data.</p>
00060 //- <p>Since elements, text nodes, comments, processing instructions, etc.
00061 //- cannot exist outside the context of a Document, the Document interface
00062 //- also contains the factory methods needed to create these objects. The
00063 //- Node objects created have a ownerDocument attribute which associates
00064 //- them with the Document within whose context they were created.</p>
00065 class CL_DomDocument : public CL_DomNode
00066 {
00068 public:
00069         //: Constructs a DOM Document.
00070         CL_DomDocument();
00071 
00072 //      CL_DomDocument(CL_IODevice *input, bool delete_input = false, bool eat_whitespace = true);
00073 
00074         CL_DomDocument(const CL_SharedPtr<CL_DomNode_Generic> &impl);
00075         
00076         ~CL_DomDocument();
00077         
00079 public:
00080         //: Returns the Document Type Declaration (see CL_DomDocumentType) associated with this document.
00081         //- <p>For HTML documents as well as XML documents without a document type declaration this
00082         //- returns null. The DOM Level 1 does not support editing the Document Type Declaration,
00083         //- therefore docType cannot be altered in any way.</p>
00084         CL_DomDocumentType get_doctype();
00085 
00086         //: Returns the CL_DomImplementation object that handles this document.
00087         CL_DomImplementation get_implementation();
00088 
00089         //: Returns the root document element node.
00090         //- <p>This is a convenience attribute that allows direct access to the child node that is
00091         //- the root element of the document. For HTML documents, this is the element with the tag name "HTML".</p>
00092         CL_DomElement get_document_element();
00093         
00095 public:
00096         //: Creates an element of the type specified.
00097         //- <p>Note that the instance returned implements the Element interface, so attributes can be
00098         //- specified directly on the returned object.</p>
00099         //param tag_name: The name of the element type to instantiate. For XML, this is case-sensitive.
00100         CL_DomElement create_element(const std::string &tag_name);
00101 
00102         //: Creates an empty DocumentFragment object.
00103         CL_DomDocumentFragment create_document_fragment();
00104 
00105         //: Creates a Text node given the specified string.
00106         //param data: The data for the node.
00107         CL_DomText create_text_node(const std::string &data);
00108 
00109         //: Creates a Comment node given the specified string.
00110         //param data: The data for the node.
00111         CL_DomComment create_comment(const std::string &data);
00112 
00113         //: Creates a CDATASection node whose value is the specified string.
00114         //param data: The data for the CDATASection contents.
00115         CL_DomCDATASection create_cdata_section(const std::string &data);
00116         
00117         //: Creates a ProcessingInstruction node given the specified name and data strings.
00118         //param target: The target part of the processing instruction.
00119         //param data: The data for the node.
00120         CL_DomProcessingInstruction create_processing_instruction(
00121                 const std::string &target,
00122                 const std::string &data);
00123 
00124         //: Creates an Attr of the given name.
00125         //- <p>Note that the Attr instance can then be set on an Element using the setAttribute method.</p>
00126         //param name: The name of the attribute.
00127         CL_DomAttr create_attribute(const std::string &name);
00128 
00129         //: Creates an EntityReference object.
00130         //param name: The name of the entity to reference.
00131         CL_DomEntityReference create_entity_reference(const std::string &name);
00132 
00133         //: Returns a NodeList of all the Elements with a given tag name in the order in which they would be encountered in a preorder traversal of the Document tree.
00134         //param tagname: The name of the tag to match on. The special value "*" matches all tags.
00135         CL_DomNodeList get_elements_by_tag_name(const std::string &tag_name);
00136 /*
00137         //: Loads the DOM document as XML from an input source.
00138         //param input: Input source to read from.
00139         //param delete_input: If true, will delete input source after usage.
00140         //param eat_whitespace: Passed on to CL_XMLTokenizer::set_eat_whitespace.
00141         //param insert_point: Place in the DOM to insert the loaded XML code.
00142         //retval: List of all top level nodes created.
00143         std::vector<CL_DomNode> load(
00144                 CL_IODevice *input,
00145                 bool delete_input = false,
00146                 bool eat_whitespace = true,
00147                 CL_DomNode insert_point = CL_DomNode());
00148 
00149         //: Saves the DOM document as XML to an input source.
00150         //param output: Output source to write to.
00151         //param delete_output: If true, will delete output source after usage.
00152         //param insert_whitespace: Passed on to CL_XMLWriter::set_insert_whitespace.
00153         void save(CL_IODevice *output, bool delete_output = false, bool insert_whitespace = true);
00154 */
00155         //: Removes all nodes from the DOM document.
00156         void clear_all();
00157 
00159 private:
00160 };
00161 
00162 #endif

Generated on Sat Feb 19 22:51:15 2005 for npcore by  doxygen 1.4.1