Skip to content

Proposal: addition of thin RAII wrappers for ease of use #190

@amtopel

Description

@amtopel

Would you consider adding a header with some thin RAII wrappers to make using this library slightly easier? Here are a couple examples of what I'm thinking about:

class CPropValuePtr
{
public:
	CPropValuePtr() :
		m_p(NULL)
	{
	}

	~CPropValuePtr()
	{
		Free();
	}

	LPSPropValue* operator&() noexcept
	{
		return &m_p;
	}

	LPSPropValue operator->() noexcept
	{
		return m_p;
	}

	void Free() noexcept
	{
		MAPIFreeBuffer(m_p);
		m_p = NULL;
	}

	LPSPropValue m_p;
};


class CRowSetPtr
{
public:
	CRowSetPtr() :
		m_p(NULL)
	{
	}

	~CRowSetPtr()
	{
		Free();
	}

	LPSRowSet* operator&() noexcept
	{
		return &m_p;
	}

	LPSRowSet operator->() noexcept
	{
		return m_p;
	}

	void Free() noexcept
	{
		FreeProws(m_p);
		m_p = NULL;
	}

	LPSRowSet m_p;
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions