~ubuntu-branches/debian/sid/3depict/sid

« back to all changes in this revision

Viewing changes to src/XMLHelper.cpp

  • Committer: Bazaar Package Importer
  • Author(s): D Haley
  • Date: 2010-08-09 21:23:50 UTC
  • Revision ID: james.westby@ubuntu.com-20100809212350-cg6yumndhwi3bqws
Tags: upstream-0.0.1
ImportĀ upstreamĀ versionĀ 0.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* XmlHelper.cpp : libXML2 wrapper code
 
2
 * Copyright (C) 2010  D Haley
 
3
 * 
 
4
 * This program is free software: you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation, either version 3 of the License, or
 
7
 * (at your option) any later version.
 
8
 * 
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 * 
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
 */
 
17
#include "XMLHelper.h"
 
18
 
 
19
unsigned int XMLHelpNextType(xmlNodePtr &node, int nodeType)
 
20
{
 
21
        do
 
22
        {
 
23
                node= node->next;
 
24
                if(!node)
 
25
                        return 1;
 
26
        }
 
27
        while(node->type != nodeType);
 
28
        return 0;
 
29
}
 
30
 
 
31
//returns zero on success, nonzero on fail
 
32
unsigned int XMLHelpFwdToElem(xmlNodePtr &node, const char *nodeName)
 
33
{
 
34
        do
 
35
        {       
 
36
                node=node->next;
 
37
        }while(node != NULL &&  
 
38
                xmlStrcmp(node->name,(const xmlChar *) nodeName));
 
39
        return (!node);
 
40
}
 
41
 
 
42
unsigned int XMLHelpFwdNotElem(xmlNodePtr &node,const char *nodeName)
 
43
{
 
44
        do
 
45
        {
 
46
                node=node->next;
 
47
        }while(node !=NULL && node->type != XML_ELEMENT_NODE && 
 
48
                !xmlStrcmp(node->name,(const xmlChar *)nodeName));
 
49
        
 
50
        return !node;
 
51
}
 
52
 
 
53
string XMLHelpGetText(xmlNodePtr node)
 
54
{
 
55
        string result;
 
56
        XMLHelpNextType(node,XML_TEXT_NODE);
 
57
        result =(char *) node->content;
 
58
        return result;
 
59
}
 
60
 
 
61