Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

xmlUtil::Source Class Reference

#include <Source.h>

List of all members.

Public Methods

 Source (DOM_Document doc, const char *creator, const char *creatorCVSID)
 ~Source ()
void add (const DOM_Element after=DOM_Element())

Private Attributes

DOM_Document m_doc
DOM_Element m_me
std::string m_creator
std::string m_myCVSID


Detailed Description

This class provides an interface to the <source> element of gdd.dtd. For now only provide a way to write one. Someday might also provide interface to read pre-existing ones.

Definition at line 16 of file Source.h.


Constructor & Destructor Documentation

xmlUtil::Source::Source DOM_Document    doc,
const char *    creator,
const char *    creatorCVSID
 

Definition at line 29 of file Source.cxx.

References m_myCVSID, and stripDollar().

00030                                 : m_doc(doc), m_creator(creator)  {
00031     
00032     char * tmp = new char[strlen(creatorCVSID) + 1];
00033     strcpy(tmp, creatorCVSID);
00034     m_myCVSID = std::string(stripDollar(tmp));
00035     delete [] tmp;
00036   }

xmlUtil::Source::~Source   [inline]
 

Definition at line 20 of file Source.h.

00020 {};


Member Function Documentation

void xmlUtil::Source::add const DOM_Element    parentArg = DOM_Element()
 

Definition at line 38 of file Source.cxx.

References m_creator, m_doc, m_myCVSID, and stripDollar().

Referenced by main().

00038                                         {
00039     static char * unknownId = "unidentified input file";
00040     DOM_Element docElt = m_doc.getDocumentElement();
00041     DOM_Element parent = parentArg;
00042     if (parent == DOM_Element()) {
00043       parent = docElt;
00044     }
00045 
00046     DOM_Element source = m_doc.createElement("source");
00047 
00048     // Document element should have a CVSid attribute
00049     DOMString idAtt = docElt.getAttribute("CVSid");
00050     char * strippedRaw;
00051     char * myRaw = 0;
00052 
00053     if (idAtt != DOMString() ){
00054       const char * raw   = xml::Dom::transToChar(idAtt);
00055       unsigned   len = strlen(raw);
00056       if (len) {
00057         myRaw = new char[len+1];
00058         strcpy(myRaw, raw);
00059         strippedRaw = stripDollar(myRaw);
00060       }
00061     }
00062     else strippedRaw = unknownId;
00063 
00064     DOMString newAtt = DOMString(strippedRaw);
00065 
00066     source.setAttribute("inputId", newAtt);
00067 
00068     // Already have creator ID as std::string
00069     source.setAttribute(DOMString("creatorId"),
00070                         DOMString(m_myCVSID.c_str()));
00071     
00072     std::string theText = 
00073       std::string("Do not edit! This file automatically created by ");
00074     theText.append(m_creator);
00075     DOM_Text    sourceText = m_doc.createTextNode(theText.c_str()); 
00076 
00077 
00078     source.appendChild(sourceText);
00079 
00080     if (myRaw) delete [] myRaw;
00081     // Finally need to insert this node as the first child of specified elt
00082     parent.insertBefore(source, parent.getFirstChild());
00083   }


Member Data Documentation

std::string xmlUtil::Source::m_creator [private]
 

Definition at line 27 of file Source.h.

Referenced by add().

DOM_Document xmlUtil::Source::m_doc [private]
 

Definition at line 25 of file Source.h.

Referenced by add().

DOM_Element xmlUtil::Source::m_me [private]
 

Definition at line 26 of file Source.h.

std::string xmlUtil::Source::m_myCVSID [private]
 

Definition at line 28 of file Source.h.

Referenced by add(), and Source().


The documentation for this class was generated from the following files:
Generated on Wed Oct 16 14:02:50 2002 by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001