#include <VXIvalue.h>
Used correctly, this class can eliminate common memory leaks associated with VXIMap usage. For instance:
VXIMap * GenerateMapFromParams(void) { VXIMapHolder result; DoStuff(); // this code may throw an exception. return result.Release(); }
int Foo(void) { VXIMapHolder params(GenerateMapFromParams()); ProcessParams(params); // This code may throw an exception. return 0; }
Public Member Functions | |
VXIMapHolder () | |
Creates an empty VXIMap. | |
VXIMapHolder (VXIMap *m) | |
Takes ownership of a VXIMap. | |
~VXIMapHolder () | |
Destorys owned VXIMap. | |
VXIMapHolder & | operator= (const VXIMapHolder &x) |
VXIMap * | GetValue () const |
Returns the internal map. | |
VXIMap * | Release () |
Give up ownership of the contained VXIMap. | |
void | Acquire (VXIMap *m) |
Acquires a new map, destroying the contained one first. | |
VXIMapHolder (const VXIMapHolder &mh) | |
Clones the contained map to a new VXIMapHolder. |
|
Creates an empty VXIMap.
|
|
Takes ownership of a VXIMap.
|
|
Destorys owned VXIMap.
|
|
Clones the contained map to a new VXIMapHolder.
|
|
Acquires a new map, destroying the contained one first.
|
|
Returns the internal map. The standard map manipulation functions may then be used. |
|
|
|
Give up ownership of the contained VXIMap. This does not destroy the contained VXIMap. Rather, a a pointer is returned, and it is the callers responsibility to destroy the map.
|