<commit_before>/*!
 * \page StandardAirlineITTestSuite_cpp Command-Line Test to Demonstrate How To Extend StdAir BOM
 * \code
 */
// //////////////////////////////////////////////////////////////////////
// Import section
// //////////////////////////////////////////////////////////////////////
// STL
#include <string>
#include <fstream>
// Boost MPL
#include <boost/mpl/push_back.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_same.hpp>
// Boost Unit Test Framework (UTF)
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MAIN
#define BOOST_TEST_MODULE StdAirTest
#include <boost/test/unit_test.hpp>
// StdAir
#include <stdair/stdair_inventory_types.hpp>
#include <stdair/service/Logger.hpp>
#include <stdair/STDAIR_Service.hpp>
#include <stdair/bom/BomRoot.hpp>
#include <stdair/bom/BomManager.hpp>
#include <stdair/factory/FacBom.hpp>
#include <stdair/factory/FacBomManager.hpp>
// StdAir Test Suite
#include <test/stdair/StdairTestLib.hpp>
#include <test/stdair/MPInventory.hpp>

namespace boost_utf = boost::unit_test;

/**
 * Configuration for the Boost Unit Test Framework (UTF)
 */
struct UnitTestConfig {
  /** Constructor. */
  UnitTestConfig() : _test_log ("StandardAirlineITTestSuite_utfresults.xml")  {
    boost_utf::unit_test_log.set_stream (_test_log);
    boost_utf::unit_test_log.set_format (boost_utf::XML);
    boost_utf::unit_test_log.set_threshold_level (boost_utf::log_test_units);
    //boost_utf::unit_test_log.set_threshold_level (boost_utf::log_successful_tests);
  }

  /** Destructor. */
  ~UnitTestConfig() {
    boost_utf::unit_test_log.set_stream (std::cout);
  }
  /** Log file */
  std::ofstream _test_log;
};

// /////////////// Main: Unit Test Suite //////////////

// Set the UTF configuration (re-direct the output to a specific file)
BOOST_GLOBAL_FIXTURE (UnitTestConfig);

// Start the test suite
BOOST_AUTO_TEST_SUITE (master_test_suite)

/**
 * Test MPL-based type handling, just as a proof-of-concept. It does
 * not use StdAir BOM.
 */
BOOST_AUTO_TEST_CASE (mpl_structure_test) {
  const stdair::ClassCode_T lBookingClassCodeA ("A");
  const stdair_test::BookingClass lA (lBookingClassCodeA);
  const stdair_test::Cabin lCabin (lA);

  BOOST_CHECK_EQUAL (lCabin.toString(), lBookingClassCodeA);
  BOOST_CHECK_MESSAGE (lCabin.toString() == lBookingClassCodeA,
                       "The cabin key, '" << lCabin.toString()
                       << "' is not equal to '" << lBookingClassCodeA << "'");

  // MPL
  typedef boost::mpl::vector<stdair_test::BookingClass> MPL_BookingClass;
  typedef boost::mpl::push_back<MPL_BookingClass,
                                stdair_test::Cabin>::type types;

  if (boost::is_same<stdair_test::BookingClass,
                     stdair_test::Cabin::child>::value == false) {
    BOOST_REQUIRE ("The two types mut be equal, but are not");
  }

  if (boost::is_same<boost::mpl::at_c<types, 1>::type,
                     stdair_test::Cabin>::value == false) {
    BOOST_REQUIRE ("The type must be stdair_test::Cabin, but is not");
  }
}

/**
 * Test the initialisation of the Standard Airline IT base library.
 */
BOOST_AUTO_TEST_CASE (stdair_service_initialisation_test) {
  // Output log File
  const std::string lLogFilename ("testServiceInitialisation.log");

  // Set the log parameters
  std::ofstream logOutputFile;

  // Open and clean the log outputfile
  logOutputFile.open (lLogFilename.c_str());
  logOutputFile.clear();

  // Initialise the stdair BOM
  const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile);
  stdair::STDAIR_Service stdairService (lLogParams);

  // Get the BOM Root
  const stdair::BomRoot& lBomRoot = stdairService.getBomRoot();
  const std::string& lBomRootKeyStr = lBomRoot.describeKey();

  const std::string lBomRootString (" -- ROOT -- ");
  BOOST_CHECK_EQUAL (lBomRootKeyStr, lBomRootString);
  BOOST_CHECK_MESSAGE (lBomRootKeyStr == lBomRootString,
                       "The BOM root key, '" << lBomRootKeyStr
                       << "', should be equal to '" << lBomRootString
                       << "', but is not.");

  // Close the Log outputFile
  logOutputFile.close();
}

/**
 * Test the initialisation of Standard Airline IT BOM objects.
 */
BOOST_AUTO_TEST_CASE (bom_structure_instantiation_test) {
  // Step 0.0: initialisation
  // Create the root of the Bom tree (i.e., a BomRoot object)
  stdair::BomRoot& lBomRoot =
    stdair::FacBom<stdair::BomRoot>::instance().create();

  // Step 0.1: Inventory level
  // Create an Inventory (BA)
  const stdair::AirlineCode_T lBAAirlineCode ("BA");
  const stdair::InventoryKey lBAKey (lBAAirlineCode);
  myprovider::Inventory& lBAInv =
    stdair::FacBom<myprovider::Inventory>::instance().create (lBAKey);
  stdair::FacBomManager::instance().addToList (lBomRoot, lBAInv);

  BOOST_CHECK_EQUAL (lBAInv.describeKey(), lBAAirlineCode);
  BOOST_CHECK_MESSAGE (lBAInv.describeKey() == lBAAirlineCode,
                       "The inventory key, '" << lBAInv.describeKey()
                       << "', should be equal to '" << lBAAirlineCode
                       << "', but is not");

  // Create an Inventory for AF
  const stdair::AirlineCode_T lAFAirlineCode ("AF");
  const stdair::InventoryKey lAFKey (lAFAirlineCode);
  myprovider::Inventory& lAFInv =
    stdair::FacBom<myprovider::Inventory>::instance().create (lAFKey);
  stdair::FacBomManager::instance().addToList (lBomRoot, lAFInv);

  BOOST_CHECK_EQUAL (lAFInv.describeKey(), lAFAirlineCode);
  BOOST_CHECK_MESSAGE (lAFInv.describeKey() == lAFAirlineCode,
                       "The inventory key, '" << lAFInv.describeKey()
                       << "', should be equal to '" << lAFAirlineCode
                       << "', but is not");

  // Browse the inventories
  const myprovider::InventoryList_T& lInventoryList =
      stdair::BomManager::getList<myprovider::Inventory> (lBomRoot);
  const std::string lInventoryKeyArray[2] = {lBAAirlineCode, lAFAirlineCode};
  short idx = 0;
  for (myprovider::InventoryList_T::const_iterator itInv =
         lInventoryList.begin(); itInv != lInventoryList.end();
       ++itInv, ++idx) {
    const myprovider::Inventory* lInv_ptr = *itInv;
    BOOST_REQUIRE (lInv_ptr != NULL);

    BOOST_CHECK_EQUAL (lInventoryKeyArray[idx], lInv_ptr->describeKey());
    BOOST_CHECK_MESSAGE (lInventoryKeyArray[idx] == lInv_ptr->describeKey(),
                         "They inventory key, '" << lInventoryKeyArray[idx]
                         << "', does not match that of the Inventory object: '"
                         << lInv_ptr->describeKey() << "'");
  }
}

// End the test suite
BOOST_AUTO_TEST_SUITE_END()

/*!
 * \endcode
 */
<commit_msg>[Test] The </TestLog> end tag is now appended to the XML result of the Boost.UTF tests.<commit_after>/*!
 * \page StandardAirlineITTestSuite_cpp Command-Line Test to Demonstrate How To Extend StdAir BOM
 * \code
 */
// //////////////////////////////////////////////////////////////////////
// Import section
// //////////////////////////////////////////////////////////////////////
// STL
#include <string>
#include <fstream>
// Boost MPL
#include <boost/mpl/push_back.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_same.hpp>
// Boost Unit Test Framework (UTF)
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MAIN
#define BOOST_TEST_MODULE StdAirTest
#include <boost/test/unit_test.hpp>
// StdAir
#include <stdair/stdair_inventory_types.hpp>
#include <stdair/service/Logger.hpp>
#include <stdair/STDAIR_Service.hpp>
#include <stdair/bom/BomRoot.hpp>
#include <stdair/bom/BomManager.hpp>
#include <stdair/factory/FacBom.hpp>
#include <stdair/factory/FacBomManager.hpp>
// StdAir Test Suite
#include <test/stdair/StdairTestLib.hpp>
#include <test/stdair/MPInventory.hpp>

namespace boost_utf = boost::unit_test;

/**
 * Configuration for the Boost Unit Test Framework (UTF)
 */
struct UnitTestConfig {
  /** Constructor. */
  UnitTestConfig() {
	static std::ofstream _test_log ("StandardAirlineITTestSuite_utfresults.xml");
    boost_utf::unit_test_log.set_stream (_test_log);
    boost_utf::unit_test_log.set_format (boost_utf::XML);
    boost_utf::unit_test_log.set_threshold_level (boost_utf::log_test_units);
    //boost_utf::unit_test_log.set_threshold_level (boost_utf::log_successful_tests);
  }

  /** Destructor. */
  ~UnitTestConfig() {
  }
};

// /////////////// Main: Unit Test Suite //////////////

// Set the UTF configuration (re-direct the output to a specific file)
BOOST_GLOBAL_FIXTURE (UnitTestConfig);

// Start the test suite
BOOST_AUTO_TEST_SUITE (master_test_suite)

/**
 * Test MPL-based type handling, just as a proof-of-concept. It does
 * not use StdAir BOM.
 */
BOOST_AUTO_TEST_CASE (mpl_structure_test) {
  const stdair::ClassCode_T lBookingClassCodeA ("A");
  const stdair_test::BookingClass lA (lBookingClassCodeA);
  const stdair_test::Cabin lCabin (lA);

  BOOST_CHECK_EQUAL (lCabin.toString(), lBookingClassCodeA);
  BOOST_CHECK_MESSAGE (lCabin.toString() == lBookingClassCodeA,
                       "The cabin key, '" << lCabin.toString()
                       << "' is not equal to '" << lBookingClassCodeA << "'");

  // MPL
  typedef boost::mpl::vector<stdair_test::BookingClass> MPL_BookingClass;
  typedef boost::mpl::push_back<MPL_BookingClass,
                                stdair_test::Cabin>::type types;

  if (boost::is_same<stdair_test::BookingClass,
                     stdair_test::Cabin::child>::value == false) {
    BOOST_REQUIRE ("The two types mut be equal, but are not");
  }

  if (boost::is_same<boost::mpl::at_c<types, 1>::type,
                     stdair_test::Cabin>::value == false) {
    BOOST_REQUIRE ("The type must be stdair_test::Cabin, but is not");
  }
}

/**
 * Test the initialisation of the Standard Airline IT base library.
 */
BOOST_AUTO_TEST_CASE (stdair_service_initialisation_test) {
  // Output log File
  const std::string lLogFilename ("testServiceInitialisation.log");

  // Set the log parameters
  std::ofstream logOutputFile;

  // Open and clean the log outputfile
  logOutputFile.open (lLogFilename.c_str());
  logOutputFile.clear();

  // Initialise the stdair BOM
  const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile);
  stdair::STDAIR_Service stdairService (lLogParams);

  // Get the BOM Root
  const stdair::BomRoot& lBomRoot = stdairService.getBomRoot();
  const std::string& lBomRootKeyStr = lBomRoot.describeKey();

  const std::string lBomRootString (" -- ROOT -- ");
  BOOST_CHECK_EQUAL (lBomRootKeyStr, lBomRootString);
  BOOST_CHECK_MESSAGE (lBomRootKeyStr == lBomRootString,
                       "The BOM root key, '" << lBomRootKeyStr
                       << "', should be equal to '" << lBomRootString
                       << "', but is not.");

  // Close the Log outputFile
  logOutputFile.close();
}

/**
 * Test the initialisation of Standard Airline IT BOM objects.
 */
BOOST_AUTO_TEST_CASE (bom_structure_instantiation_test) {
  // Step 0.0: initialisation
  // Create the root of the Bom tree (i.e., a BomRoot object)
  stdair::BomRoot& lBomRoot =
    stdair::FacBom<stdair::BomRoot>::instance().create();

  // Step 0.1: Inventory level
  // Create an Inventory (BA)
  const stdair::AirlineCode_T lBAAirlineCode ("BA");
  const stdair::InventoryKey lBAKey (lBAAirlineCode);
  myprovider::Inventory& lBAInv =
    stdair::FacBom<myprovider::Inventory>::instance().create (lBAKey);
  stdair::FacBomManager::instance().addToList (lBomRoot, lBAInv);

  BOOST_CHECK_EQUAL (lBAInv.describeKey(), lBAAirlineCode);
  BOOST_CHECK_MESSAGE (lBAInv.describeKey() == lBAAirlineCode,
                       "The inventory key, '" << lBAInv.describeKey()
                       << "', should be equal to '" << lBAAirlineCode
                       << "', but is not");

  // Create an Inventory for AF
  const stdair::AirlineCode_T lAFAirlineCode ("AF");
  const stdair::InventoryKey lAFKey (lAFAirlineCode);
  myprovider::Inventory& lAFInv =
    stdair::FacBom<myprovider::Inventory>::instance().create (lAFKey);
  stdair::FacBomManager::instance().addToList (lBomRoot, lAFInv);

  BOOST_CHECK_EQUAL (lAFInv.describeKey(), lAFAirlineCode);
  BOOST_CHECK_MESSAGE (lAFInv.describeKey() == lAFAirlineCode,
                       "The inventory key, '" << lAFInv.describeKey()
                       << "', should be equal to '" << lAFAirlineCode
                       << "', but is not");

  // Browse the inventories
  const myprovider::InventoryList_T& lInventoryList =
      stdair::BomManager::getList<myprovider::Inventory> (lBomRoot);
  const std::string lInventoryKeyArray[2] = {lBAAirlineCode, lAFAirlineCode};
  short idx = 0;
  for (myprovider::InventoryList_T::const_iterator itInv =
         lInventoryList.begin(); itInv != lInventoryList.end();
       ++itInv, ++idx) {
    const myprovider::Inventory* lInv_ptr = *itInv;
    BOOST_REQUIRE (lInv_ptr != NULL);

    BOOST_CHECK_EQUAL (lInventoryKeyArray[idx], lInv_ptr->describeKey());
    BOOST_CHECK_MESSAGE (lInventoryKeyArray[idx] == lInv_ptr->describeKey(),
                         "They inventory key, '" << lInventoryKeyArray[idx]
                         << "', does not match that of the Inventory object: '"
                         << lInv_ptr->describeKey() << "'");
  }
}

// End the test suite
BOOST_AUTO_TEST_SUITE_END()

/*!
 * \endcode
 */
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: ContentHelper.hxx,v $
 *
 *  $Revision: 1.4 $
 *
 *  last change: $Author: vg $ $Date: 2005-03-10 16:36:09 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the License); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an AS IS basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/
#ifndef DBA_CONTENTHELPER_HXX
#define DBA_CONTENTHELPER_HXX

#ifndef _DBASHARED_APITOOLS_HXX_
#include "apitools.hxx"
#endif
#ifndef _COM_SUN_STAR_UCB_XCONTENT_HPP_
#include <com/sun/star/ucb/XContent.hpp>
#endif
#ifndef _COM_SUN_STAR_UCB_XCOMMANDPROCESSOR_HPP_
#include <com/sun/star/ucb/XCommandProcessor.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTIESCHANGENOTIFIER_HPP_
#include <com/sun/star/beans/XPropertiesChangeNotifier.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYCONTAINER_HPP_
#include <com/sun/star/beans/XPropertyContainer.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
#include <com/sun/star/lang/XServiceInfo.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
#include <com/sun/star/lang/XInitialization.hpp>
#endif
#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
#include <com/sun/star/container/XNameAccess.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
#include <com/sun/star/sdbc/XRow.hpp>
#endif
#ifndef _COM_SUN_STAR_EMBED_XSTORAGE_HPP_
#include <com/sun/star/embed/XStorage.hpp>
#endif
#ifndef _COM_SUN_STAR_EMBED_XEMBEDDEDOBJECT_HPP_
#include <com/sun/star/embed/XEmbeddedObject.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_
#include <com/sun/star/lang/XUnoTunnel.hpp>
#endif
#ifndef _CPPUHELPER_COMPBASE9_HXX_
#include <cppuhelper/compbase9.hxx>
#endif
#ifndef _COMPHELPER_BROADCASTHELPER_HXX_
#include <comphelper/broadcasthelper.hxx>
#endif
#ifndef _COMPHELPER_UNO3_HXX_
#include <comphelper/uno3.hxx>
#endif
#ifndef _COMPHELPER_STLTYPES_HXX_
#include <comphelper/stl_types.hxx>
#endif
#ifndef _COM_SUN_STAR_BEANS_PROPERTY_HPP_
#include <com/sun/star/beans/Property.hpp>
#endif
#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
#include <com/sun/star/container/XChild.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBCX_XRENAME_HPP_
#include <com/sun/star/sdbcx/XRename.hpp>
#endif
#ifndef BOOST_SHARED_PTR_HPP_INCLUDED
#include <boost/shared_ptr.hpp>
#endif

namespace dbaccess
{
    class ODatabaseModelImpl;
    struct ContentProperties
    {
        ::rtl::OUString aTitle;         // Title
        ::rtl::OUString aContentType;   // ContentType
        sal_Bool        bIsDocument;    // IsDocument
        sal_Bool        bIsFolder;      // IsFolder
        sal_Bool        bAsTemplate;    // AsTemplate
        ::rtl::OUString sPersistentName;// persitent name of the document

        // @@@ Add other properties supported by your content.

        ContentProperties()
        : bIsDocument( sal_True ), bIsFolder( sal_False ), bAsTemplate( sal_False ) {}
    };

    class OContentHelper_Impl
    {
    public:
        OContentHelper_Impl();
        virtual ~OContentHelper_Impl();

        ContentProperties   m_aProps;
        ODatabaseModelImpl* m_pDataSource; // this will stay alive as long as the content exists
    };

    typedef ::boost::shared_ptr<OContentHelper_Impl> TContentPtr;

    typedef ::cppu::OMultiTypeInterfaceContainerHelperVar<  ::rtl::OUString,
                                                            ::comphelper::UStringHash,
                                                            ::comphelper::UStringEqual
                                                        > PropertyChangeListenerContainer;
    typedef ::comphelper::OMutexAndBroadcastHelper  OContentHelper_MBASE;
    typedef ::cppu::WeakComponentImplHelper9    <   ::com::sun::star::ucb::XContent
                                                ,   ::com::sun::star::ucb::XCommandProcessor
                                                ,   ::com::sun::star::lang::XServiceInfo
                                                ,   ::com::sun::star::beans::XPropertiesChangeNotifier
                                                ,   ::com::sun::star::beans::XPropertyContainer
                                                ,   ::com::sun::star::lang::XInitialization
                                                ,   ::com::sun::star::lang::XUnoTunnel
                                                ,   ::com::sun::star::container::XChild
                                                ,   ::com::sun::star::sdbcx::XRename
                                                >   OContentHelper_COMPBASE;

    class OContentHelper :   public OContentHelper_MBASE
                            ,public OContentHelper_COMPBASE
    {
        ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
            setPropertyValues( const ::com::sun::star::uno::Sequence<
                                ::com::sun::star::beans::PropertyValue >& rValues,
                            const ::com::sun::star::uno::Reference<
                                ::com::sun::star::ucb::XCommandEnvironment >& xEnv );
        com::sun::star::uno::Sequence< com::sun::star::beans::Property >
            getProperties( const com::sun::star::uno::Reference<
                            com::sun::star::ucb::XCommandEnvironment > & xEnv );

    protected:
        ::cppu::OInterfaceContainerHelper   m_aContentListeners;
        PropertyChangeListenerContainer     m_aPropertyChangeListeners;
        ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >               m_xParentContainer;
        ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >    m_xORB;
        TContentPtr                     m_pImpl;
        sal_uInt32                      m_nCommandId;

        // helper
        virtual void SAL_CALL disposing();

        virtual void notifyDataSourceModified();

        /**
        * This method can be used to propagate changes of property values.
        *
        * @param evt is a sequence of property change events.
        */
        void notifyPropertiesChange( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyChangeEvent >& evt ) const;
    public:

        OContentHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB
                        ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >&   _xParentContainer
                        ,const TContentPtr& _pImpl
                    );

        // com::sun::star::lang::XTypeProvider
        DECLARE_IMPLEMENTATION_ID( );
        // ::com::sun::star::lang::XServiceInfo
        DECLARE_SERVICE_INFO();

        // XContent
        virtual ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentIdentifier > SAL_CALL getIdentifier(  ) throw (::com::sun::star::uno::RuntimeException) ;
        virtual ::rtl::OUString SAL_CALL getContentType(  ) throw (::com::sun::star::uno::RuntimeException) ;
        virtual void SAL_CALL addContentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentEventListener >& Listener ) throw (::com::sun::star::uno::RuntimeException) ;
        virtual void SAL_CALL removeContentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentEventListener >& Listener ) throw (::com::sun::star::uno::RuntimeException) ;

        // XCommandProcessor
        virtual sal_Int32 SAL_CALL createCommandIdentifier(  ) throw (::com::sun::star::uno::RuntimeException) ;
        virtual ::com::sun::star::uno::Any SAL_CALL execute( const ::com::sun::star::ucb::Command& aCommand, sal_Int32 CommandId, const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& Environment ) throw (::com::sun::star::uno::Exception, ::com::sun::star::ucb::CommandAbortedException, ::com::sun::star::uno::RuntimeException) ;
        virtual void SAL_CALL abort( sal_Int32 CommandId ) throw (::com::sun::star::uno::RuntimeException) ;

        // XPropertiesChangeNotifier
        virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener ) throw (::com::sun::star::uno::RuntimeException) ;
        virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener ) throw (::com::sun::star::uno::RuntimeException) ;

        // XPropertyContainer
        virtual void SAL_CALL addProperty( const ::rtl::OUString& Name, sal_Int16 Attributes, const ::com::sun::star::uno::Any& DefaultValue ) throw (::com::sun::star::beans::PropertyExistException, ::com::sun::star::beans::IllegalTypeException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) ;
        virtual void SAL_CALL removeProperty( const ::rtl::OUString& Name ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::NotRemoveableException, ::com::sun::star::uno::RuntimeException) ;

        // XInitialization
        virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);

        // com::sun::star::lang::XUnoTunnel
        virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);

        // ::com::sun::star::container::XChild
        virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent(  ) throw (::com::sun::star::uno::RuntimeException);
        virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);

        // XRename
        virtual void SAL_CALL rename( const ::rtl::OUString& newName ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);

        // helper
        virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage> getStorage() const;

        inline const ContentProperties& getContentProperties() const { return m_pImpl->m_aProps; }
        ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
            getPropertyValues( const ::com::sun::star::uno::Sequence<
                            ::com::sun::star::beans::Property >& rProperties );

        inline TContentPtr getImpl() const { return m_pImpl; }
    };

//........................................................................
}   // namespace dbaccess
//........................................................................
#endif // DBA_CONTENTHELPER_HXX
<commit_msg>INTEGRATION: CWS dba26 (1.3.82); FILE MERGED 2005/03/14 14:00:38 fs 1.3.82.2: RESYNC: (1.3-1.4); FILE MERGED 2005/03/11 13:30:55 fs 1.3.82.1: #i44786# minor typo in comment<commit_after>/*************************************************************************
 *
 *  $RCSfile: ContentHelper.hxx,v $
 *
 *  $Revision: 1.5 $
 *
 *  last change: $Author: vg $ $Date: 2005-03-23 09:47:35 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the License); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an AS IS basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/
#ifndef DBA_CONTENTHELPER_HXX
#define DBA_CONTENTHELPER_HXX

#ifndef _DBASHARED_APITOOLS_HXX_
#include "apitools.hxx"
#endif
#ifndef _COM_SUN_STAR_UCB_XCONTENT_HPP_
#include <com/sun/star/ucb/XContent.hpp>
#endif
#ifndef _COM_SUN_STAR_UCB_XCOMMANDPROCESSOR_HPP_
#include <com/sun/star/ucb/XCommandProcessor.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTIESCHANGENOTIFIER_HPP_
#include <com/sun/star/beans/XPropertiesChangeNotifier.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYCONTAINER_HPP_
#include <com/sun/star/beans/XPropertyContainer.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
#include <com/sun/star/lang/XServiceInfo.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
#include <com/sun/star/lang/XInitialization.hpp>
#endif
#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
#include <com/sun/star/container/XNameAccess.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
#include <com/sun/star/sdbc/XRow.hpp>
#endif
#ifndef _COM_SUN_STAR_EMBED_XSTORAGE_HPP_
#include <com/sun/star/embed/XStorage.hpp>
#endif
#ifndef _COM_SUN_STAR_EMBED_XEMBEDDEDOBJECT_HPP_
#include <com/sun/star/embed/XEmbeddedObject.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_
#include <com/sun/star/lang/XUnoTunnel.hpp>
#endif
#ifndef _CPPUHELPER_COMPBASE9_HXX_
#include <cppuhelper/compbase9.hxx>
#endif
#ifndef _COMPHELPER_BROADCASTHELPER_HXX_
#include <comphelper/broadcasthelper.hxx>
#endif
#ifndef _COMPHELPER_UNO3_HXX_
#include <comphelper/uno3.hxx>
#endif
#ifndef _COMPHELPER_STLTYPES_HXX_
#include <comphelper/stl_types.hxx>
#endif
#ifndef _COM_SUN_STAR_BEANS_PROPERTY_HPP_
#include <com/sun/star/beans/Property.hpp>
#endif
#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
#include <com/sun/star/container/XChild.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBCX_XRENAME_HPP_
#include <com/sun/star/sdbcx/XRename.hpp>
#endif
#ifndef BOOST_SHARED_PTR_HPP_INCLUDED
#include <boost/shared_ptr.hpp>
#endif

namespace dbaccess
{
    class ODatabaseModelImpl;
    struct ContentProperties
    {
        ::rtl::OUString aTitle;         // Title
        ::rtl::OUString aContentType;   // ContentType
        sal_Bool        bIsDocument;    // IsDocument
        sal_Bool        bIsFolder;      // IsFolder
        sal_Bool        bAsTemplate;    // AsTemplate
        ::rtl::OUString sPersistentName;// persistent name of the document

        // @@@ Add other properties supported by your content.

        ContentProperties()
        : bIsDocument( sal_True ), bIsFolder( sal_False ), bAsTemplate( sal_False ) {}
    };

    class OContentHelper_Impl
    {
    public:
        OContentHelper_Impl();
        virtual ~OContentHelper_Impl();

        ContentProperties   m_aProps;
        ODatabaseModelImpl* m_pDataSource; // this will stay alive as long as the content exists
    };

    typedef ::boost::shared_ptr<OContentHelper_Impl> TContentPtr;

    typedef ::cppu::OMultiTypeInterfaceContainerHelperVar<  ::rtl::OUString,
                                                            ::comphelper::UStringHash,
                                                            ::comphelper::UStringEqual
                                                        > PropertyChangeListenerContainer;
    typedef ::comphelper::OMutexAndBroadcastHelper  OContentHelper_MBASE;
    typedef ::cppu::WeakComponentImplHelper9    <   ::com::sun::star::ucb::XContent
                                                ,   ::com::sun::star::ucb::XCommandProcessor
                                                ,   ::com::sun::star::lang::XServiceInfo
                                                ,   ::com::sun::star::beans::XPropertiesChangeNotifier
                                                ,   ::com::sun::star::beans::XPropertyContainer
                                                ,   ::com::sun::star::lang::XInitialization
                                                ,   ::com::sun::star::lang::XUnoTunnel
                                                ,   ::com::sun::star::container::XChild
                                                ,   ::com::sun::star::sdbcx::XRename
                                                >   OContentHelper_COMPBASE;

    class OContentHelper :   public OContentHelper_MBASE
                            ,public OContentHelper_COMPBASE
    {
        ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
            setPropertyValues( const ::com::sun::star::uno::Sequence<
                                ::com::sun::star::beans::PropertyValue >& rValues,
                            const ::com::sun::star::uno::Reference<
                                ::com::sun::star::ucb::XCommandEnvironment >& xEnv );
        com::sun::star::uno::Sequence< com::sun::star::beans::Property >
            getProperties( const com::sun::star::uno::Reference<
                            com::sun::star::ucb::XCommandEnvironment > & xEnv );

    protected:
        ::cppu::OInterfaceContainerHelper   m_aContentListeners;
        PropertyChangeListenerContainer     m_aPropertyChangeListeners;
        ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >               m_xParentContainer;
        ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >    m_xORB;
        TContentPtr                     m_pImpl;
        sal_uInt32                      m_nCommandId;

        // helper
        virtual void SAL_CALL disposing();

        virtual void notifyDataSourceModified();

        /**
        * This method can be used to propagate changes of property values.
        *
        * @param evt is a sequence of property change events.
        */
        void notifyPropertiesChange( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyChangeEvent >& evt ) const;
    public:

        OContentHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB
                        ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >&   _xParentContainer
                        ,const TContentPtr& _pImpl
                    );

        // com::sun::star::lang::XTypeProvider
        DECLARE_IMPLEMENTATION_ID( );
        // ::com::sun::star::lang::XServiceInfo
        DECLARE_SERVICE_INFO();

        // XContent
        virtual ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentIdentifier > SAL_CALL getIdentifier(  ) throw (::com::sun::star::uno::RuntimeException) ;
        virtual ::rtl::OUString SAL_CALL getContentType(  ) throw (::com::sun::star::uno::RuntimeException) ;
        virtual void SAL_CALL addContentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentEventListener >& Listener ) throw (::com::sun::star::uno::RuntimeException) ;
        virtual void SAL_CALL removeContentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentEventListener >& Listener ) throw (::com::sun::star::uno::RuntimeException) ;

        // XCommandProcessor
        virtual sal_Int32 SAL_CALL createCommandIdentifier(  ) throw (::com::sun::star::uno::RuntimeException) ;
        virtual ::com::sun::star::uno::Any SAL_CALL execute( const ::com::sun::star::ucb::Command& aCommand, sal_Int32 CommandId, const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& Environment ) throw (::com::sun::star::uno::Exception, ::com::sun::star::ucb::CommandAbortedException, ::com::sun::star::uno::RuntimeException) ;
        virtual void SAL_CALL abort( sal_Int32 CommandId ) throw (::com::sun::star::uno::RuntimeException) ;

        // XPropertiesChangeNotifier
        virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener ) throw (::com::sun::star::uno::RuntimeException) ;
        virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener ) throw (::com::sun::star::uno::RuntimeException) ;

        // XPropertyContainer
        virtual void SAL_CALL addProperty( const ::rtl::OUString& Name, sal_Int16 Attributes, const ::com::sun::star::uno::Any& DefaultValue ) throw (::com::sun::star::beans::PropertyExistException, ::com::sun::star::beans::IllegalTypeException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) ;
        virtual void SAL_CALL removeProperty( const ::rtl::OUString& Name ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::NotRemoveableException, ::com::sun::star::uno::RuntimeException) ;

        // XInitialization
        virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);

        // com::sun::star::lang::XUnoTunnel
        virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);

        // ::com::sun::star::container::XChild
        virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent(  ) throw (::com::sun::star::uno::RuntimeException);
        virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);

        // XRename
        virtual void SAL_CALL rename( const ::rtl::OUString& newName ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);

        // helper
        virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage> getStorage() const;

        inline const ContentProperties& getContentProperties() const { return m_pImpl->m_aProps; }
        ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
            getPropertyValues( const ::com::sun::star::uno::Sequence<
                            ::com::sun::star::beans::Property >& rProperties );

        inline TContentPtr getImpl() const { return m_pImpl; }
    };

//........................................................................
}   // namespace dbaccess
//........................................................................
#endif // DBA_CONTENTHELPER_HXX
<|endoftext|>


<commit_before>#include "../include/File.h"
#include <vector>
#include <ctype.h>
#include <locale>
using namespace std;

const string tok = ";";
const string vars = "var";
const string consts = "const";
const string minitok = ",";
const string equals = "=";
const string affct = ":=";
const string plusLut = "+";
const string minusLut = "-";
const string multiplyLut = "*";
const string divideLut = "/";
const string paro = "(";
const string parf = ")";

File::File()
{
    //ctor
}

void File::setPath(string link)
{
    path = link;
}

File::~File()
{

}

void File::openParse()
{
	ifstream myfile;
	myfile.open (path.c_str());
	if (myfile.is_open())
	  {
		string ligne; //variable contenant chaque ligne lue

        //cette boucle s'arrête dès qu'une erreur de lecture survient
        while ( getline( myfile, ligne ) )
        {
            if(ligne != "")
            {
                    vector<string> array;
                stringstream ss(ligne);
                string temp;
                while (ss >> temp)
                {
                // Tant que le mot n'a pas été consommé entièrement
                    if(cleanWord(temp))
                    {
                        array.push_back(temp);
                    }
                    else
                    {
                       Dismantle(&array,&temp);
                    }
		}
                parsedFiles.push_back(array);
			}
        }
	    myfile.close();
		cleaning();
		// TEST PARSING ParsingTest();
	  }
	else
	{
		throw 0;
	}
}

vector<string> File::getContinueParsedFile()
{
	vector<string> continueParsedFile;
	for(unsigned int i=0; i<parsedFiles.size(); i++)
	{
		for(unsigned int j=0; j<parsedFiles[i].size(); j++)
		{
			continueParsedFile.push_back(parsedFiles[i][j]);
		}
	}
	return continueParsedFile;
}

vector<vector<string> > File::getParsedFiles()
{
	return parsedFiles;
}

void File::ParsingTest()
{
	for (unsigned int i = 0;i<parsedFiles.size();i++)
	{
		for (unsigned int j=0;j<parsedFiles[i].size();j++)
		{
			if (parsedFiles[i][j] != "")
				cout << parsedFiles[i][j] << endl;
			else
				cout << "NULL" << endl;
		}
	}
}

void File::cleaning()
{
	for (unsigned int i = 0;i<parsedFiles.size();i++)
	{
		for (unsigned int j=0;j<parsedFiles[i].size();j++)
		{
			if (parsedFiles[i][j] == "")
			parsedFiles[i].erase(parsedFiles[i].begin()+j);
		}
	}
}

void File::Dismantle(vector<string>* array,string* temp)
{
	if((*temp).find(affct)!=string::npos)
	{
		size_t found = (*temp).find(affct);
		if((*temp).substr(0,found-1) != "" && (*temp).substr(0,found-1)!=affct)
		{
			(*array).push_back((*temp).substr(0,found-1));
		}
		(*array).push_back(affct);
		string remaining;
		remaining = (*temp).substr(found+2);
		if (remaining != "")
		{
			Dismantle(array,&remaining);
		}
	}
	else
	{
		size_t found = (*temp).find_first_of("+-*/=(),;");
		if (found != std::string::npos)
		{
			string flush = "";
			for(size_t found = 0;found<(*temp).size();found++)
			{
				if(!isalpha((*temp)[found])&&!isdigit((*temp)[found]))
				{
					if(flush!="")
					{
						(*array).push_back(flush);
					}
					flush ="";
					(*array).push_back(string(1,(*temp)[found]));
				}
				else
				{
					flush +=(*temp)[found];
				}
			}
			// On flush ce qui reste
			(*array).push_back(flush);
		}
		else
		{
			 (*array).push_back((*temp));
		}
	}
}

bool File::cleanWord(string tested)
{
    if (tested.find_first_of("+-*/=(),;") != string::npos || tested.find(affct) != string::npos )
    {
        return false;
    }
    return true;
}

<commit_msg>file bug resolved<commit_after>#include "../include/File.h"
#include <vector>
#include <ctype.h>
#include <locale>
using namespace std;

const string tok = ";";
const string vars = "var";
const string consts = "const";
const string minitok = ",";
const string equals = "=";
const string affct = ":=";
const string plusLut = "+";
const string minusLut = "-";
const string multiplyLut = "*";
const string divideLut = "/";
const string paro = "(";
const string parf = ")";

File::File()
{
    //ctor
}

void File::setPath(string link)
{
    path = link;
}

File::~File()
{

}

void File::openParse()
{
	ifstream myfile;
	myfile.open (path.c_str());
	if (myfile.is_open())
	  {
		string ligne; //variable contenant chaque ligne lue

        //cette boucle s'arrête dès qu'une erreur de lecture survient
        while ( getline( myfile, ligne ) )
        {
            if(ligne != "")
            {
                    vector<string> array;
                stringstream ss(ligne);
                string temp;
                while (ss >> temp)
                {
                // Tant que le mot n'a pas été consommé entièrement
                    if(cleanWord(temp))
                    {
                        array.push_back(temp);
                    }
                    else
                    {
                       Dismantle(&array,&temp);
                    }
		}
                parsedFiles.push_back(array);
			}
        }
	    myfile.close();
		cleaning();
		ParsingTest();
	  }
	else
	{
		throw 0;
	}
}

vector<string> File::getContinueParsedFile()
{
	vector<string> continueParsedFile;
	for(unsigned int i=0; i<parsedFiles.size(); i++)
	{
		for(unsigned int j=0; j<parsedFiles[i].size(); j++)
		{
			continueParsedFile.push_back(parsedFiles[i][j]);
		}
	}
	return continueParsedFile;
}

vector<vector<string> > File::getParsedFiles()
{
	return parsedFiles;
}

void File::ParsingTest()
{
	for (unsigned int i = 0;i<parsedFiles.size();i++)
	{
		for (unsigned int j=0;j<parsedFiles[i].size();j++)
		{
			if (parsedFiles[i][j] != "")
				cout << parsedFiles[i][j] << endl;
			else
				cout << "NULL" << endl;
		}
	}
}

void File::cleaning()
{
	for (unsigned int i = 0;i<parsedFiles.size();i++)
	{
		for (unsigned int j=0;j<parsedFiles[i].size();j++)
		{
			if (parsedFiles[i][j] == "")
			parsedFiles[i].erase(parsedFiles[i].begin()+j);
		}
	}
}

