VTK
dox/IO/XMLParser/vtkXMLUtilities.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkXMLUtilities.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00023 #ifndef __vtkXMLUtilities_h
00024 #define __vtkXMLUtilities_h
00025 
00026 #include "vtkIOXMLParserModule.h" // For export macro
00027 #include "vtkObject.h"
00028 
00029 class vtkXMLDataElement;
00030 
00031 class VTKIOXMLPARSER_EXPORT vtkXMLUtilities : public vtkObject
00032 {
00033 public:
00034   static vtkXMLUtilities* New();
00035   vtkTypeMacro(vtkXMLUtilities, vtkObject);
00036 
00038 
00041   static void EncodeString(const char *input, int input_encoding,
00042                            ostream &output, int output_encoding,
00043                            int special_entities = 0);
00045 
00047 
00052   static void CollateAttributes(vtkXMLDataElement*,
00053                                 ostream&,
00054                                 const char *sep = 0);
00056 
00057   //BTX
00059 
00066   static void FlattenElement(vtkXMLDataElement*,
00067                              ostream&,
00068                              vtkIndent *indent = 0,
00069                              int indent_attributes = 1);
00071 
00073 
00076   static int WriteElementToFile(vtkXMLDataElement*,
00077                                 const char *filename,
00078                                 vtkIndent *indent = 0);
00079   //ETX
00081 
00082   //BTX
00084 
00093   static vtkXMLDataElement* ReadElementFromStream(
00094     istream&, int encoding = VTK_ENCODING_NONE);
00095   static vtkXMLDataElement* ReadElementFromString(
00096     const char *str, int encoding = VTK_ENCODING_NONE);
00097   static vtkXMLDataElement* ReadElementFromFile(
00098     const char *filename, int encoding = VTK_ENCODING_NONE);
00099   //ETX
00101 
00103 
00110   static void ReadElementFromAttributeArray(
00111         vtkXMLDataElement *element,
00112         const char** atts,
00113         int encoding);
00115 
00116   //BTX
00118 
00124   static int FindSimilarElements(vtkXMLDataElement *elem,
00125                                  vtkXMLDataElement *tree,
00126                                  vtkXMLDataElement ***results);
00127   //ETX
00129 
00131 
00134   static void FactorElements(vtkXMLDataElement *tree);
00135   static void UnFactorElements(vtkXMLDataElement *tree);
00137 
00138 protected:
00139   vtkXMLUtilities() {};
00140   ~vtkXMLUtilities() {};
00141 
00142   static int FactorElementsInternal(vtkXMLDataElement *tree,
00143                                     vtkXMLDataElement *root,
00144                                     vtkXMLDataElement *pool);
00145   static int UnFactorElementsInternal(vtkXMLDataElement *tree,
00146                                       vtkXMLDataElement *pool);
00147 
00148 private:
00149   vtkXMLUtilities(const vtkXMLUtilities&); // Not implemented
00150   void operator=(const vtkXMLUtilities&); // Not implemented
00151 };
00152 
00153 #endif
00154 
00155 
00156 // VTK-HeaderTest-Exclude: vtkXMLUtilities.h