⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmlprinter.cpp

📁 GPS Manager is a GUI for downloading, organizing, maintaining, and uploading GPS data (i.e. tracks,
💻 CPP
字号:
/*gpsmgr: A program for managing GPS informationCopyright (C) 2003 Austin BinghamThis program is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public Licenseas published by the Free Software Foundation; either version 2of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.You can reach the author at:    abingham@spamcop.net*/#include "xmlPrinter.h"#include <iostream>XMLPrinter::XMLPrinter(std::ostream& out) :    mOS (out),    mIndent ("  "),    mIndentLevel (0){}XMLPrinter::XMLPrinter(std::ostream& out, const std::string& indent_token) :    mOS (out),    mIndent (indent_token),    mIndentLevel (0){}void XMLPrinter::flushWrites() const{    mOS.flush();}void XMLPrinter::write(const std::string& _sz) const {    mOS << _sz;}void XMLPrinter::writeLn(const std::string& _sz) const {    write(_sz);    mOS << std::endl;}std::string XMLPrinter::simpleTag(const std::string& _tag, const std::string& _data) const {    std::string rval = getIndentString();    rval = rval + "<" + _tag + ">";    rval = rval + _data;    rval = rval + "</" + _tag + ">";    return rval;}std::string XMLPrinter::simpleTag(const std::string& _tag, const std::string& _data,			     const Attrs& _atts) const{    std::string rval = getIndentString();    rval = rval + "<" + _tag + transformAttributes(_atts) + ">";    rval = rval + _data;    rval = rval + "</" + _tag + ">";    return rval;}std::string XMLPrinter::simpleTag(const std::string& _tag, const Attrs& _atts) const {    std::string rval = getIndentString();    rval = rval + "<" + _tag + transformAttributes(_atts) + "/>";    return rval;}std::string XMLPrinter::simpleTag(const std::string& _tag) const {    std::string rval = getIndentString();    rval = rval + "<" + _tag + "/>";    return rval;}std::string XMLPrinter::open(const std::string& _sz) const {    std::string rval = getIndentString() + "<" + _sz + ">";    int& ref = (int)mIndentLevel; // dancing around constness    ++ref;    return rval;}std::string XMLPrinter::open(const std::string& _sz, const Attrs& _atts) const {    std::string rval = getIndentString() + "<" + _sz + transformAttributes(_atts) + ">";    int& ref = (int)mIndentLevel;    ++ref;    return rval;}std::string XMLPrinter::transformAttributes(const Attrs& _atts) const {    std::string rval = "";    for (Attrs::const_iterator itr = _atts.begin();	 itr != _atts.end();	 ++itr)    {	rval = rval + " " +	       itr->first + "=\"" +	       itr->second + "\"";    }        return rval;}std::string XMLPrinter::close(const std::string& _sz, bool indent) const {    int& ref = (int)mIndentLevel;    --ref;    if (indent)	return getIndentString() + "</" + _sz + ">";    else	return "</" + _sz + ">";}std::string XMLPrinter::comment(const std::string& text) const{    return "<!-- " + text + " -->";}std::string XMLPrinter::getIndentString() const {    std::string rval = "";    for (int i = 0; i < mIndentLevel; ++i) {	rval = rval + mIndent;    }    return rval;}std::string XMLPrinter::getIndentToken() const { return mIndent; }void XMLPrinter::setIndentToken(const std::string& _sz) { mIndent = _sz; }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -