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

📄 xmlelement.h

📁 C++高级编程这本书所附的源代码
💻 H
字号:
// XMLElement.h

#include <string>
#include <vector>
#include <map>
#include <iostream>

class XMLElement
{
 public:
  XMLElement();
  ~XMLElement();

  void setElementName(const std::string& inName);

  void setAttribute(const std::string& inAttributeName,
		    const std::string& inAttributeValue);

  void addSubElement(const XMLElement* inElement);

  // Setting a text node will override any nested elements
  void setTextNode(const std::string& inValue);

  friend std::ostream& operator<<(std::ostream& outStream,
			     const XMLElement& inElem);

 protected:
  void writeToStream(std::ostream& outStream, int inIndentLevel = 0) const;

  void indentStream(std::ostream& outStream, int inIndentLevel) const;

 private:
  std::string                            mElementName;
  std::map<std::string, std::string>     mAttributes;
  std::vector<const XMLElement*>         mSubElements;
  std::string                            mTextNode;
};

⌨️ 快捷键说明

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