CLAM-Development
1.1
|
00001 /* 00002 * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG) 00003 * UNIVERSITAT POMPEU FABRA 00004 * 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 * 00020 */ 00021 #ifndef _LibXmlDomWriter_hxx_ 00022 #define _LibXmlDomWriter_hxx_ 00023 00024 #include <iosfwd> 00025 #include <libxml++/document.h> 00026 00027 namespace xmlpp 00028 { 00029 class Document; 00030 class Node; 00031 } 00032 00033 namespace CLAM 00034 { 00035 00041 class LibXmlDomWriter 00042 { 00043 public: 00044 LibXmlDomWriter() 00045 { 00046 mShouldIndent=false; 00047 mShouldCanonicalize=false; 00048 } 00049 00050 void write(std::ostream & target, xmlpp::Node * node) 00051 { 00052 xmlpp::Document document; 00053 document.create_root_node_by_import(node); 00054 write(target, &document); 00055 } 00056 00057 void write(std::ostream & target, xmlpp::Document * node) 00058 { 00059 if (mShouldIndent) 00060 node->write_to_stream_formatted(target,"UTF-8"); 00061 else 00062 node->write_to_stream(target,"UTF-8"); 00063 } 00064 00065 void DoCanonicalFormat(bool shouldDo = true) 00066 { 00067 mShouldCanonicalize=shouldDo; 00068 } 00069 void DoIndentedFormat(bool shouldDo = true) 00070 { 00071 mShouldIndent=shouldDo; 00072 } 00073 private: 00074 bool mShouldIndent; 00075 bool mShouldCanonicalize; 00076 }; 00077 00078 00079 00080 } 00081 #endif//_LibXmlDomWriter_hxx_ 00082