am c6c6ab50: Merge "Implement C++11 move semantics for android::FileMap"
* commit 'c6c6ab50bc11d55f3135312ceccbcf0c400b437e': Implement C++11 move semantics for android::FileMap
This commit is contained in:
commit
bda375fa41
2 changed files with 40 additions and 0 deletions
|
|
@ -52,6 +52,9 @@ class FileMap {
|
||||||
public:
|
public:
|
||||||
FileMap(void);
|
FileMap(void);
|
||||||
|
|
||||||
|
FileMap(FileMap&& f);
|
||||||
|
FileMap& operator=(FileMap&& f);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a new mapping on an open file.
|
* Create a new mapping on an open file.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,43 @@ FileMap::FileMap(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Move Constructor.
|
||||||
|
FileMap::FileMap(FileMap&& other)
|
||||||
|
: mFileName(other.mFileName), mBasePtr(other.mBasePtr), mBaseLength(other.mBaseLength),
|
||||||
|
mDataOffset(other.mDataOffset), mDataPtr(other.mDataPtr), mDataLength(other.mDataLength)
|
||||||
|
#if defined(__MINGW32__)
|
||||||
|
, mFileHandle(other.mFileHandle), mFileMapping(other.mFileMapping)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
other.mFileName = NULL;
|
||||||
|
other.mBasePtr = NULL;
|
||||||
|
other.mDataPtr = NULL;
|
||||||
|
#if defined(__MINGW32__)
|
||||||
|
other.mFileHandle = 0;
|
||||||
|
other.mFileMapping = 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move assign operator.
|
||||||
|
FileMap& FileMap::operator=(FileMap&& other) {
|
||||||
|
mFileName = other.mFileName;
|
||||||
|
mBasePtr = other.mBasePtr;
|
||||||
|
mBaseLength = other.mBaseLength;
|
||||||
|
mDataOffset = other.mDataOffset;
|
||||||
|
mDataPtr = other.mDataPtr;
|
||||||
|
mDataLength = other.mDataLength;
|
||||||
|
other.mFileName = NULL;
|
||||||
|
other.mBasePtr = NULL;
|
||||||
|
other.mDataPtr = NULL;
|
||||||
|
#if defined(__MINGW32__)
|
||||||
|
mFileHandle = other.mFileHandle;
|
||||||
|
mFileMapping = other.mFileMapping;
|
||||||
|
other.mFileHandle = 0;
|
||||||
|
other.mFileMapping = 0;
|
||||||
|
#endif
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
// Destructor.
|
// Destructor.
|
||||||
FileMap::~FileMap(void)
|
FileMap::~FileMap(void)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue