LTP GCOV extension - code coverage report
Current view: directory - src/libutil - xml-writer.hh
Test: app.info
Date: 2008-11-20 Instrumented lines: 7
Code covered: 100.0 % Executed lines: 7

       1                 : #ifndef __XML_WRITER_H
       2                 : #define __XML_WRITER_H
       3                 : 
       4                 : #include <iostream>
       5                 : #include <string>
       6                 : #include <list>
       7                 : #include <map>
       8                 : 
       9                 : 
      10                 : namespace nix {
      11                 : 
      12                 : using std::string;
      13                 : using std::map;
      14                 : using std::list;
      15                 : 
      16                 : 
      17                 : typedef map<string, string> XMLAttrs;
      18                 : 
      19                 : 
      20                 : class XMLWriter
      21                 : {
      22                 : private:
      23                 :     
      24                 :     std::ostream & output;
      25                 : 
      26                 :     bool indent;
      27                 :     bool closed;
      28                 : 
      29                 :     list<string> pendingElems;
      30                 : 
      31                 : public:
      32                 : 
      33                 :     XMLWriter(bool indent, std::ostream & output);
      34                 :     ~XMLWriter();
      35                 : 
      36                 :     void close();
      37                 : 
      38                 :     void openElement(const string & name,
      39                 :         const XMLAttrs & attrs = XMLAttrs());
      40                 :     void closeElement();
      41                 : 
      42                 :     void writeEmptyElement(const string & name,
      43                 :         const XMLAttrs & attrs = XMLAttrs());
      44                 :     
      45                 :     void writeCharData(const string & data);
      46                 : 
      47                 : private:
      48                 :     void writeAttrs(const XMLAttrs & attrs);
      49                 : 
      50                 :     void indent_(unsigned int depth);
      51                 : };
      52                 : 
      53                 : 
      54                 : class XMLOpenElement
      55                 : {
      56                 : private:
      57                 :     XMLWriter & writer;
      58                 : public:
      59                 :     XMLOpenElement(XMLWriter & writer, const string & name,
      60             234 :         const XMLAttrs & attrs = XMLAttrs())
      61             234 :         : writer(writer)
      62                 :     {
      63             234 :         writer.openElement(name, attrs);
      64             234 :     }
      65             234 :     ~XMLOpenElement()
      66                 :     {
      67             234 :         writer.closeElement();
      68             234 :     }
      69                 : };
      70                 : 
      71                 :  
      72                 : }
      73                 : 
      74                 : 
      75                 : #endif /* !__XML_WRITER_H */

Generated by: LTP GCOV extension version 1.6