Diluculum::LuaUserData Class Reference

#include <LuaUserData.hpp>

List of all members.

Public Member Functions

 LuaUserData (size_t size)
 LuaUserData (const LuaUserData &other)
const LuaUserDataoperator= (const LuaUserData &rhs)
size_t getSize () const
void * getData ()
 Returns a pointer to the data stored in this LuaUserData.
const void * getData () const
bool operator> (const LuaUserData &rhs) const
bool operator< (const LuaUserData &rhs) const
bool operator== (const LuaUserData &rhs) const
bool operator!= (const LuaUserData &rhs) const
 The "different than" operator for LuaUserData.

Private Attributes

size_t size_
 The number of bytes stored "in" data_.
boost::scoped_array< char > data_
 A (smart) pointer to the data owned by this LuaUserData.


Detailed Description

A C++ equivalent of a Lua userdata. Or, perhaps more precisely: something that lives in the C++-space, and that stores data that would normally be in the Lua-space as userdata. This is used as the value of a LuaValue when it holds userdata.
Note:
A LuaUserData has no counterpart in a Lua state. It is simply a block of memory that can be (via a LuaValue and a LuaState) stored in or read from a userdata in Lua state.

Definition at line 45 of file LuaUserData.hpp.


Constructor & Destructor Documentation

Diluculum::LuaUserData::LuaUserData size_t  size  ) 
 

Constructs a LuaUserData, allocating size bytes of memory. This memory is initially filled with garbage. And this memory is automatically freed when the LuaUserData is destroyed.

Diluculum::LuaUserData::LuaUserData const LuaUserData other  ) 
 

The copy constructor. The newly constructed LuaUserData will have its own block of memory, with the same contents as the other. In other words, this constructor allocates and copies memory.


Member Function Documentation

const void* Diluculum::LuaUserData::getData  )  const [inline]
 

Returns a const pointer to the data stored in this LuaUserData.

Definition at line 79 of file LuaUserData.hpp.

References data_.

void* Diluculum::LuaUserData::getData  )  [inline]
 

Returns a pointer to the data stored in this LuaUserData.

Definition at line 74 of file LuaUserData.hpp.

References data_.

size_t Diluculum::LuaUserData::getSize  )  const [inline]
 

Returns the size, in bytes, of the data stored in this LuaUserData.

Definition at line 71 of file LuaUserData.hpp.

References size_.

bool Diluculum::LuaUserData::operator!= const LuaUserData rhs  )  const
 

The "different than" operator for LuaUserData.

bool Diluculum::LuaUserData::operator< const LuaUserData rhs  )  const
 

The "less than" operator for LuaUserData.

Note:
Given two LuaUserDatas, the decision on which one is lesser is somewhat arbitrary. The criterion is similar to the described for the "greater than" operator.
Todo:
This is currently implemented using memcmp(). I think that this is not part of the C++ standard yet (just of C99).

const LuaUserData& Diluculum::LuaUserData::operator= const LuaUserData rhs  ) 
 

Assigns a LuaUserData to this one. The memory currently allocated for this will be freed, new memory will be allocated, and the data stored in rhs will be copied to this.

bool Diluculum::LuaUserData::operator== const LuaUserData rhs  )  const
 

The "equal to" operator for LuaUserData.

Note:
Two LuaUserDatas are considered equal if the data they store have the same size and the same contents.
Todo:
In Lua, a userdata is considered equal only to itself. Things are different here. Does this have a reason to not be like in Lua?

bool Diluculum::LuaUserData::operator> const LuaUserData rhs  )  const
 

The "greater than" operator for LuaUserData.

Note:
Given two LuaUserDatas, the decision on which one is greater is somewhat arbitrary. Here, the userdata with larger size() is considered greater. If both are equal, the decision is based on the contents of the stored data.
Todo:
This is currently implemented using memcmp(). I think that this is not part of the C++ standard yet (just of C99).


Member Data Documentation

boost::scoped_array<char> Diluculum::LuaUserData::data_ [private]
 

A (smart) pointer to the data owned by this LuaUserData.

Definition at line 117 of file LuaUserData.hpp.

Referenced by getData().

size_t Diluculum::LuaUserData::size_ [private]
 

The number of bytes stored "in" data_.

Definition at line 114 of file LuaUserData.hpp.

Referenced by getSize().


The documentation for this class was generated from the following file:
Generated on Tue Feb 6 09:30:26 2007 for Diluculum by  doxygen 1.4.6