void File::Dismantle(vector<string>* array,string* temp)
{
	if((*temp).find(affct)!=string::npos)
	{
		size_t found = (*temp).find(affct);
		if((*temp).substr(0,found) != "" && (*temp).substr(0,found)!=affct)
		{
			(*array).push_back((*temp).substr(0,found));
		}
		(*array).push_back(affct);
		string remaining;
		remaining = (*temp).substr(found+2);
		if (remaining != "")
		{
			Dismantle(array,&remaining);
		}
	}
	else
	{
		size_t found = (*temp).find_first_of("+-*/=(),;");
		if (found != std::string::npos)
		{
			string flush = "";
			for(size_t found = 0;found<(*temp).size();found++)
			{
				if(!isalpha((*temp)[found])&&!isdigit((*temp)[found]))
				{
					if(flush!="")
					{
						(*array).push_back(flush);
					}
					flush ="";
					(*array).push_back(string(1,(*temp)[found]));
				}
				else
				{
					flush +=(*temp)[found];
				}
			}
			// On flush ce qui reste
			(*array).push_back(flush);
		}
		else
		{
			 (*array).push_back((*temp));
		}
	}
}

bool File::cleanWord(string tested)
{
    if (tested.find_first_of("+-*/=(),;") != string::npos || tested.find(affct) != string::npos )
    {
        return false;
    }
    return true;
}

<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: dbtreemodel.cxx,v $
 *
 *  $Revision: 1.17 $
 *
 *  last change: $Author: kz $ $Date: 2006-10-05 13:01:33 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_dbaccess.hxx"

#ifndef DBAUI_DBTREEMODEL_HXX
#include "dbtreemodel.hxx"
#endif
#ifndef _DBU_RESOURCE_HRC_
#include "dbu_resource.hrc"
#endif
#ifndef _OSL_DIAGNOSE_H_
#include <osl/diagnose.h>
#endif

namespace dbaui
{
    //========================================================================
    //= DBTreeListModel
    //========================================================================
    DBG_NAME(DBTreeListUserData)
    //------------------------------------------------------------------------
    DBTreeListModel::DBTreeListUserData::DBTreeListUserData()
        :eType(SbaTableQueryBrowser::etQuery)
    {
        DBG_CTOR(DBTreeListUserData,NULL);
    }
    //------------------------------------------------------------------------
    DBTreeListModel::DBTreeListUserData::~DBTreeListUserData()
    {
        DBG_DTOR(DBTreeListUserData,NULL);
    }
}
<commit_msg>INTEGRATION: CWS changefileheader (1.17.248); FILE MERGED 2008/03/31 13:27:07 rt 1.17.248.1: #i87441# Change license header to LPGL v3.<commit_after>/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: dbtreemodel.cxx,v $
 * $Revision: 1.18 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_dbaccess.hxx"

#ifndef DBAUI_DBTREEMODEL_HXX
#include "dbtreemodel.hxx"
#endif
#ifndef _DBU_RESOURCE_HRC_
#include "dbu_resource.hrc"
#endif
#ifndef _OSL_DIAGNOSE_H_
#include <osl/diagnose.h>
#endif

namespace dbaui
{
    //========================================================================
    //= DBTreeListModel
    //========================================================================
    DBG_NAME(DBTreeListUserData)
    //------------------------------------------------------------------------
    DBTreeListModel::DBTreeListUserData::DBTreeListUserData()
        :eType(SbaTableQueryBrowser::etQuery)
    {
        DBG_CTOR(DBTreeListUserData,NULL);
    }
    //------------------------------------------------------------------------
    DBTreeListModel::DBTreeListUserData::~DBTreeListUserData()
    {
        DBG_DTOR(DBTreeListUserData,NULL);
    }
}
<|endoftext|>


<commit_before>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/mdia/mdiamba.C $                                 */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2012,2013              */
/*                                                                        */
/* p1                                                                     */
/*                                                                        */
/* Object Code Only (OCO) source materials                                */
/* Licensed Internal Code Source Materials                                */
/* IBM HostBoot Licensed Internal Code                                    */
/*                                                                        */
/* The source code for this program is not published or otherwise         */
/* divested of its trade secrets, irrespective of what has been           */
/* deposited with the U.S. Copyright Office.                              */
/*                                                                        */
/* Origin: 30                                                             */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
/**
 * @file mdiamba.C
 * @brief mdia mba specific functions
 */

#include "mdiafwd.H"
#include "mdiaglobals.H"
#include "mdiasm.H"
#include "mdiatrace.H"
#include "targeting/common/utilFilter.H"

using namespace TARGETING;

namespace MDIA
{

errlHndl_t getMbaDiagnosticMode(
        const Globals & i_globals,
        TargetHandle_t i_mba,
        DiagMode & o_mode)
{
    o_mode = INIT_ONLY;

    if(MNFG_FLAG_BIT_MNFG_ENABLE_EXHAUSTIVE_PATTERN_TEST
            & i_globals.mfgPolicy)
    {
        o_mode = NINE_PATTERNS;
    }

    else if(MNFG_FLAG_BIT_MNFG_ENABLE_STANDARD_PATTERN_TEST
            & i_globals.mfgPolicy)
    {
        o_mode = FOUR_PATTERNS;
    }

    else if(MNFG_FLAG_BIT_MNFG_ENABLE_MINIMUM_PATTERN_TEST
            & i_globals.mfgPolicy)
    {
        o_mode = ONE_PATTERN;
    }

    // Only need to check hw changed state attributes
    // when not already set to standard or exhaustive
    if((FOUR_PATTERNS != o_mode) ||
       (NINE_PATTERNS != o_mode))
    {
        if(isHWStateChanged(i_mba))
        {
            o_mode = FOUR_PATTERNS;
        }
    }

    MDIA_FAST("getMbaDiagnosticMode: mba: %x, o_mode: 0x%x",
              get_huid(i_mba), o_mode);

    return 0;
}

errlHndl_t getMbaWorkFlow(
                DiagMode i_mode,
                WorkFlow & o_wf,
                const Globals & i_globals)
{
    // add the correct sequences for the mba based
    // on the mode

    // every mba does restore dram repairs

    o_wf.push_back(RESTORE_DRAM_REPAIRS);

    switch (i_mode) {

        case NINE_PATTERNS:

            o_wf.push_back(START_RANDOM_PATTERN);
            o_wf.push_back(START_SCRUB);
            o_wf.push_back(START_PATTERN_7);
            o_wf.push_back(START_SCRUB);
            o_wf.push_back(START_PATTERN_6);
            o_wf.push_back(START_SCRUB);
            o_wf.push_back(START_PATTERN_5);
            o_wf.push_back(START_SCRUB);
            o_wf.push_back(START_PATTERN_4);
            o_wf.push_back(START_SCRUB);

            // fall through

        case FOUR_PATTERNS:

            o_wf.push_back(START_PATTERN_3);
            o_wf.push_back(START_SCRUB);
            o_wf.push_back(START_PATTERN_2);
            o_wf.push_back(START_SCRUB);
            o_wf.push_back(START_PATTERN_1);
            o_wf.push_back(START_SCRUB);

            // fall through

        case ONE_PATTERN:

            o_wf.push_back(START_PATTERN_0);

            // fall through

        case SCRUB_ONLY:

            o_wf.push_back(START_SCRUB);
            break;

        case INIT_ONLY:

            o_wf.push_back(START_PATTERN_0);
            break;

        default:
            break;
    }

    if(MNFG_FLAG_BIT_MNFG_IPL_MEMORY_CE_CHECKINGE
            & i_globals.mfgPolicy)
    {
        o_wf.push_back(ANALYZE_IPL_MNFG_CE_STATS);
    }

    // clear HW changed state attribute
    o_wf.push_back(CLEAR_HW_CHANGED_STATE);
    return 0;
}

/*
 *  Local helper function to return a list of Centaur
 *  DIMMs, and MCS associated with the input MBA target
 *
 *  If i_queryOnly = true (Query)
 *    - Return a list of DIMMs, Centaur, and
 *      MCS connected to this MBA
 *
 *  Else (Clear)
 *   - Return a list of DIMMs and
 *     (Centaur + MCS) if all the DIMMs behind this
 *     Centaur have hwchangedState flags cleared
 *     or about to be cleared by this MBA
 */
TargetHandleList getMemTargetsForQueryOrClear(
                    TargetHandle_t i_mba, bool i_queryOnly)
{
    #define FUNC "getMemTargetsForQueryOrClear: "
    TargetHandleList o_list;

    do
    {
        // add associated DIMMs
        TargetHandleList dimmList;
        getChildAffinityTargets(dimmList,
                                i_mba,
                                CLASS_NA,
                                TYPE_DIMM);

        if( ! dimmList.empty() )
        {
            o_list.insert(o_list.begin(), dimmList.begin(),
                          dimmList.end());
        }

        // add associated Centaur
        TargetHandleList targetList;
        getParentAffinityTargets(targetList,
                                 i_mba,
                                 CLASS_CHIP,
                                 TYPE_MEMBUF);

        if( targetList.empty() )
        {
            MDIA_FAST(FUNC"no connected centaur "
                    "for mba: %x", get_huid(i_mba));
            break;
        }

        TargetHandle_t centaur = targetList[0];

        // if query flag is not set, check to make sure
        // all of the dimms connected to this centaur
        // have cleared hw chagned state attributes
        // before adding this centaur/mcs to the list.
        // This is needed because we only clear
        // the centaur/mcs attribute when all of the
        // dimms' attributes from both mbas have cleared.
        if(false == i_queryOnly)
        {
            targetList.clear();
            getChildAffinityTargets(targetList,
                                    centaur,
                                    CLASS_NA,
                                    TYPE_DIMM);

            if( ! targetList.empty() )
            {
                TargetHandleList::iterator target;

                for(target = targetList.begin();
                    target != targetList.end(); ++target)
                {
                    // exclude dimms belong to the current mba
                    // because their attributes will be cleared
                    if(dimmList.end() !=
                             std::find(dimmList.begin(),
                                       dimmList.end(), *target))
                    {
                        continue;
                    }

                    ATTR_HWAS_STATE_CHANGED_FLAG_type hwChangeFlag;
                    hwChangeFlag =
                      (*target)->getAttr<ATTR_HWAS_STATE_CHANGED_FLAG>();

                    if(HWAS_CHANGED_BIT_MEMDIAG & hwChangeFlag)
                    {
                        MDIA_FAST(FUNC"hwChangedState is not cleared "
                                  "for dimm: %x", get_huid(*target));
                        centaur = NULL; // don't add centaur and mcs
                        break;
                    }
                }
            }
        }

        if(NULL == centaur)
        {
            break;
        }

        o_list.push_back(centaur);

        // get connected mcs target
        targetList.clear();

        getParentAffinityTargets(targetList,
                                 centaur,
                                 CLASS_UNIT,
                                 TYPE_MCS);

        if( ! targetList.empty() )
        {
            o_list.push_back(targetList[0]);
        }

    } while(0);

    MDIA_DBG(FUNC"mba: %x, size: %d",
             get_huid(i_mba), o_list.size());

    return o_list;

    #undef FUNC
}

bool isHWStateChanged(TargetHandle_t i_mba)
{
    bool hwChanged = false;
    ATTR_HWAS_STATE_CHANGED_FLAG_type hwChangeFlag;

    // Get a list of associated targets for attribute query
    TargetHandleList targetList =
        getMemTargetsForQueryOrClear(i_mba, true);

    for(TargetHandleList::iterator target = targetList.begin();
        target != targetList.end(); ++target )
    {
        hwChangeFlag =
            (*target)->getAttr<ATTR_HWAS_STATE_CHANGED_FLAG>();

        if(HWAS_CHANGED_BIT_MEMDIAG & hwChangeFlag)
        {
            MDIA_DBG("isHWStateChanged: set for target: %x",
                     get_huid(*target));
            hwChanged = true;
            break;
        }
    }

    return hwChanged;
}

void clearHWStateChanged(TargetHandle_t i_mba)
{
    TargetHandleList targetList;

    // Get a list of associated targets for attribute clearing
    targetList = getMemTargetsForQueryOrClear(i_mba, false);

    for(TargetHandleList::iterator target = targetList.begin();
        target != targetList.end(); ++target)
    {
        MDIA_DBG("clearHWStateChanged: mba: %x, target: %x",
                 get_huid(i_mba), get_huid(*target));

        clear_hwas_changed_bit( *target,
                                HWAS_CHANGED_BIT_MEMDIAG);
    }
}

}
<commit_msg>MDIA: fix bug in pattern test check<commit_after>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/mdia/mdiamba.C $                                 */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2012,2013              */
/*                                                                        */
/* p1                                                                     */
/*                                                                        */
/* Object Code Only (OCO) source materials                                */
/* Licensed Internal Code Source Materials                                */
/* IBM HostBoot Licensed Internal Code                                    */
/*                                                                        */
/* The source code for this program is not published or otherwise         */
/* divested of its trade secrets, irrespective of what has been           */
/* deposited with the U.S. Copyright Office.                              */
/*                                                                        */
/* Origin: 30                                                             */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
/**
 * @file mdiamba.C
 * @brief mdia mba specific functions
 */

