aboutsummaryrefslogtreecommitdiff
path: root/tools/lldb-mi/MIUtilVariant.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lldb-mi/MIUtilVariant.h')
-rw-r--r--tools/lldb-mi/MIUtilVariant.h393
1 files changed, 198 insertions, 195 deletions
diff --git a/tools/lldb-mi/MIUtilVariant.h b/tools/lldb-mi/MIUtilVariant.h
index 3cb59796e5c0..aa1604ab6ff9 100644
--- a/tools/lldb-mi/MIUtilVariant.h
+++ b/tools/lldb-mi/MIUtilVariant.h
@@ -8,131 +8,131 @@
//===----------------------------------------------------------------------===//
//++
-// File: MIUtilVariant.h
+// File: MIUtilVariant.h
//
-// Overview: CMIUtilVariant interface.
+// Overview: CMIUtilVariant interface.
//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
+// Environment: Compilers: Visual C++ 12.
+// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
+// Libraries: See MIReadmetxt.
//
-// Gotchas: See CMIUtilVariant class description.
+// Gotchas: See CMIUtilVariant class description.
//
-// Copyright: None.
+// Copyright: None.
//--
#pragma once
// In-house headers:
-#include "MIDataTypes.h"
+#include "MIDataTypes.h"
//++ ============================================================================
-// Details: MI common code utility class. The class implements behaviour of a
-// variant object which holds any data object of type T. A copy of the
-// data object specified is made and stored in *this wrapper. When the
-// *this object is destroyed the data object hold within calls its
-// destructor should it have one.
-// Gotchas: None.
-// Authors: Illya Rudkin 18/06/2014.
-// Changes: None.
+// Details: MI common code utility class. The class implements behaviour of a
+// variant object which holds any data object of type T. A copy of the
+// data object specified is made and stored in *this wrapper. When the
+// *this object is destroyed the data object hold within calls its
+// destructor should it have one.
+// Gotchas: None.
+// Authors: Illya Rudkin 18/06/2014.
+// Changes: None.
//--
class CMIUtilVariant
{
-// Methods:
-public:
- /* ctor */ CMIUtilVariant( void );
- /* ctor */ CMIUtilVariant( const CMIUtilVariant & vrOther );
- /* ctor */ CMIUtilVariant( CMIUtilVariant & vrOther );
- /* ctor */ CMIUtilVariant( CMIUtilVariant && vrwOther );
- /* dtor */ ~CMIUtilVariant( void );
-
- template< typename T >
- void Set( const T & vArg );
- template< typename T >
- T * Get( void ) const;
+ // Methods:
+ public:
+ /* ctor */ CMIUtilVariant(void);
+ /* ctor */ CMIUtilVariant(const CMIUtilVariant &vrOther);
+ /* ctor */ CMIUtilVariant(CMIUtilVariant &vrOther);
+ /* ctor */ CMIUtilVariant(CMIUtilVariant &&vrwOther);
+ /* dtor */ ~CMIUtilVariant(void);
- CMIUtilVariant & operator= ( const CMIUtilVariant & vrOther );
- CMIUtilVariant & operator= ( CMIUtilVariant && vrwOther );
+ template <typename T> void Set(const T &vArg);
+ template <typename T> T *Get(void) const;
-// Classes:
-private:
- //++ ----------------------------------------------------------------------
- // Details: Base class wrapper to hold the variant's data object when
- // assigned to it by the Set() function. Do not use the CDataObjectBase
- // to create objects, use only CDataObjectBase derived objects,
- // see CDataObject() class.
- //--
- class CDataObjectBase
- {
- // Methods:
- public:
- /* ctor */ CDataObjectBase( void );
- /* ctor */ CDataObjectBase( const CDataObjectBase & vrOther );
- /* ctor */ CDataObjectBase( CDataObjectBase & vrOther );
- /* ctor */ CDataObjectBase( CDataObjectBase && vrwOther );
- //
- CDataObjectBase & operator= ( const CDataObjectBase & vrOther ) ;
- CDataObjectBase & operator= ( CDataObjectBase && vrwOther ) ;
-
- // Overrideable:
- public:
- virtual ~CDataObjectBase( void );
- virtual CDataObjectBase * CreateCopyOfSelf( void );
- virtual bool GetIsDerivedClass( void ) const;
+ CMIUtilVariant &operator=(const CMIUtilVariant &vrOther);
+ CMIUtilVariant &operator=(CMIUtilVariant &&vrwOther);
- // Overrideable:
- protected:
- virtual void Copy( const CDataObjectBase & vrOther );
- virtual void Destroy( void );
- };
+ // Classes:
+ private:
+ //++ ----------------------------------------------------------------------
+ // Details: Base class wrapper to hold the variant's data object when
+ // assigned to it by the Set() function. Do not use the CDataObjectBase
+ // to create objects, use only CDataObjectBase derived objects,
+ // see CDataObject() class.
+ //--
+ class CDataObjectBase
+ {
+ // Methods:
+ public:
+ /* ctor */ CDataObjectBase(void);
+ /* ctor */ CDataObjectBase(const CDataObjectBase &vrOther);
+ /* ctor */ CDataObjectBase(CDataObjectBase &vrOther);
+ /* ctor */ CDataObjectBase(CDataObjectBase &&vrwOther);
+ //
+ CDataObjectBase &operator=(const CDataObjectBase &vrOther);
+ CDataObjectBase &operator=(CDataObjectBase &&vrwOther);
- //++ ----------------------------------------------------------------------
- // Details: Derived from CDataObjectBase, this class is the wrapper for the
- // data object as it has an aggregate of type T which is a copy
- // of the data object assigned to the variant object.
- //--
- template< typename T >
- class CDataObject : public CDataObjectBase
- {
- // Methods:
- public:
- /* ctor */ CDataObject( void );
- /* ctor */ CDataObject( const T & vArg );
- /* ctor */ CDataObject( const CDataObject & vrOther );
- /* ctor */ CDataObject( CDataObject & vrOther );
- /* ctor */ CDataObject( CDataObject && vrwOther );
- //
- CDataObject & operator= ( const CDataObject & vrOther );
- CDataObject & operator= ( CDataObject && vrwOther );
- //
- T & GetDataObject( void );
+ // Overrideable:
+ public:
+ virtual ~CDataObjectBase(void);
+ virtual CDataObjectBase *CreateCopyOfSelf(void);
+ virtual bool GetIsDerivedClass(void) const;
- // Overridden:
- public:
- // From CDataObjectBase
- virtual ~CDataObject( void );
- virtual CDataObjectBase * CreateCopyOfSelf( void );
- virtual bool GetIsDerivedClass( void ) const;
+ // Overrideable:
+ protected:
+ virtual void Copy(const CDataObjectBase &vrOther);
+ virtual void Destroy(void);
+ };
- // Overridden:
- private:
- // From CDataObjectBase
- virtual void Copy( const CDataObject & vrOther );
- virtual void Destroy( void );
+ //++ ----------------------------------------------------------------------
+ // Details: Derived from CDataObjectBase, this class is the wrapper for the
+ // data object as it has an aggregate of type T which is a copy
+ // of the data object assigned to the variant object.
+ //--
+ template <typename T> class CDataObject : public CDataObjectBase
+ {
+ // Methods:
+ public:
+ /* ctor */ CDataObject(void);
+ /* ctor */ CDataObject(const T &vArg);
+ /* ctor */ CDataObject(const CDataObject &vrOther);
+ /* ctor */ CDataObject(CDataObject &vrOther);
+ /* ctor */ CDataObject(CDataObject &&vrwOther);
+ //
+ CDataObject &operator=(const CDataObject &vrOther);
+ CDataObject &operator=(CDataObject &&vrwOther);
+ //
+ T &GetDataObject(void);
- // Attributes:
- private:
- T m_dataObj;
- };
+ // Overridden:
+ public:
+ // From CDataObjectBase
+ virtual ~CDataObject(void);
+ virtual CDataObjectBase *CreateCopyOfSelf(void);
+ virtual bool GetIsDerivedClass(void) const;
-// Methods
-private:
- void Destroy( void );
- void Copy( const CMIUtilVariant & vrOther );
+ // Overrideable:
+ private:
+ virtual void Duplicate(const CDataObject &vrOther);
-// Attributes:
-private:
- CDataObjectBase * m_pDataObject;
+ // Overridden:
+ private:
+ // From CDataObjectBase
+ virtual void Destroy(void);
+
+ // Attributes:
+ private:
+ T m_dataObj;
+ };
+
+ // Methods
+ private:
+ void Destroy(void);
+ void Copy(const CMIUtilVariant &vrOther);
+
+ // Attributes:
+ private:
+ CDataObjectBase *m_pDataObject;
};
//---------------------------------------------------------------------------------------
@@ -140,112 +140,114 @@ private:
//---------------------------------------------------------------------------------------
//++ ------------------------------------------------------------------------------------
-// Details: CDataObject constructor.
-// Type: Method.
-// Args: T - The object's type.
-// Return: None.
-// Throws: None.
+// Details: CDataObject constructor.
+// Type: Method.
+// Args: T - The object's type.
+// Return: None.
+// Throws: None.
//--
-template< typename T >
-CMIUtilVariant::CDataObject< T >::CDataObject( void )
+template <typename T> CMIUtilVariant::CDataObject<T>::CDataObject(void)
{
}
//++ ------------------------------------------------------------------------------------
-// Details: CDataObject constructor.
-// Type: Method.
-// Args: T - The object's type.
-// vArg - (R) The data object to be stored in the variant object.
-// Return: None.
-// Throws: None.
+// Details: CDataObject constructor.
+// Type: Method.
+// Args: T - The object's type.
+// vArg - (R) The data object to be stored in the variant object.
+// Return: None.
+// Throws: None.
//--
-template< typename T >
-CMIUtilVariant::CDataObject< T >::CDataObject( const T & vArg )
+template <typename T> CMIUtilVariant::CDataObject<T>::CDataObject(const T &vArg)
{
- m_dataObj = vArg;
+ m_dataObj = vArg;
}
//++ ------------------------------------------------------------------------------------
-// Details: CDataObject destructor.
-// Type: Overridden.
-// Args: T - The object's type.
-// Return: None.
-// Throws: None.
+// Details: CDataObject destructor.
+// Type: Overridden.
+// Args: T - The object's type.
+// Return: None.
+// Throws: None.
//--
-template< typename T >
-CMIUtilVariant::CDataObject< T >::~CDataObject( void )
+template <typename T> CMIUtilVariant::CDataObject<T>::~CDataObject(void)
{
- Destroy();
+ Destroy();
}
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the data object hold by *this object wrapper.
-// Type: Method.
-// Args: T - The object's type.
-// Return: T & - Reference to the data object.
-// Throws: None.
+// Details: Retrieve the data object hold by *this object wrapper.
+// Type: Method.
+// Args: T - The object's type.
+// Return: T & - Reference to the data object.
+// Throws: None.
//--
-template< typename T >
-T & CMIUtilVariant::CDataObject< T >::GetDataObject( void )
+template <typename T>
+T &
+CMIUtilVariant::CDataObject<T>::GetDataObject(void)
{
- return m_dataObj;
+ return m_dataObj;
}
//++ ------------------------------------------------------------------------------------
-// Details: Create a new copy of *this class.
-// Type: Overridden.
-// Args: T - The object's type.
-// Return: CDataObjectBase * - Pointer to a new object.
-// Throws: None.
+// Details: Create a new copy of *this class.
+// Type: Overridden.
+// Args: T - The object's type.
+// Return: CDataObjectBase * - Pointer to a new object.
+// Throws: None.
//--
-template< typename T >
-CMIUtilVariant::CDataObjectBase * CMIUtilVariant::CDataObject< T >::CreateCopyOfSelf( void )
+template <typename T>
+CMIUtilVariant::CDataObjectBase *
+CMIUtilVariant::CDataObject<T>::CreateCopyOfSelf(void)
{
- CDataObject * pCopy = new CDataObject< T >( m_dataObj );
-
- return pCopy;
+ CDataObject *pCopy = new CDataObject<T>(m_dataObj);
+
+ return pCopy;
}
//++ ------------------------------------------------------------------------------------
-// Details: Determine if *this object is a derived from CDataObjectBase.
-// Type: Overridden.
-// Args: T - The object's type.
-// Return: bool - True = *this is derived from CDataObjectBase
-// - False = *this is an instance of the base class.
-// Throws: None.
+// Details: Determine if *this object is a derived from CDataObjectBase.
+// Type: Overridden.
+// Args: T - The object's type.
+// Return: bool - True = *this is derived from CDataObjectBase
+// - False = *this is an instance of the base class.
+// Throws: None.
//--
-template< typename T >
-bool CMIUtilVariant::CDataObject< T >::GetIsDerivedClass( void ) const
+template <typename T>
+bool
+CMIUtilVariant::CDataObject<T>::GetIsDerivedClass(void) const
{
- return true;
+ return true;
}
//++ ------------------------------------------------------------------------------------
-// Details: Perform a bitwise copy of *this object.
-// Type: Overridden.
-// Args: T - The object's type.
-// vrOther - (R) The other object.
-// Return: None.
-// Throws: None.
+// Details: Perform a bitwise copy of *this object.
+// Type: Overrideable.
+// Args: T - The object's type.
+// vrOther - (R) The other object.
+// Return: None.
+// Throws: None.
//--
-template< typename T >
-void CMIUtilVariant::CDataObject< T >::Copy( const CDataObject & vrOther )
+template <typename T>
+void
+CMIUtilVariant::CDataObject<T>::Duplicate(const CDataObject &vrOther)
{
- CDataObjectBase::Copy( vrOther );
- m_dataObj = vrOther.m_dataObj;
+ CDataObjectBase::Copy(vrOther);
+ m_dataObj = vrOther.m_dataObj;
}
//++ ------------------------------------------------------------------------------------
-// Details: Release any resources used by *this object.
-// Type: Overridden.
-// Args: None.
-// Return: None.
-// Throws: None.
+// Details: Release any resources used by *this object.
+// Type: Overridden.
+// Args: None.
+// Return: None.
+// Throws: None.
//--
-template< typename T >
-void CMIUtilVariant::CDataObject< T >::Destroy( void )
+template <typename T>
+void
+CMIUtilVariant::CDataObject<T>::Destroy(void)
{
- CDataObjectBase::Destroy();
+ CDataObjectBase::Destroy();
}
//---------------------------------------------------------------------------------------
@@ -253,36 +255,37 @@ void CMIUtilVariant::CDataObject< T >::Destroy( void )
//---------------------------------------------------------------------------------------
//++ ------------------------------------------------------------------------------------
-// Details: Assign to the variant an object of a specified type.
-// Type: Template method.
-// Args: T - The object's type.
-// vArg - (R) The object to store.
-// Return: None.
-// Throws: None.
+// Details: Assign to the variant an object of a specified type.
+// Type: Template method.
+// Args: T - The object's type.
+// vArg - (R) The object to store.
+// Return: None.
+// Throws: None.
//--
-template< typename T >
-void CMIUtilVariant::Set( const T & vArg )
+template <typename T>
+void
+CMIUtilVariant::Set(const T &vArg)
{
- m_pDataObject = new CDataObject< T >( vArg );
+ m_pDataObject = new CDataObject<T>(vArg);
}
//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the data object from *this variant.
-// Type: Template method.
-// Args: T - The object's type.
-// Return: T * - Pointer the data object, NULL = data object not assigned to *this variant.
-// Throws: None.
+// Details: Retrieve the data object from *this variant.
+// Type: Template method.
+// Args: T - The object's type.
+// Return: T * - Pointer the data object, NULL = data object not assigned to *this variant.
+// Throws: None.
//--
-template< typename T >
-T * CMIUtilVariant::Get( void ) const
+template <typename T>
+T *
+CMIUtilVariant::Get(void) const
{
- if( (m_pDataObject != nullptr) && m_pDataObject->GetIsDerivedClass() )
- {
- CDataObject< T > * pDataObj = static_cast< CDataObject< T > * >( m_pDataObject );
- return &pDataObj->GetDataObject();
- }
+ if ((m_pDataObject != nullptr) && m_pDataObject->GetIsDerivedClass())
+ {
+ CDataObject<T> *pDataObj = static_cast<CDataObject<T> *>(m_pDataObject);
+ return &pDataObj->GetDataObject();
+ }
- // Do not use a CDataObjectBase object, use only CDataObjectBase derived objects
- return nullptr;
+ // Do not use a CDataObjectBase object, use only CDataObjectBase derived objects
+ return nullptr;
}
-