Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 1 | /* |
| 2 | * INTEL CONFIDENTIAL |
Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 3 | * Copyright © 2013 Intel |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 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. |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 21 | */ |
| 22 | |
| 23 | #pragma once |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 24 | #include "XmlDocSource.h" |
Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 25 | #include <string> |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 26 | |
Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 27 | /** |
| 28 | * Source class that read a file to get an xml document. |
| 29 | * Its base class will validate the document. |
| 30 | */ |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 31 | class CXmlFileDocSource : public CXmlDocSource |
| 32 | { |
| 33 | public: |
Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 34 | /** |
| 35 | * Constructor |
| 36 | * |
| 37 | * @param[in] strXmlInstanceFile a string containing the path to the xml file |
| 38 | * @param[in] strXmlSchemaFile a string containing the path to the schema file |
| 39 | * @param[in] strRootElementType a string containing the root element type |
| 40 | * @param[in] strRootElementName a string containing the root element name |
| 41 | * @param[in] strNameAttributeName a string containing the name of the root name attribute |
| 42 | */ |
| 43 | CXmlFileDocSource(const string& strXmlInstanceFile, |
| 44 | const string& strXmlSchemaFile, |
| 45 | const string& strRootElementType, |
| 46 | const string& strRootElementName, |
| 47 | const string& strNameAttrituteName); |
| 48 | /** |
| 49 | * Constructor |
| 50 | * |
| 51 | * @param[in] strXmlInstanceFile a string containing the path to the xml file |
| 52 | * @param[in] strXmlSchemaFile a string containing the path to the schema file |
| 53 | * @param[in] strRootElementType a string containing the root element type |
| 54 | */ |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 55 | CXmlFileDocSource(const string& strXmlInstanceFile, const string& strXmlSchemaFile, const string& strRootElementType); |
| 56 | |
Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 57 | /** |
| 58 | * CXmlDocSource method implementation. |
| 59 | * |
| 60 | * @param[out] serializingContext is used as error output |
| 61 | * |
| 62 | * @return false if any error occurs |
| 63 | */ |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 64 | virtual bool populate(CXmlSerializingContext& serializingContext); |
| 65 | |
Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 66 | /** |
| 67 | * Method that checks that the file exists and is readable. |
| 68 | * |
| 69 | * @param[out] serializingContext is used as error output |
| 70 | * |
| 71 | * @return false if any error occurs during the parsing |
| 72 | */ |
Frédéric Boisnard | a409daa | 2012-10-18 18:20:03 +0200 | [diff] [blame] | 73 | virtual bool isParsable(CXmlSerializingContext& serializingContext) const; |
| 74 | |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 75 | private: |
Guillaume Denneulin | 3ba083e | 2014-01-31 15:09:42 +0100 | [diff] [blame^] | 76 | /** |
| 77 | * Read xml file |
| 78 | * |
| 79 | * This function reads an xml file and processes eventual included files |
| 80 | * WARNING: to compile this function, libxml2 has to be compiled with LIBXML_XINCLUDE_ENABLED |
| 81 | * |
| 82 | * @param[in] strFileName the file name |
| 83 | * |
| 84 | * @return a pointer to generated xml document object |
| 85 | */ |
| 86 | static _xmlDoc* readFile(const string& strFileName); |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 87 | |
Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 88 | /** |
| 89 | * Instance file |
| 90 | */ |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 91 | string _strXmlInstanceFile; |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 92 | }; |