#include "mdiafwd.H"
#include "mdiaglobals.H"
#include "mdiasm.H"
#include "mdiatrace.H"
#include "targeting/common/utilFilter.H"

using namespace TARGETING;

namespace MDIA
{

errlHndl_t getMbaDiagnosticMode(
        const Globals & i_globals,
        TargetHandle_t i_mba,
        DiagMode & o_mode)
{
    o_mode = INIT_ONLY;

    if(MNFG_FLAG_BIT_MNFG_ENABLE_EXHAUSTIVE_PATTERN_TEST
            & i_globals.mfgPolicy)
    {
        o_mode = NINE_PATTERNS;
    }

    else if(MNFG_FLAG_BIT_MNFG_ENABLE_STANDARD_PATTERN_TEST
            & i_globals.mfgPolicy)
    {
        o_mode = FOUR_PATTERNS;
    }

    else if(MNFG_FLAG_BIT_MNFG_ENABLE_MINIMUM_PATTERN_TEST
            & i_globals.mfgPolicy)
    {
        o_mode = ONE_PATTERN;
    }

    // Only need to check hw changed state attributes
    // when not already set to standard or exhaustive
    if(!((FOUR_PATTERNS == o_mode) ||
         (NINE_PATTERNS == o_mode)))
    {
        if(isHWStateChanged(i_mba))
        {
            o_mode = FOUR_PATTERNS;
        }
    }

    MDIA_FAST("getMbaDiagnosticMode: mba: %x, o_mode: 0x%x",
              get_huid(i_mba), o_mode);

    return 0;
}

errlHndl_t getMbaWorkFlow(
                DiagMode i_mode,
                WorkFlow & o_wf,
                const Globals & i_globals)
{
    // add the correct sequences for the mba based
    // on the mode

    // every mba does restore dram repairs

    o_wf.push_back(RESTORE_DRAM_REPAIRS);

    switch (i_mode) {

        case NINE_PATTERNS:

            o_wf.push_back(START_RANDOM_PATTERN);
            o_wf.push_back(START_SCRUB);
            o_wf.push_back(START_PATTERN_7);
            o_wf.push_back(START_SCRUB);
            o_wf.push_back(START_PATTERN_6);
            o_wf.push_back(START_SCRUB);
            o_wf.push_back(START_PATTERN_5);
            o_wf.push_back(START_SCRUB);
            o_wf.push_back(START_PATTERN_4);
            o_wf.push_back(START_SCRUB);

            // fall through

        case FOUR_PATTERNS:

            o_wf.push_back(START_PATTERN_3);
            o_wf.push_back(START_SCRUB);
            o_wf.push_back(START_PATTERN_2);
            o_wf.push_back(START_SCRUB);
            o_wf.push_back(START_PATTERN_1);
            o_wf.push_back(START_SCRUB);

            // fall through

        case ONE_PATTERN:

            o_wf.push_back(START_PATTERN_0);

            // fall through

        case SCRUB_ONLY:

            o_wf.push_back(START_SCRUB);
            break;

        case INIT_ONLY:

            o_wf.push_back(START_PATTERN_0);
            break;

        default:
            break;
    }

    if(MNFG_FLAG_BIT_MNFG_IPL_MEMORY_CE_CHECKINGE
            & i_globals.mfgPolicy)
    {
        o_wf.push_back(ANALYZE_IPL_MNFG_CE_STATS);
    }

    // clear HW changed state attribute
    o_wf.push_back(CLEAR_HW_CHANGED_STATE);
    return 0;
}

/*
 *  Local helper function to return a list of Centaur
 *  DIMMs, and MCS associated with the input MBA target
 *
 *  If i_queryOnly = true (Query)
 *    - Return a list of DIMMs, Centaur, and
 *      MCS connected to this MBA
 *
 *  Else (Clear)
 *   - Return a list of DIMMs and
 *     (Centaur + MCS) if all the DIMMs behind this
 *     Centaur have hwchangedState flags cleared
 *     or about to be cleared by this MBA
 */
TargetHandleList getMemTargetsForQueryOrClear(
                    TargetHandle_t i_mba, bool i_queryOnly)
{
    #define FUNC "getMemTargetsForQueryOrClear: "
    TargetHandleList o_list;

    do
    {
        // add associated DIMMs
        TargetHandleList dimmList;
        getChildAffinityTargets(dimmList,
                                i_mba,
                                CLASS_NA,
                                TYPE_DIMM);

        if( ! dimmList.empty() )
        {
            o_list.insert(o_list.begin(), dimmList.begin(),
                          dimmList.end());
        }

        // add associated Centaur
        TargetHandleList targetList;
        getParentAffinityTargets(targetList,
                                 i_mba,
                                 CLASS_CHIP,
                                 TYPE_MEMBUF);

        if( targetList.empty() )
        {
            MDIA_FAST(FUNC"no connected centaur "
                    "for mba: %x", get_huid(i_mba));
            break;
        }

        TargetHandle_t centaur = targetList[0];

        // if query flag is not set, check to make sure
        // all of the dimms connected to this centaur
        // have cleared hw chagned state attributes
        // before adding this centaur/mcs to the list.
        // This is needed because we only clear
        // the centaur/mcs attribute when all of the
        // dimms' attributes from both mbas have cleared.
        if(false == i_queryOnly)
        {
            targetList.clear();
            getChildAffinityTargets(targetList,
                                    centaur,
                                    CLASS_NA,
                                    TYPE_DIMM);

            if( ! targetList.empty() )
            {
                TargetHandleList::iterator target;

                for(target = targetList.begin();
                    target != targetList.end(); ++target)
                {
                    // exclude dimms belong to the current mba
                    // because their attributes will be cleared
                    if(dimmList.end() !=
                             std::find(dimmList.begin(),
                                       dimmList.end(), *target))
                    {
                        continue;
                    }

                    ATTR_HWAS_STATE_CHANGED_FLAG_type hwChangeFlag;
                    hwChangeFlag =
                      (*target)->getAttr<ATTR_HWAS_STATE_CHANGED_FLAG>();

                    if(HWAS_CHANGED_BIT_MEMDIAG & hwChangeFlag)
                    {
                        MDIA_FAST(FUNC"hwChangedState is not cleared "
                                  "for dimm: %x", get_huid(*target));
                        centaur = NULL; // don't add centaur and mcs
                        break;
                    }
                }
            }
        }

        if(NULL == centaur)
        {
            break;
        }

        o_list.push_back(centaur);

        // get connected mcs target
        targetList.clear();

        getParentAffinityTargets(targetList,
                                 centaur,
                                 CLASS_UNIT,
                                 TYPE_MCS);

        if( ! targetList.empty() )
        {
            o_list.push_back(targetList[0]);
        }

    } while(0);

    MDIA_DBG(FUNC"mba: %x, size: %d",
             get_huid(i_mba), o_list.size());

    return o_list;

    #undef FUNC
}

bool isHWStateChanged(TargetHandle_t i_mba)
{
    bool hwChanged = false;
    ATTR_HWAS_STATE_CHANGED_FLAG_type hwChangeFlag;

    // Get a list of associated targets for attribute query
    TargetHandleList targetList =
        getMemTargetsForQueryOrClear(i_mba, true);

    for(TargetHandleList::iterator target = targetList.begin();
        target != targetList.end(); ++target )
    {
        hwChangeFlag =
            (*target)->getAttr<ATTR_HWAS_STATE_CHANGED_FLAG>();

        if(HWAS_CHANGED_BIT_MEMDIAG & hwChangeFlag)
        {
            MDIA_DBG("isHWStateChanged: set for target: %x",
                     get_huid(*target));
            hwChanged = true;
            break;
        }
    }

    return hwChanged;
}

void clearHWStateChanged(TargetHandle_t i_mba)
{
    TargetHandleList targetList;

    // Get a list of associated targets for attribute clearing
    targetList = getMemTargetsForQueryOrClear(i_mba, false);

    for(TargetHandleList::iterator target = targetList.begin();
        target != targetList.end(); ++target)
    {
        MDIA_DBG("clearHWStateChanged: mba: %x, target: %x",
                 get_huid(i_mba), get_huid(*target));

        clear_hwas_changed_bit( *target,
                                HWAS_CHANGED_BIT_MEMDIAG);
    }
}

}
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: TableWindowData.hxx,v $
 *
 *  $Revision: 1.2 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-08 15:38:38 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef DBAUI_TABLEWINDOWDATA_HXX
