summaryrefslogtreecommitdiff
path: root/modules/xml/src/cpp/XMLNs.hxx
blob: ea0cb0a42f7c96945e07f8f1ddfdd9b9496534c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
 *
 * This file must be used under the terms of the CeCILL.
 * This source file is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at
 * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
 *
 */

#ifndef __XMLNS_HXX__
#define __XMLNS_HXX__

#include <string>

#include "xml.h"

#include "dynlib_xml_scilab.h"

namespace org_modules_xml
{

class XMLElement;
class XMLObject;

/**
 * @file
 * @author Calixte DENIZET <calixte.denizet@scilab.org>
 *
 * Class to wrap a namespace xmlNs.
 * @see http://xmlsoft.org/html/libxml-tree.html#xmlNs
 */
class XML_SCILAB_IMPEXP XMLNs: public XMLObject
{
    const XMLObject & parent;
    xmlNs *ns;

public:

    /**
     * @param parent the parent XML object
     * @param ns the xml namespace
     */
    XMLNs(const XMLObject & parent, xmlNs * ns);

    /**
     * @param elem the parent XMLElement
     * @param prefix the namespace prefix
     * @param href the namespace href
     */
    XMLNs(const XMLElement & elem, char *prefix, char *href);

    ~XMLNs();

    void *getRealXMLPointer() const;

    /**
     * @return the namespace href
     */
    const char *getHref() const
    {
        return ns == 0 ? "" : (const char *)ns->href;
    }

    /**
     * @return the namespace prefix
     */
    const char *getPrefix() const
    {
        return ns == 0 ? "" : (const char *)ns->prefix;
    }

    /**
     * @return the xmlNs behind this object
     */
    xmlNs *getRealNs() const
    {
        return ns;
    }

    const XMLObject *getXMLObjectParent() const;
    const std::string toString() const;
};
}

#endif