diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2007-04-03 03:49:53 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2007-04-03 03:49:53 +0000 |
| commit | f4c20290509d7ed3a8fd5304577e7a4cc0b9d974 (patch) | |
| tree | 13cdf64f7cf134f397a7165b7a3fe0807e37026b /src/xmldocument.cpp | |
| parent | 74d4c8cd27334fc7204d5a8773deb3d424565778 (diff) | |
| download | libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.gz libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.bz2 libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.xz libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.zip | |
Ok, no code is left in src, it's all in src/old. We'll gradually move code back
into src as it's fixed and re-org'd. This includes tests, which, I may write a
unit test system into libbu++ just to make my life easier.
Diffstat (limited to 'src/xmldocument.cpp')
| -rw-r--r-- | src/xmldocument.cpp | 149 |
1 files changed, 0 insertions, 149 deletions
diff --git a/src/xmldocument.cpp b/src/xmldocument.cpp deleted file mode 100644 index d7867d5..0000000 --- a/src/xmldocument.cpp +++ /dev/null | |||
| @@ -1,149 +0,0 @@ | |||
| 1 | #include <stdio.h> | ||
| 2 | #include <stdlib.h> | ||
| 3 | #include "xmlwriter.h" | ||
| 4 | |||
| 5 | XmlDocument::XmlDocument( XmlNode *pRoot ) | ||
| 6 | { | ||
| 7 | this->pRoot = pRoot; | ||
| 8 | pCurrent = NULL; | ||
| 9 | bCompleted = (pRoot!=NULL); | ||
| 10 | } | ||
| 11 | |||
| 12 | XmlDocument::~XmlDocument() | ||
| 13 | { | ||
| 14 | if( pRoot ) | ||
| 15 | { | ||
| 16 | delete pRoot; | ||
| 17 | } | ||
| 18 | } | ||
| 19 | |||
| 20 | void XmlDocument::addNode( const char *sName, const char *sContent, bool bClose ) | ||
| 21 | { | ||
| 22 | if( pRoot == NULL ) | ||
| 23 | { | ||
| 24 | // This is the first node, so ignore position and just insert it. | ||
| 25 | pCurrent = pRoot = new XmlNode( sName, NULL, sContent ); | ||
| 26 | } | ||
| 27 | else | ||
| 28 | { | ||
| 29 | pCurrent = pCurrent->addChild( sName, sContent ); | ||
| 30 | } | ||
| 31 | |||
| 32 | if( bClose ) | ||
| 33 | { | ||
| 34 | closeNode(); | ||
| 35 | } | ||
| 36 | } | ||
| 37 | |||
| 38 | void XmlDocument::setName( const char *sName ) | ||
| 39 | { | ||
| 40 | pCurrent->setName( sName ); | ||
| 41 | } | ||
| 42 | |||
| 43 | bool XmlDocument::isCompleted() | ||
| 44 | { | ||
| 45 | return bCompleted; | ||
| 46 | } | ||
| 47 | |||
| 48 | XmlNode *XmlDocument::getRoot() | ||
| 49 | { | ||
| 50 | return pRoot; | ||
| 51 | } | ||
| 52 | |||
| 53 | XmlNode *XmlDocument::detatchRoot() | ||
| 54 | { | ||
| 55 | XmlNode *pTemp = pRoot; | ||
| 56 | pRoot = NULL; | ||
| 57 | return pTemp; | ||
| 58 | } | ||
| 59 | |||
| 60 | XmlNode *XmlDocument::getCurrent() | ||
| 61 | { | ||
| 62 | return pCurrent; | ||
| 63 | } | ||
| 64 | |||
| 65 | void XmlDocument::closeNode() | ||
| 66 | { | ||
| 67 | if( pCurrent != NULL ) | ||
| 68 | { | ||
| 69 | pCurrent = pCurrent->getParent(); | ||
| 70 | |||
| 71 | if( pCurrent == NULL ) | ||
| 72 | { | ||
| 73 | bCompleted = true; | ||
| 74 | } | ||
| 75 | } | ||
| 76 | } | ||
| 77 | |||
| 78 | void XmlDocument::addProperty( const char *sName, const char *sValue ) | ||
| 79 | { | ||
| 80 | if( pCurrent ) | ||
| 81 | { | ||
| 82 | pCurrent->addProperty( sName, sValue ); | ||
| 83 | } | ||
| 84 | } | ||
| 85 | |||
| 86 | void XmlDocument::addProperty( const char *sName, const unsigned char nValue ) | ||
| 87 | { | ||
| 88 | char buf[12]; | ||
| 89 | sprintf( buf, "%hhi", nValue ); | ||
| 90 | addProperty( sName, buf ); | ||
| 91 | } | ||
| 92 | |||
| 93 | void XmlDocument::addProperty( const char *sName, const char nValue ) | ||
| 94 | { | ||
| 95 | char buf[12]; | ||
| 96 | sprintf( buf, "%hhi", nValue ); | ||
| 97 | addProperty( sName, buf ); | ||
| 98 | } | ||
| 99 | |||
| 100 | void XmlDocument::addProperty( const char *sName, const unsigned short nValue ) | ||
| 101 | { | ||
| 102 | char buf[12]; | ||
| 103 | sprintf( buf, "%hi", nValue ); | ||
| 104 | addProperty( sName, buf ); | ||
| 105 | } | ||
| 106 | |||
| 107 | void XmlDocument::addProperty( const char *sName, const short nValue ) | ||
| 108 | { | ||
| 109 | char buf[12]; | ||
| 110 | sprintf( buf, "%hi", nValue ); | ||
| 111 | addProperty( sName, buf ); | ||
| 112 | } | ||
| 113 | |||
| 114 | void XmlDocument::addProperty( const char *sName, const int nValue ) | ||
| 115 | { | ||
| 116 | char buf[12]; | ||
| 117 | sprintf( buf, "%d", nValue ); | ||
| 118 | addProperty( sName, buf ); | ||
| 119 | } | ||
| 120 | |||
| 121 | void XmlDocument::addProperty( const char *sName, const unsigned long nValue ) | ||
| 122 | { | ||
| 123 | char buf[12]; | ||
| 124 | sprintf( buf, "%li", nValue ); | ||
| 125 | addProperty( sName, buf ); | ||
| 126 | } | ||
| 127 | |||
| 128 | void XmlDocument::addProperty( const char *sName, const long nValue ) | ||
| 129 | { | ||
| 130 | char buf[12]; | ||
| 131 | sprintf( buf, "%li", nValue ); | ||
| 132 | addProperty( sName, buf ); | ||
| 133 | } | ||
| 134 | |||
| 135 | void XmlDocument::addProperty( const char *sName, const double dValue ) | ||
| 136 | { | ||
| 137 | char buf[40]; | ||
| 138 | sprintf( buf, "%f", dValue ); | ||
| 139 | addProperty( sName, buf ); | ||
| 140 | } | ||
| 141 | |||
| 142 | void XmlDocument::setContent( const char *sContent ) | ||
| 143 | { | ||
| 144 | if( pCurrent ) | ||
| 145 | { | ||
| 146 | pCurrent->setContent( sContent ); | ||
| 147 | } | ||
| 148 | } | ||
| 149 | |||