#define DBAUI_TABLEWINDOWDATA_HXX

#ifndef _SV_GEN_HXX
#include <tools/gen.hxx>
#endif
#ifndef _RTTI_HXX
#include <tools/rtti.hxx>
#endif
#ifndef _COM_SUN_STAR_IO_XOBJECTOUTPUTSTREAM_HPP_
#include <com/sun/star/io/XObjectOutputStream.hpp>
#endif
#ifndef _COM_SUN_STAR_IO_XOBJECTINPUTSTREAM_HPP_
#include <com/sun/star/io/XObjectInputStream.hpp>
#endif

namespace dbaui
{
    class OTableWindowData
    {
    protected:
        ::rtl::OUString m_aTableName;
        ::rtl::OUString m_aWinName;
        ::rtl::OUString m_sComposedName;
        Point           m_aPosition;
        Size            m_aSize;
        sal_Bool        m_bShowAll;

    public:
        TYPEINFO();
        OTableWindowData();
        OTableWindowData( const ::rtl::OUString& _rComposedName, const ::rtl::OUString& strTableName, const ::rtl::OUString& rWinName = ::rtl::OUString() );
        virtual ~OTableWindowData();

        virtual void Load(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxIn);
        virtual void Save(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOut);

        ::rtl::OUString GetComposedName()   const { return m_sComposedName; }
        ::rtl::OUString GetTableName()      const { return m_aTableName; }
        ::rtl::OUString GetWinName()        const { return m_aWinName; }
        Point GetPosition()                 const { return m_aPosition; }
        Size GetSize()                      const { return m_aSize; }
        BOOL IsShowAll()                    const { return m_bShowAll; }
        BOOL HasPosition()  const;
        BOOL HasSize()      const;

        void SetTableName( const ::rtl::OUString& rTableName )  { m_aTableName = rTableName; }
        void SetWinName( const ::rtl::OUString& rWinName )      { m_aWinName = rWinName; }
        void SetPosition( const Point& rPos )                   { m_aPosition=rPos; }
        void SetSize( const Size& rSize )                       { m_aSize = rSize; }
        void ShowAll( BOOL bAll )                               { m_bShowAll = bAll; }
    };
}
#endif // DBAUI_TABLEWINDOWDATA_HXX

<commit_msg>INTEGRATION: CWS dba24b (1.2.306); FILE MERGED 2007/08/16 06:14:43 oj 1.2.306.1: #i56898# clean up of the class structure<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: TableWindowData.hxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: hr $ $Date: 2007-11-01 15:19:26 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef DBAUI_TABLEWINDOWDATA_HXX
#define DBAUI_TABLEWINDOWDATA_HXX

#ifndef _SV_GEN_HXX
#include <tools/gen.hxx>
#endif
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/sdbc/XConnection.hpp>
#include <unotools/eventlisteneradapter.hxx>
#include <boost/shared_ptr.hpp>
#include <vector>

namespace dbaui
{
    class OTableWindowData : public ::utl::OEventListenerAdapter
    {
        mutable ::osl::Mutex    m_aMutex;

        void listen();
    protected:
        // the columns of the table
        ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >       m_xTable; // can either be a table or a query
        ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >    m_xColumns;

        ::rtl::OUString m_aTableName;
        ::rtl::OUString m_aWinName;
        ::rtl::OUString m_sComposedName;
        Point           m_aPosition;
        Size            m_aSize;
        sal_Bool        m_bShowAll;
        bool            m_bIsQuery;

    public:
        explicit OTableWindowData(  const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xTable
                                   ,const ::rtl::OUString& _rComposedName
                                   ,const ::rtl::OUString& strTableName
                                   ,const ::rtl::OUString& rWinName = ::rtl::OUString() );
        virtual ~OTableWindowData();

        /** late constructor
        *
        * \param _xConnection
        * \param _bAllowQueries when true, queries are allowed
        * \return false if the table was unaccessible otherwise true
        */
        bool init(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection  >& _xConnection
                 ,bool _bAllowQueries);

        inline ::rtl::OUString GetComposedName()    const { return m_sComposedName; }
        inline ::rtl::OUString GetTableName()       const { return m_aTableName; }
        inline ::rtl::OUString GetWinName()         const { return m_aWinName; }
        inline Point GetPosition()                  const { return m_aPosition; }
        inline Size GetSize()                       const { return m_aSize; }
        inline BOOL IsShowAll()                     const { return m_bShowAll; }
        inline bool isQuery()                       const { return m_bIsQuery; }
        BOOL HasPosition()  const;
        BOOL HasSize()      const;

        inline void SetWinName( const ::rtl::OUString& rWinName )       { m_aWinName = rWinName; }
        inline void SetPosition( const Point& rPos )                    { m_aPosition=rPos; }
        inline void SetSize( const Size& rSize )                        { m_aSize = rSize; }
        inline void ShowAll( BOOL bAll )                                { m_bShowAll = bAll; }

        inline ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getTable() const { ::osl::MutexGuard aGuard( m_aMutex  ); return m_xTable; }
        inline ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > getColumns() const { ::osl::MutexGuard aGuard( m_aMutex  ); return m_xColumns; }

        // OEventListenerAdapter
        virtual void _disposing( const ::com::sun::star::lang::EventObject& _rSource );
    };

    typedef ::std::vector< ::boost::shared_ptr<OTableWindowData> >      TTableWindowData;
}
#endif // DBAUI_TABLEWINDOWDATA_HXX

<|endoftext|>


<commit_before>//===--- Main.cpp - The LLVM Compiler Driver -------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open
// Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
//  Usually this file just includes CompilerDriver/Main.inc, but here we apply
//  some trickery to make the built-in '-save-temps' option hidden and enabled
//  by default.
//
//===----------------------------------------------------------------------===//

#include "llvm/CompilerDriver/BuiltinOptions.h"
#include "llvm/CompilerDriver/ForceLinkage.h"

namespace llvmc {
  int Main(int argc, char** argv);
}

int main(int argc, char** argv) {

  // HACK
  SaveTemps = SaveTempsEnum::Obj;
  SaveTemps.setHiddenFlag(llvm::cl::Hidden);

  llvmc::ForceLinkage();
  return llvmc::Main(argc, argv);
}
<commit_msg>By default -t is always on for mcc16 and it uses ./tmp-objs as the temp directory.<commit_after>//===--- Main.cpp - The LLVM Compiler Driver -------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open
// Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
//  Usually this file just includes CompilerDriver/Main.inc, but here we apply
//  some trickery to make the built-in '-save-temps' option hidden and enabled
//  by default.
//
//===----------------------------------------------------------------------===//

#include "llvm/CompilerDriver/BuiltinOptions.h"
#include "llvm/CompilerDriver/ForceLinkage.h"

namespace llvmc {
  int Main(int argc, char** argv);
}

int main(int argc, char** argv) {

  // HACK
  SaveTemps = SaveTempsEnum::Unset;
  SaveTemps.setHiddenFlag(llvm::cl::Hidden);
  TempDirname = "tmp-objs";

  llvmc::ForceLinkage();
  return llvmc::Main(argc, argv);
}
<|endoftext|>


<commit_before>
//
// Copyright (c) 2012 Jonathan Topf
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

// Platform-specific configuration.
#if defined _WIN32
    #define REQUIRE_IOSTREAM
#elif defined __APPLE__
    #include <maya/OpenMayaMac.h>
#endif

// Maya headers.
#include <maya/MArgList.h>
#include <maya/MDagPath.h>
#include <maya/MFloatArray.h>
#include <maya/MFloatVector.h>
#include <maya/MFloatVectorArray.h>
#include <maya/MFnDependencyNode.h>
#include <maya/MFnMesh.h>
#include <maya/MGlobal.h>
#include <maya/MIntArray.h>
#include <maya/MIOStream.h>
#include <maya/MItMeshPolygon.h>
#include <maya/MObject.h>
#include <maya/MObjectArray.h>
#include <maya/MPlug.h>
#include <maya/MPlugArray.h>
#include <maya/MPoint.h>
#include <maya/MPointArray.h>
#include <maya/MSelectionList.h>
#include <maya/MSimple.h>
#include <maya/MStatus.h>
#include <maya/MString.h>

// Standard headers.
#include <fstream>
#include <vector>

#if defined _WIN32
    #if defined ms_export_obj_EXPORTS
        #define DLLSYMBOL __declspec(dllexport)
    #else
        #define DLLSYMBOL __declspec(dllimport)
    #endif
#else
    #define DLLSYMBOL
#endif

using namespace std;

const MString Version("0.1.2");

