SmbiosXmlImpl_xerces.h

Go to the documentation of this file.
00001 // vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=c:cindent:
00002 /*
00003  * Copyright (C) 2005 Dell Inc.
00004  *  by Michael Brown <Michael_E_Brown@dell.com>
00005  * Licensed under the Open Software License version 2.1
00006  *
00007  * Alternatively, you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published
00009  * by the Free Software Foundation; either version 2 of the License,
00010  * or (at your option) any later version.
00011 
00012  * This program is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00015  * See the GNU General Public License for more details.
00016  */
00017 
00018 
00019 #ifndef SMBIOSXMLIMPL_XERCES_h
00020 #define SMBIOSXMLIMPL_XERCES_h
00021 
00022 // compat header should always be first header
00023 #include "smbios/compat.h"
00024 
00025 #include <xercesc/parsers/XercesDOMParser.hpp>
00026 #include <xercesc/dom/DOMImplementation.hpp>
00027 #include <xercesc/dom/DOMImplementationLS.hpp>
00028 
00029 #include "smbios/ISmbiosXml.h"
00030 #include "../smbios/SmbiosImpl.h"
00031 
00032 namespace smbios
00033 {
00034     class SmbiosItemXml : public SmbiosItem
00035     {
00036     public:
00037         SmbiosItemXml (const SmbiosItem & source)
00038                 : SmbiosItem(source), doc(0)
00039         {}
00040         ;
00041         explicit SmbiosItemXml (const smbiosLowlevel::smbios_structure_header *header = 0)
00042                 : SmbiosItem(header), doc(0)
00043         {}
00044         ;
00045         virtual std::ostream & streamify( std::ostream & cout ) const;
00046 
00047         void setXmlFilePath( const std::string newFile, XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *newDoc );
00048 
00049         // TODO: listFields
00050         using  SmbiosItem::getU8;
00051         using  SmbiosItem::getU16;
00052         using  SmbiosItem::getU32;
00053         using  SmbiosItem::getU64;
00054         using  SmbiosItem::getString;
00055         using  SmbiosItem::getBitfield;
00056         virtual u8 getU8( const std::string field ) const;
00057         virtual u16 getU16( const std::string field ) const;
00058         virtual u32 getU32( const std::string field ) const;
00059         virtual u64 getU64( const std::string field ) const;
00060         virtual u32 getBitfield( const std::string field, const std::string bitField) const;
00061         virtual const char* getString( const std::string field ) const;
00062 
00063     protected:
00064         std::string getTypeAsString() const;
00065         std::string xmlFile;
00066         XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc;
00067     };
00068 
00069     class SmbiosTableXml : public virtual SmbiosTable
00070     {
00071     public:
00072         // ITERATORS!
00073         using  SmbiosTable::operator[];
00074         virtual iterator operator[]( const std::string & );
00075         virtual const_iterator operator[]( const std::string & ) const;
00076 
00077         virtual std::ostream & streamify(std::ostream & cout ) const;
00078 
00079         // CONSTRUCTORS/DESTRUCTORS
00080         virtual ~SmbiosTableXml();
00081         explicit SmbiosTableXml(std::vector<SmbiosStrategy *> initStrategyList, bool strictValidation = 0);
00082 
00083         void setXmlFilePath( std::string );
00084         int getTypeForString( const std::string )const;
00085         const std::string getStringForType( const int )const;
00086 
00087         const XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *getXmlDoc() const;
00088 
00089     protected:
00090         // Private, should never construct empty object.
00091         SmbiosTableXml ();
00092 
00093         virtual ISmbiosItem &makeItem( const void *header = 0) const;
00094 
00095     protected:
00096         std::string xmlFile;
00097 
00098         // parser owns all XML entities. When it is deleted, everything
00099         // goes with it.
00100         XERCES_CPP_NAMESPACE_QUALIFIER DOMBuilder *parser;
00101 
00102         // The doc is owned by the parser. We do not have to clean it up
00103         // it is deleted when the parser is released. We keep a ref
00104         // here for speed purposes
00105         XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc;
00106 
00107         // indicates if XML subsystem has been initialized and should be
00108         // terminated.
00109         bool xmlInitialized;
00110 
00111     private:
00112         SmbiosTableXml (const SmbiosTableXml & source);
00113         SmbiosTableXml & operator = (const SmbiosTableXml & source);
00114     };
00115 }
00116 
00117 #endif /* SMBIOSXMLIMPL_XERCES_h */
00118 

Generated on Tue Jan 17 02:59:08 2006 for SMBIOS Library by  doxygen 1.4.6