OW_MOFCompiler.hpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 2001-2004 Vintela, Inc. All rights reserved.
00003 *
00004 * Redistribution and use in source and binary forms, with or without
00005 * modification, are permitted provided that the following conditions are met:
00006 *
00007 *  - Redistributions of source code must retain the above copyright notice,
00008 *    this list of conditions and the following disclaimer.
00009 *
00010 *  - Redistributions in binary form must reproduce the above copyright notice,
00011 *    this list of conditions and the following disclaimer in the documentation
00012 *    and/or other materials provided with the distribution.
00013 *
00014 *  - Neither the name of Vintela, Inc. nor the names of its
00015 *    contributors may be used to endorse or promote products derived from this
00016 *    software without specific prior written permission.
00017 *
00018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00019 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 * ARE DISCLAIMED. IN NO EVENT SHALL Vintela, Inc. OR THE CONTRIBUTORS
00022 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00023 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00024 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00025 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00026 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00027 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00028 * POSSIBILITY OF SUCH DAMAGE.
00029 *******************************************************************************/
00030 
00035 #ifndef OW_MOF_COMPILER_HPP_INCLUDE_GUARD_
00036 #define OW_MOF_COMPILER_HPP_INCLUDE_GUARD_
00037 #include "OW_config.h"
00038 #include "OW_CIMOMHandleIFC.hpp"
00039 #include "OW_String.hpp"
00040 #include "OW_MOFParserErrorHandlerIFC.hpp"
00041 #include "OW_Exception.hpp"
00042 #include "OW_Array.hpp"
00043 #include "OW_MOFLineInfo.hpp"
00044 #include "OW_MOFGrammar.hpp"
00045 #include "OW_CIMFwd.hpp"
00046 #include "OW_Logger.hpp"
00047 
00048 #ifdef OW_WIN32
00049 #pragma warning (push)
00050 #pragma warning (disable: 4251)
00051 #endif
00052 
00053 // these 2 need to be at global scope because flex also declares them.
00054 struct owmof_buffer_state;
00055 typedef struct yy_buffer_state *YY_BUFFER_STATE;
00056 
00057 namespace OW_NAMESPACE
00058 {
00059 
00060 OW_DECLARE_APIEXCEPTION(MOFCompiler, OW_MOF_API);
00061 
00062 namespace MOF
00063 {
00064 
00065 class OW_MOF_API Compiler
00066 {
00067 public:
00068    struct Options
00069    {
00070       Options()
00071          : m_createNamespaces(false)
00072          , m_checkSyntaxOnly(false)
00073          , m_remove(false)
00074          , m_preserve(false)
00075          , m_upgrade(true)
00076          , m_ignoreDoubleIncludes(false)
00077          , m_removeDescriptions(false)
00078          , m_removeObjects(false)
00079       {}
00080       Options(const String& namespace_,
00081          bool createNamespaces, bool checkSyntaxOnly, const String& dumpXmlFile,
00082          bool remove, bool preserve, bool upgrade, const StringArray& includeDirs,
00083          bool ignoreDoubleIncludes, bool removeDescriptions, bool removeObjects, 
00084          const String& depSearchDir = "")
00085          : m_namespace(namespace_)
00086          , m_createNamespaces(createNamespaces)
00087          , m_checkSyntaxOnly(checkSyntaxOnly)
00088          , m_dumpXmlFile(dumpXmlFile)
00089          , m_remove(remove)
00090          , m_preserve(preserve)
00091          , m_upgrade(upgrade)
00092          , m_includeDirs(includeDirs)
00093          , m_ignoreDoubleIncludes(ignoreDoubleIncludes)
00094          , m_removeDescriptions(removeDescriptions)
00095          , m_removeObjects(removeObjects)
00096          , m_depSearchDir(depSearchDir)
00097       {
00098       }
00099 
00100       String m_namespace;
00101       bool m_createNamespaces;
00102       bool m_checkSyntaxOnly;
00103       String m_dumpXmlFile;
00104       bool m_remove;
00105       bool m_preserve;
00106       bool m_upgrade;
00107       StringArray m_includeDirs;
00108       bool m_ignoreDoubleIncludes;
00109       bool m_removeDescriptions;
00110       bool m_removeObjects;
00111       String m_depSearchDir; 
00112    };
00113 
00114    Compiler( const CIMOMHandleIFCRef& ch, const Options& opts, const ParserErrorHandlerIFCRef& mpeh );
00115    ~Compiler();
00116    long compile( const String& filename );
00117    long compileString( const String& mof );
00118    static String fixParsedString(const String& s);
00119 
00120    ParserErrorHandlerIFCRef theErrorHandler;
00121    AutoPtr<MOFSpecification> mofSpecification;
00122    String basepath;
00123 
00124    // This variable is only for convenience for the lexer and parser.
00125    // After parsing is complete, it should not be used.  The filename and
00126    // line numbers are stored in the AST.
00127    LineInfo theLineInfo;
00128 
00129    // Needed by the code to implement includes
00130    enum
00131    {
00132       E_MAX_INCLUDE_DEPTH = 100
00133    };
00134 
00135    struct include_t
00136    {
00137       YY_BUFFER_STATE owmofBufferState;
00138       LineInfo theLineInfo;
00139    };
00140 
00141    include_t include_stack[E_MAX_INCLUDE_DEPTH];
00142    int include_stack_ptr;
00143 
00144 private:
00145    CIMOMHandleIFCRef m_ch;
00146    Options m_opts;
00147    // unimplemented
00148    Compiler(const Compiler& x);
00149    Compiler& operator=(const Compiler& x);
00150 
00151 };
00152 
00153 
00154 OW_MOF_API CIMInstance compileInstanceFromMOF(const String& instMOF, const LoggerRef& logger = LoggerRef()) OW_DEPRECATED; // in 3.2.0
00155 OW_MOF_API CIMInstanceArray compileInstancesFromMOF(const String& instMOF, const LoggerRef& logger = LoggerRef()) OW_DEPRECATED; // in 3.2.0
00156 OW_MOF_API CIMInstanceArray compileInstancesFromMOF(const String& instMOF, const CIMOMHandleIFCRef& realhdl, const String& ns, const LoggerRef& logger = LoggerRef()) OW_DEPRECATED; // in 3.2.0
00157 
00161 OW_MOF_API void compileMOF(const String& mof, const CIMOMHandleIFCRef& realhdl, const String& ns,
00162    CIMInstanceArray& instances, CIMClassArray& classes, CIMQualifierTypeArray& qualifierTypes, const LoggerRef& logger = LoggerRef());
00163 
00164 
00165 
00166 } // end namespace MOF
00167 } // end namespace OW_NAMESPACE
00168 
00169 #ifdef OW_WIN32
00170 #pragma warning (pop)
00171 #endif
00172 
00173 #endif // MOF_COMPILER_HPP_

Generated on Thu Feb 9 08:48:07 2006 for openwbem by  doxygen 1.4.6