DLLSYMBOL MStatus initializePlugin(MObject _obj);
DLLSYMBOL MStatus uninitializePlugin(MObject _obj);

DeclareSimpleCommand(ms_export_obj, "mayaseed", Version.asChar());

//
// Reference:
//
//   robthebloke.org, Intermediate Exporter + Viewer:
//   http://nccastaff.bournemouth.ac.uk/jmacey/RobTheBloke/www/index.html
//

MStatus ms_export_obj::doIt(const MArgList& args)
{
    // Extract arguments.
    MString mesh_name;
    MString file_path;
    for (unsigned int i = 0; i < args.length(); i++)
    {
        if (args.asString(i) == "-mesh")
            mesh_name = args.asString(++i);
        else if (args.asString(i) == "-filePath")
            file_path = args.asString(++i);
    }

    MString display_info;
    display_info.format("Exporting ^1s to ^2s using ms_export_obj (native)", mesh_name, file_path);
    MGlobal::displayInfo(display_info);

    MSelectionList sel;
    sel.add(mesh_name);

    MDagPath mesh_dag_path;
    sel.getDagPath(0, mesh_dag_path);

    MFnMesh mesh(mesh_dag_path);

    // Open file for writing, overwriting previous contents.
    ofstream out_file;
    out_file.open(file_path.asChar(), ios::trunc);
    out_file << "# File generated by ms_export_obj version " << Version.asChar() << endl << endl;

    // Write vertices.
    MPointArray point_array;
    mesh.getPoints(point_array);
    const unsigned int point_count = point_array.length();
    for (unsigned int i = 0; i < point_count; ++i)
    {
        const MPoint& p = point_array[i];
        out_file << "v " << p.x << ' ' << p.y << ' ' << p.z << endl;
    }

    // Write UVs.
    MFloatArray u_array, v_array;
    mesh.getUVs(u_array, v_array);
    const unsigned int uv_count = u_array.length();
    for (unsigned int i = 0; i < uv_count; ++i)
    {
        out_file << "vt " << u_array[i] << ' ' << v_array[i] << endl;
    }

    // Write normals.
    MFloatVectorArray normal_array;
    mesh.getNormals(normal_array, MSpace::kTransform);
    const unsigned int normal_count = normal_array.length();
    for (unsigned int i = 0; i < normal_count; ++i)
    {
        const MFloatVector& n = normal_array[i];
        out_file << "vn " << n.x << ' ' << n.y <<  ' ' << n.z << endl;
    }

    // Build a list of all surface shaders used on the mesh. Note that
    // the nodes returned are the shading groups, not the material nodes!
    MObjectArray shaders;
    MIntArray shader_indices;
    mesh.getConnectedShaders(0, shaders, shader_indices);

    // Build array of material names.
    vector<MString> material_names;
    for (unsigned int i = 0; i < shaders.length(); ++i)
    {
        const MFnDependencyNode shader(shaders[i]);
        const MPlug surface_shader = shader.findPlug("surfaceShader");

        MPlugArray materials;
        surface_shader.connectedTo(materials, true, true);

        for (unsigned int j = 0; j < materials.length(); ++j)
        {
            const MFnDependencyNode material(materials[j].node());
            material_names.push_back(material.name());
        }
    }

    // Write faces.
    unsigned int face_index = 0;
    unsigned int last_shader_index = ~0;
    MItMeshPolygon poly_it(mesh.object());
    while (!poly_it.isDone())
    {
        const int shader_index = shader_indices[face_index];

        if (shader_index != last_shader_index)
        {
            last_shader_index = shader_index;

            out_file << "usemtl ";

            if (shader_index == -1)
                out_file << "no_material";
            else
                out_file << material_names[shader_index];

            out_file << endl;
        }

        out_file << 'f';

        const unsigned int vertex_count = poly_it.polygonVertexCount();
        for (unsigned int i = 0; i < vertex_count; ++i)
        {
            int uv_index;
            poly_it.getUVIndex(i, uv_index);
            out_file << ' ' << (poly_it.vertexIndex(i) + 1) << '/' << (uv_index + 1) << '/' << (poly_it.normalIndex(i) + 1);
        }

        out_file << endl;

        ++face_index;
        poly_it.next();
    }

    // CLose the file.
    out_file.close();

    return MS::kSuccess;
}
<commit_msg>fixed typo.<commit_after>
//
// Copyright (c) 2012 Jonathan Topf
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

// Platform-specific configuration.
#if defined _WIN32
    #define REQUIRE_IOSTREAM
#elif defined __APPLE__
    #include <maya/OpenMayaMac.h>
#endif

// Maya headers.
#include <maya/MArgList.h>
#include <maya/MDagPath.h>
#include <maya/MFloatArray.h>
#include <maya/MFloatVector.h>
#include <maya/MFloatVectorArray.h>
#include <maya/MFnDependencyNode.h>
#include <maya/MFnMesh.h>
#include <maya/MGlobal.h>
#include <maya/MIntArray.h>
#include <maya/MIOStream.h>
#include <maya/MItMeshPolygon.h>
#include <maya/MObject.h>
#include <maya/MObjectArray.h>
#include <maya/MPlug.h>
#include <maya/MPlugArray.h>
#include <maya/MPoint.h>
#include <maya/MPointArray.h>
#include <maya/MSelectionList.h>
#include <maya/MSimple.h>
#include <maya/MStatus.h>
#include <maya/MString.h>

// Standard headers.
#include <fstream>
#include <vector>

#if defined _WIN32
    #if defined ms_export_obj_EXPORTS
        #define DLLSYMBOL __declspec(dllexport)
    #else
        #define DLLSYMBOL __declspec(dllimport)
    #endif
#else
    #define DLLSYMBOL
#endif

using namespace std;

const MString Version("0.1.2");

DLLSYMBOL MStatus initializePlugin(MObject _obj);
DLLSYMBOL MStatus uninitializePlugin(MObject _obj);

DeclareSimpleCommand(ms_export_obj, "mayaseed", Version.asChar());

//
// Reference:
//
//   robthebloke.org, Intermediate Exporter + Viewer:
//   http://nccastaff.bournemouth.ac.uk/jmacey/RobTheBloke/www/index.html
//

MStatus ms_export_obj::doIt(const MArgList& args)
{
    // Extract arguments.
    MString mesh_name;
    MString file_path;
    for (unsigned int i = 0; i < args.length(); i++)
    {
        if (args.asString(i) == "-mesh")
            mesh_name = args.asString(++i);
        else if (args.asString(i) == "-filePath")
            file_path = args.asString(++i);
    }

    MString display_info;
    display_info.format("Exporting ^1s to ^2s using ms_export_obj (native)", mesh_name, file_path);
    MGlobal::displayInfo(display_info);

    MSelectionList sel;
    sel.add(mesh_name);

    MDagPath mesh_dag_path;
    sel.getDagPath(0, mesh_dag_path);

    MFnMesh mesh(mesh_dag_path);

    // Open file for writing, overwriting previous contents.
    ofstream out_file;
    out_file.open(file_path.asChar(), ios::trunc);
    out_file << "# File generated by ms_export_obj version " << Version.asChar() << endl << endl;

    // Write vertices.
    MPointArray point_array;
    mesh.getPoints(point_array);
    const unsigned int point_count = point_array.length();
    for (unsigned int i = 0; i < point_count; ++i)
    {
        const MPoint& p = point_array[i];
        out_file << "v " << p.x << ' ' << p.y << ' ' << p.z << endl;
    }

    // Write UVs.
    MFloatArray u_array, v_array;
    mesh.getUVs(u_array, v_array);
    const unsigned int uv_count = u_array.length();
    for (unsigned int i = 0; i < uv_count; ++i)
    {
        out_file << "vt " << u_array[i] << ' ' << v_array[i] << endl;
    }

    // Write normals.
    MFloatVectorArray normal_array;
    mesh.getNormals(normal_array, MSpace::kTransform);
    const unsigned int normal_count = normal_array.length();
    for (unsigned int i = 0; i < normal_count; ++i)
    {
        const MFloatVector& n = normal_array[i];
        out_file << "vn " << n.x << ' ' << n.y <<  ' ' << n.z << endl;
    }

    // Build a list of all surface shaders used on the mesh. Note that
    // the nodes returned are the shading groups, not the material nodes!
    MObjectArray shaders;
    MIntArray shader_indices;
    mesh.getConnectedShaders(0, shaders, shader_indices);

    // Build array of material names.
    vector<MString> material_names;
    for (unsigned int i = 0; i < shaders.length(); ++i)
    {
        const MFnDependencyNode shader(shaders[i]);
        const MPlug surface_shader = shader.findPlug("surfaceShader");

        MPlugArray materials;
        surface_shader.connectedTo(materials, true, true);

        for (unsigned int j = 0; j < materials.length(); ++j)
        {
            const MFnDependencyNode material(materials[j].node());
            material_names.push_back(material.name());
        }
    }

    // Write faces.
    unsigned int face_index = 0;
    unsigned int last_shader_index = ~0;
    MItMeshPolygon poly_it(mesh.object());
    while (!poly_it.isDone())
    {
        const int shader_index = shader_indices[face_index];

        if (shader_index != last_shader_index)
        {
            last_shader_index = shader_index;

            out_file << "usemtl ";

            if (shader_index == -1)
                out_file << "no_material";
            else
                out_file << material_names[shader_index];

            out_file << endl;
        }

        out_file << 'f';

        const unsigned int vertex_count = poly_it.polygonVertexCount();
        for (unsigned int i = 0; i < vertex_count; ++i)
        {
            int uv_index;
            poly_it.getUVIndex(i, uv_index);
            out_file << ' ' << (poly_it.vertexIndex(i) + 1) << '/' << (uv_index + 1) << '/' << (poly_it.normalIndex(i) + 1);
        }

        out_file << endl;

        ++face_index;
        poly_it.next();
    }

    // Close the file.
    out_file.close();

    return MS::kSuccess;
}
<|endoftext|>