Kevin Rocard | 93250d1 | 2012-07-19 17:48:30 +0200 | [diff] [blame] | 1 | /* |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2 | * 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 Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 22 | * CREATED: 2011-06-01 |
| 23 | * UPDATED: 2011-07-27 |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 24 | */ |
| 25 | #pragma once |
| 26 | |
| 27 | #include <stdint.h> |
| 28 | #include <string> |
| 29 | |
| 30 | using namespace std; |
| 31 | |
| 32 | struct _xmlNode; |
| 33 | struct _xmlDoc; |
| 34 | |
| 35 | class CXmlElement |
| 36 | { |
| 37 | friend class CChildIterator; |
| 38 | public: |
| 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 Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 61 | uint32_t getNbChildElements() const; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 62 | bool getParentElement(CXmlElement& parentElement) const; |
| 63 | |
| 64 | // Setters |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 65 | void setAttributeBoolean(const string& strAttributeName, bool bValue); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 66 | 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 Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame^] | 70 | void setAttributeInteger(const string& strAttributeName, uint32_t uiValue); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 71 | |
| 72 | // Child creation |
| 73 | void createChild(CXmlElement& childElement, const string& strType); |
| 74 | |
| 75 | public: |
| 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 | |
| 87 | private: |
| 88 | _xmlNode* _pXmlElement; |
| 89 | }; |
| 90 | |