blob: a1bf42c24a613364e5b468103d17670d878da9e7 [file] [log] [blame]
Kevin Rocard93250d12012-07-19 17:48:30 +02001/*
Patrick Benavoli68a91282011-08-31 11:23:23 +02002 * INTEL CONFIDENTIAL
3 * Copyright © 2011 Intel
4 * Corporation All Rights Reserved.
5 *
6 * The source code contained or described herein and all documents related to
7 * the source code ("Material") are owned by Intel Corporation or its suppliers
8 * or licensors. Title to the Material remains with Intel Corporation or its
9 * suppliers and licensors. The Material contains trade secrets and proprietary
10 * and confidential information of Intel or its suppliers and licensors. The
11 * Material is protected by worldwide copyright and trade secret laws and
12 * treaty provisions. No part of the Material may be used, copied, reproduced,
13 * modified, published, uploaded, posted, transmitted, distributed, or
14 * disclosed in any way without Intel’s prior express written permission.
15 *
16 * No license under any patent, copyright, trade secret or other intellectual
17 * property right is granted to or conferred upon you by disclosure or delivery
18 * of the Materials, either expressly, by implication, inducement, estoppel or
19 * otherwise. Any license under such intellectual property rights must be
20 * express and approved by Intel in writing.
21 *
Patrick Benavoli68a91282011-08-31 11:23:23 +020022 * CREATED: 2011-06-01
23 * UPDATED: 2011-07-27
Patrick Benavoli68a91282011-08-31 11:23:23 +020024 */
25#pragma once
26
27#include <stdint.h>
28#include <string>
29
30using namespace std;
31
32struct _xmlNode;
33struct _xmlDoc;
34
35class CXmlElement
36{
37 friend class CChildIterator;
38public:
39 CXmlElement(_xmlNode* pXmlElement);
40 CXmlElement();
41
42 // Xml element
43 void setXmlElement(_xmlNode* pXmlElement);
44
45 // Getters
46 string getType() const;
47 string getPath() const;
48 string getNameAttribute() const;
49 bool hasAttribute(const string& strAttributeName) const;
50 bool getAttributeBoolean(const string& strAttributeName, const string& strTrueValue) const;
51 bool getAttributeBoolean(const string& strAttributeName) const;
52 string getAttributeString(const string& strAttributeName) const;
53 uint32_t getAttributeInteger(const string& strAttributeName) const;
54 int32_t getAttributeSignedInteger(const string& strAttributeName) const;
55 double getAttributeDouble(const string& strAttributeName) const;
56 string getTextContent() const;
57
58 // Navigation
59 bool getChildElement(const string& strType, CXmlElement& childElement) const;
60 bool getChildElement(const string& strType, const string& strNameAttribute, CXmlElement& childElement) const;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +020061 uint32_t getNbChildElements() const;
Patrick Benavoli68a91282011-08-31 11:23:23 +020062 bool getParentElement(CXmlElement& parentElement) const;
63
64 // Setters
Patrick Benavoli63499d42011-10-24 18:50:03 +020065 void setAttributeBoolean(const string& strAttributeName, bool bValue);
Patrick Benavoli68a91282011-08-31 11:23:23 +020066 void setAttributeString(const string& strAttributeName, const string& strValue);
67 void setNameAttribute(const string& strValue);
68 void setTextContent(const string& strContent);
69 void setComment(const string& strComment);
Georges-Henri Baron326a31d2012-06-28 12:05:09 +020070 void setAttributeInteger(const string& strAttributeName, uint32_t uiValue);
Patrick Benavoli68a91282011-08-31 11:23:23 +020071
72 // Child creation
73 void createChild(CXmlElement& childElement, const string& strType);
74
75public:
76 // Child iteration
77 class CChildIterator
78 {
79 public:
80 CChildIterator(const CXmlElement& xmlElement);
81
82 bool next(CXmlElement& xmlChildElement);
83 private:
84 _xmlNode* _pCurNode;
85 };
86
87private:
88 _xmlNode* _pXmlElement;
89};
90